/* =========================================================
   山河卷 (Worldbook) - 龙宫贝阙
   🐚 仙气悬挂式文件管理系统
   ========================================================= */

/* === 🔧 标准化：液态玻璃材质变量 === */
#worldbook {
    /* 护眼仙气配色 */
    --wb-bg-top: #dceefb; 
    --wb-bg-bot: #eef2f3;
    
    /* 🔧 统一材质：液态玻璃拟态 (Liquid Glass OS) */
    --wb-glass-card: rgba(255, 255, 255, 0.6);        /* 卡片背景 */
    --wb-glass-border: rgba(255, 255, 255, 0.3);      /* 微光描边 */
    --wb-glass-highlight: rgba(255, 255, 255, 0.8);   /* 高亮状态 */
    --wb-glass-blur: blur(20px);                       /* 毛玻璃模糊 */
    --wb-border-radius: 20px;                          /* 统一圆角 */
    
    /* 文字：深海蓝灰 */
    --wb-text-main: #546e7a;
    --wb-text-sub: #90a4ae;
    --wb-accent: #81d4fa; /* 冰蓝光效 */
}

/* === 容器基础 === */
#worldbook {
    position: relative;
    overflow: hidden;
    /* 背景：柔和的晨雾渐变 */
    background: linear-gradient(180deg, var(--wb-bg-top) 0%, var(--wb-bg-bot) 100%);
}

/* 背景流光 (柔和版) */
#worldbook .wb-bg-flow {
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, transparent 60%);
    animation: wb-flow 15s infinite alternate;
    pointer-events: none;
    opacity: 0.6;
}
@keyframes wb-flow {
    from { transform: translate(-20px, -20px); }
    to { transform: translate(20px, 20px); }
}

/* =========================================
   1. 首页 (Home) - 悬挂展示
   ========================================= */
#worldbook .wb-top-bar {
    padding: 50px 20px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 20;
    position: relative;
}

/* 左侧返回键 */
#worldbook .wb-top-bar > .wb-icon-btn:first-child {
    order: 1;
}

/* 中间标题 */
#worldbook .wb-app-title {
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 28px;
    color: var(--wb-text-main);
    text-shadow: 0 1px 2px rgba(255,255,255,0.8);
    order: 2;
    flex: 1;
    text-align: center;
}

/* 右侧功能键组 */
#worldbook .wb-actions {
    display: flex;
    gap: 10px;
    order: 3;
}

/* 🔧 玻璃按钮 - 统一材质 */
#worldbook .wb-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--wb-glass-card);
    border: 1px solid var(--wb-glass-border);
    backdrop-filter: var(--wb-glass-blur); /* 🔧 统一模糊 */
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--wb-text-main);
    cursor: pointer;
    transition: 0.2s;
}
#worldbook .wb-icon-btn:hover {
    background: var(--wb-glass-highlight);
    box-shadow: 0 0 10px var(--wb-accent);
}

/* =========================================
   悬挂容器 - 横向滚动布局
   ========================================= */

/* 容器：启用 Flex 横向滚动 */
#worldbook .wb-hanging-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    
    /* 🔧 Flex 横向布局 */
    display: flex;
    flex-direction: row; /* 明确指定横向 */
    flex-wrap: nowrap; /* 不换行 */
    align-items: flex-start;
    gap: 60px;
    
    /* 🔧 内边距 */
    padding: 120px 30px 50px 30px;
    
    /* 🔧 激活横向滚动 */
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    
    /* 🔧 确保可交互 */
    pointer-events: auto;
    
    /* 🔧 隐藏滚动条 */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

/* 隐藏滚动条 (Chrome/Safari) */
#worldbook .wb-hanging-area::-webkit-scrollbar {
    display: none;
}


/* 空状态提示 */
#worldbook .wb-empty-state {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}
#worldbook .wb-empty-icon {
    font-size: 80px;
    margin-bottom: 20px;
    opacity: 0.3;
}
#worldbook .wb-empty-title {
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 24px;
    color: var(--wb-text-main);
    margin-bottom: 10px;
}
#worldbook .wb-empty-subtitle {
    font-size: 14px;
    color: var(--wb-text-sub);
    line-height: 1.6;
}

/* 贝壳挂件 - Flex 子元素 */
#worldbook .wb-hanger {
    /* 🔧 移除绝对定位，使用流式 Flex 布局 */
    position: relative;
    
    /* 🔧 Flex 子元素：禁止缩小，保持原始尺寸 */
    flex: 0 0 auto;
    flex-shrink: 0;
    
    /* 🔧 最小宽度，防止被压缩 */
    min-width: 140px;
    
    /* 垂直布局 */
    display: flex;
    flex-direction: column;
    align-items: center;
    
    /* 动画与交互 */
    transform-origin: top center;
    cursor: pointer;
    animation: wb-sway 6s infinite ease-in-out alternate;
    transition: transform 0.3s;
    pointer-events: auto;
}

/* 动画延迟（通过 --index 变量控制） */
#worldbook .wb-hanger:nth-child(n) {
    animation-delay: calc(0.2s * var(--index, 0));
}

/* 管理模式 - 贝壳抖动 */
#worldbook.wb-managing-folders .wb-hanger {
    animation: wb-shake 0.5s infinite;
}

/* 删除角标 */
#worldbook .wb-delete-badge {
    position: absolute;
    top: 30px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.4);
    z-index: 10;
    cursor: pointer;
    transition: 0.2s;
}
#worldbook .wb-delete-badge:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.6);
}
#worldbook.wb-managing-folders .wb-delete-badge {
    display: flex;
}

/* 抖动动画 */
@keyframes wb-shake {
    0%, 100% { transform: rotate(-1deg); }
    50% { transform: rotate(1deg); }
}

@keyframes wb-sway {
    0% { transform: rotate(-2deg); }
    100% { transform: rotate(2deg); }
}

/* 珍珠链 */
/* 珍珠链 */
#worldbook .wb-pearl-chain {
    width: 4px;
    height: 60px;
    background-image: radial-gradient(circle, #fff 40%, #cfd8dc 60%, transparent 70%);
    background-size: 8px 8px;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.1));
}

/* 贝壳 */
#worldbook .wb-shell-body {
    width: 100px;
    height: 80px;
    position: relative;
    z-index: 2;
    border-radius: 50% 50% 10% 10% / 100% 100% 20% 20%;
    background: radial-gradient(circle at 50% 100%, #fff, #e1f5fe);
    box-shadow: 0 5px 15px rgba(129, 212, 250, 0.3), inset 0 0 10px #fff;
    border: 1px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
#worldbook .wb-shell-ridges {
    position: absolute;
    width: 100%;
    height: 100%;
    background: repeating-conic-gradient(
        from 270deg at 50% 120%, 
        transparent 0deg, 
        transparent 8deg, 
        rgba(129,212,250,0.1) 10deg, 
        rgba(129,212,250,0.1) 12deg
    );
}
#worldbook .wb-center-pearl {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #fff, #eceff1);
    box-shadow: 0 0 10px rgba(255,255,255,0.9);
    z-index: 3;
}

/* 挂牌 (水晶质感) */
#worldbook .wb-tag-card {
    margin-top: 5px;
    width: 30px;
    height: 100px;
    background: rgba(255,255,255,0.3);
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    cursor: pointer; /* 可点击编辑 */
    transition: 0.2s;
}
#worldbook .wb-tag-card:hover {
    background: rgba(255,255,255,0.4);
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}
#worldbook .wb-tag-text {
    writing-mode: vertical-rl;
    text-orientation: upright; /* 🔧 修复：数字和英文直立显示 */
    font-family: 'Ma Shan Zheng', cursive;
    font-size: 18px;
    color: var(--wb-text-main);
    letter-spacing: 4px;
}

/* =========================================
   2. 列表页 (List Layer) - 鲛绡风格
   ========================================= */
#worldbook .wb-list-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 75%;
    /* 🔧 统一材质：液态玻璃 */
    background: var(--wb-glass-card);
    backdrop-filter: var(--wb-glass-blur);
    border: 1px solid var(--wb-glass-border);
    border-radius: var(--wb-border-radius) var(--wb-border-radius) 0 0;
    box-shadow: 0 -10px 40px rgba(129, 212, 250, 0.1);
    z-index: 50;
    display: flex;
    flex-direction: column;
    transform: translateY(110%);
    transition: 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#worldbook .wb-list-layer.wb-open {
    transform: translateY(0);
}

#worldbook .wb-list-header {
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.3);
}
#worldbook .wb-list-title {
    font-size: 20px;
    color: var(--wb-text-main);
    font-weight: bold;
}

/* 🔍 搜索栏 */
#worldbook .wb-search-bar {
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}
#worldbook .wb-search-bar i {
    font-size: 18px;
    color: var(--wb-text-sub);
}
#worldbook .wb-search-bar input {
    flex: 1;
    padding: 10px 15px;
    border: none;
    border-radius: 20px;
    background: rgba(255,255,255,0.5);
    font-size: 14px;
    color: var(--wb-text-main);
    outline: none;
    transition: 0.2s;
}
#worldbook .wb-search-bar input:focus {
    background: rgba(255,255,255,0.8);
    box-shadow: 0 2px 8px rgba(129, 212, 250, 0.2);
}
#worldbook .wb-search-bar input::placeholder {
    color: var(--wb-text-sub);
}

/* 列表工具栏 */
#worldbook .wb-list-tools {
    display: flex;
    gap: 15px;
    align-items: center;
}
#worldbook .wb-tool-text {
    font-size: 14px;
    font-weight: bold;
    color: #4fc3f7;
    cursor: pointer;
}
#worldbook .wb-tool-icon {
    font-size: 20px;
    color: var(--wb-text-sub);
    cursor: pointer;
}

#worldbook .wb-list-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* 🔧 条目样式：统一液态玻璃材质 */
#worldbook .wb-entry-item {
    padding: 15px;
    border-radius: var(--wb-border-radius);
    margin-bottom: 12px;
    background: var(--wb-glass-card);
    border: 1px solid var(--wb-glass-border);
    backdrop-filter: var(--wb-glass-blur); /* 🔧 添加毛玻璃效果 */
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}
#worldbook .wb-entry-item:hover {
    background: var(--wb-glass-highlight);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(129, 212, 250, 0.2);
}

/* 勾选框 */
#worldbook .wb-check-box {
    width: 0;
    overflow: hidden;
    opacity: 0;
    transition: 0.3s;
}
#worldbook .wb-list-layer.wb-managing .wb-check-box {
    width: 25px;
    opacity: 1;
    margin-right: 5px;
}
#worldbook .wb-circle-check {
    width: 18px;
    height: 18px;
    border: 2px solid var(--wb-text-sub);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
#worldbook .wb-circle-check.wb-checked {
    background: #4fc3f7;
    border-color: #4fc3f7;
    color: #fff;
}
#worldbook .wb-circle-check.wb-checked::after {
    content: '✓';
    font-size: 10px;
}

#worldbook .wb-entry-info {
    flex: 1;
}
#worldbook .wb-entry-name {
    font-size: 16px;
    color: var(--wb-text-main);
    font-weight: bold;
}
#worldbook .wb-entry-meta {
    font-size: 12px;
    color: var(--wb-text-sub);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 水晶开关 - 条目启用/禁用状态 */
#worldbook .wb-entry-toggle {
    width: 40px;
    height: 22px;
    background: rgba(200, 200, 200, 0.3);
    border-radius: 11px;
    border: 1px solid rgba(255,255,255,0.5);
    position: relative;
    cursor: pointer;
    transition: 0.3s;
    backdrop-filter: blur(5px);
    flex-shrink: 0;
}
#worldbook .wb-entry-toggle::after {
    content: '';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 16px;
    height: 16px;
    background: radial-gradient(circle at 30% 30%, #fff, #eceff1);
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
#worldbook .wb-entry-toggle.wb-enabled {
    background: linear-gradient(135deg, #b3e5fc, #81d4fa);
}
#worldbook .wb-entry-toggle.wb-enabled::after {
    left: 20px;
}
/* 禁用状态的条目变灰 */
#worldbook .wb-entry-item.wb-disabled {
    opacity: 0.5;
}
#worldbook .wb-entry-item.wb-disabled .wb-entry-name {
    text-decoration: line-through;
    color: var(--wb-text-sub);
}

/* 标签美化 */
#worldbook .wb-tag {
    padding: 2px 6px;
    background: rgba(129, 212, 250, 0.1);
    border-radius: 4px;
    color: #4fc3f7;
}

/* 底部栏 */
#worldbook .wb-bottom-bar {
    padding: 15px 20px 30px;
    border-top: 1px solid rgba(255,255,255,0.3);
    display: flex;
    justify-content: center;
    background: rgba(255,255,255,0.4);
}

/* 新建按钮：发光珍珠 */
#worldbook .wb-add-btn {
    width: 100%;
    height: 44px;
    background: linear-gradient(135deg, #e1f5fe, #b3e5fc);
    color: #0277bd;
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    gap: 8px;
    box-shadow: 0 5px 15px rgba(129, 212, 250, 0.3);
    border: 1px solid rgba(255,255,255,0.8);
}

/* 批量操作栏 */
#worldbook .wb-batch-actions {
    display: none;
    width: 100%;
    justify-content: space-around;
}
#worldbook .wb-list-layer.wb-managing .wb-add-btn {
    display: none;
}
#worldbook .wb-list-layer.wb-managing .wb-batch-actions {
    display: flex;
}

#worldbook .wb-action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 10px;
    color: var(--wb-text-main);
    cursor: pointer;
}
#worldbook .wb-action-item i {
    font-size: 20px;
    margin-bottom: 2px;
}
#worldbook .wb-action-item.wb-delete i {
    color: #ff8a80;
}

/* =========================================
   3. 编辑页 (Editor)
   ========================================= */
#worldbook .wb-editor-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fcfdfe; /* 护眼纸张色 */
    z-index: 60;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}
#worldbook .wb-editor-layer.wb-open {
    transform: translateX(0);
}

#worldbook .wb-editor-nav {
    padding: 50px 20px 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
#worldbook .wb-save-text {
    color: #4fc3f7;
    font-weight: bold;
    cursor: pointer;
}

#worldbook .wb-editor-body {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
}

#worldbook .wb-clean-input {
    width: 100%;
    padding: 12px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    margin-bottom: 20px;
    color: var(--wb-text-main);
}
#worldbook .wb-clean-textarea {
    width: 100%;
    min-height: 300px;
    padding: 15px;
    background: #fff;
    border: none;
    border-radius: 12px;
    resize: none;
    outline: none;
    font-size: 15px;
    line-height: 1.8;
    color: #555;
}

#worldbook .wb-toggle-box {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}
#worldbook .wb-toggle-btn {
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid #eee;
    font-size: 12px;
    color: var(--wb-text-sub);
    cursor: pointer;
}
#worldbook .wb-toggle-btn.wb-active {
    background: #e1f5fe;
    color: #0277bd;
    border-color: #81d4fa;
}
#worldbook #wb-keyword-box {
    display: none;
    margin-bottom: 20px;
}

/* =========================================
   🔧 修复3: 自定义液态玻璃弹窗系统
   (替换所有 prompt/alert/confirm)
   ========================================= */

/* 弹窗遮罩层 */
#worldbook .wb-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px); /* 🔧 毛玻璃遮罩 */
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    animation: wb-fadeIn 0.3s ease;
}

#worldbook .wb-modal-overlay.wb-show {
    display: flex;
}

@keyframes wb-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 🔧 液态玻璃弹窗主体 */
#worldbook .wb-glass-modal {
    width: 320px;
    max-width: 90%;
    background: var(--wb-glass-card); /* 🔧 统一材质 */
    backdrop-filter: var(--wb-glass-blur); /* 🔧 20px 模糊 */
    border: 1px solid var(--wb-glass-border); /* 🔧 微光描边 */
    border-radius: var(--wb-border-radius); /* 🔧 20px 圆角 */
    box-shadow: 0 10px 40px rgba(129, 212, 250, 0.3);
    padding: 25px;
    animation: wb-modalSlideIn 0.3s ease;
}

@keyframes wb-modalSlideIn {
    from { 
        transform: scale(0.9) translateY(-20px); 
        opacity: 0; 
    }
    to { 
        transform: scale(1) translateY(0); 
        opacity: 1; 
    }
}

/* 弹窗标题 */
#worldbook .wb-modal-title {
    font-size: 18px;
    font-weight: bold;
    color: var(--wb-text-main);
    margin-bottom: 15px;
    text-align: center;
}

/* 弹窗消息文本 */
#worldbook .wb-modal-message {
    font-size: 15px;
    color: var(--wb-text-main);
    margin-bottom: 20px;
    text-align: center;
    line-height: 1.6;
}

/* 弹窗输入框 */
#worldbook .wb-modal-input {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(129, 212, 250, 0.3);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    font-size: 15px;
    color: var(--wb-text-main);
    outline: none;
    transition: 0.2s;
    margin-bottom: 20px;
}

#worldbook .wb-modal-input:focus {
    border-color: var(--wb-accent);
    box-shadow: 0 0 10px rgba(129, 212, 250, 0.2);
}

/* 弹窗按钮组 */
#worldbook .wb-modal-buttons {
    display: flex;
    gap: 10px;
}

#worldbook .wb-modal-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}

/* 取消按钮 */
#worldbook .wb-modal-btn-cancel {
    background: rgba(255, 255, 255, 0.5);
    color: var(--wb-text-sub);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

#worldbook .wb-modal-btn-cancel:hover {
    background: rgba(255, 255, 255, 0.8);
}

/* 确认按钮 */
#worldbook .wb-modal-btn-confirm {
    background: linear-gradient(135deg, #81d4fa, #4fc3f7);
    color: white;
    box-shadow: 0 3px 10px rgba(129, 212, 250, 0.3);
}

#worldbook .wb-modal-btn-confirm:hover {
    box-shadow: 0 5px 15px rgba(129, 212, 250, 0.5);
    transform: translateY(-1px);
}

/* 危险按钮（删除等操作） */
#worldbook .wb-modal-btn-danger {
    background: linear-gradient(135deg, #ff8a80, #ff5252);
    color: white;
    box-shadow: 0 3px 10px rgba(255, 138, 128, 0.3);
}

#worldbook .wb-modal-btn-danger:hover {
    box-shadow: 0 5px 15px rgba(255, 138, 128, 0.5);
    transform: translateY(-1px);
}
