/* ========================================
   导航站点专用样式 - 大气沉浸版 (Modern Pro)
   版本：8.0 - 宽屏、微质感、大留白
   ======================================== */

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-bg: #ffffff;
    --bg-color: #f8f9fc; /* 极淡的蓝灰背景，比纯白更有质感 */
    --text-main: #1f2937;
    --text-sub: #6b7280;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.02);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.01);
    --shadow-hover: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    --radius-lg: 16px;
    --radius-xl: 24px;
}

body {
    background-color: var(--bg-color);
    /* 增加一个极淡的背景纹理，提升高级感 */
    background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
    background-size: 32px 32px;
}

/* ---------------- 导航页面头部 (大气版) ---------------- */
.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 60px; /* 加大底部间距 */
    padding: 40px 0 20px 0;
    flex-wrap: wrap;
    gap: 20px;
}

.nav-header h1 {
    color: var(--text-main);
    font-size: 32px; /* 加大标题 */
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #1f2937, #4b5563);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-actions {
    display: flex;
    gap: 12px;
}

.add-category-btn {
    padding: 12px 24px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    border-radius: 12px !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.4) !important;
}

.add-category-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6) !important;
}

/* ---------------- 分类区域 (清爽无框 + 大间距) ---------------- */
.category-section {
    background: transparent;
    border: none;
    padding: 0 10px;
    margin-bottom: 80px; /* 分类之间巨大的呼吸感 */
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

/*  staggered animation delay handled in JS or inline style if needed, 
    but simple fade is enough for now */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px; /* 标题与网址的间距加大 */
    padding: 0 12px;
    background: transparent;
    border: none;
    position: relative;
}



.category-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 0; /* 🔥 改为 0，让文字紧贴左边缘（或容器内边距） */
}

.category-title span:first-child {
    font-size: 28px; /* 大图标 */
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.category-count-badge {
    background: #eef2ff;
    color: #667eea;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    min-width: 24px;
    text-align: center;
}

.category-actions {
    display: flex;
    gap: 10px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.category-section:hover .category-actions {
    opacity: 1;
}

.category-actions .btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s;
}

/* ---------------- 网址网格 (大气布局) ---------------- */
.website-grid {
    display: grid;
    
    /* 🔥 核心修改逻辑：
       1. repeat(auto-fit, ...): 尝试自动填充列数。
       2. minmax(260px, 320px): 
          - 最小宽度 260px (保证不小)
          - 最大宽度 320px (🔥 关键！限制卡片最宽只能到 320px，防止它被拉得太宽)
       3. 这样即使一行只有 2 个，它们也只会是 320px 宽，而不是撑满整个屏幕。
    */
    grid-template-columns: repeat(auto-fit, minmax(260px, 320px));
    
    gap: 24px; /* 卡片之间的间距 */
    padding: 0 12px;
    width: 100%;
    
    /* 🔥 新增：让不足一行的卡片靠左对齐，而不是分散对齐 */
    justify-content: start; 
}

.website-card-wrapper {
    position: relative;
    display: block;
    height: 100%;
    perspective: 1000px; /* 为3D效果做准备 */
}

/* 卡片主体：极简白 + 柔光阴影 */
.website-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 16px 60px 16px 20px; /* 右侧留出按钮空间 */
    text-decoration: none !important;
    color: var(--text-main);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255,255,255,0.6);
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    min-height: 80px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    backdrop-filter: blur(10px);
}

/* 悬停效果：上浮 + 大阴影 + 轻微渐变边框 */
.website-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: var(--shadow-hover);
    border-color: rgba(102, 126, 234, 0.3);
    background: #fff;
    z-index: 10;
}

/* 内部光晕效果 */
.website-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.website-card:hover::after {
    opacity: 1;
}

/* 图标：更大、更圆润 */
.website-icon {
    width: 48px; /* 加大图标 */
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    border-radius: 12px;
    flex-shrink: 0;
    background: #f3f4f6;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: transform 0.3s;
}

.website-card:hover .website-icon {
    transform: scale(1.05);
}

/* 网站信息 */
.website-info {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    line-height: 1.4;
}

.website-title {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.website-desc {
    font-size: 13px;
    color: var(--text-sub);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    font-weight: 400;
}

.website-desc:empty {
    display: none;
}

/* 操作按钮：悬浮显示，更精致 */
.admin-actions-bar {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    z-index: 20;
    opacity: 0; /* 默认隐藏 */
    transform: translateX(10px);
    transition: all 0.3s ease;
}

.website-card-wrapper:hover .admin-actions-bar {
    opacity: 1;
    transform: translateX(0);
}

.action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: #f3f4f6;
    color: #4b5563;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.action-btn:hover {
    transform: scale(1.1);
    background: #fff;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.btn-edit:hover { color: #d97706; background: #fffbeb; }
.btn-del:hover { color: #dc2626; background: #fef2f2; }

/* ---------------- 空状态 ---------------- */
.empty-state {
    text-align: center;
    padding: 100px 20px;
    color: var(--text-sub);
    background: rgba(255,255,255,0.5);
    border-radius: var(--radius-xl);
    border: 2px dashed #e5e7eb;
    max-width: 600px;
    margin: 0 auto;
}

.empty-state-icon {
    font-size: 80px;
    margin-bottom: 24px;
    opacity: 0.4;
    display: inline-block;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* ---------------- 模态框 (玻璃拟态) ---------------- */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 24px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95) translateY(20px);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255,255,255,0.5);
    
    /* 🔥 关键修复：让子元素的 absolute 定位参考这个 padding 盒 */
    position: relative; 
}

.modal.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    /* 不需要额外的 padding，因为父容器已经有了 */
}

.modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 20px;
    font-weight: 700;
}

/* 🔥 修复关闭按钮位置 */
.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    
    /* 方案 A: 如果按钮在 header 里，flex布局通常能自动推到右边 */
    /* 方案 B: 如果还是偏左，强制绝对定位到父容器的右上角 (减去 padding) */
    position: absolute;
    top: 20px; /* 40px (parent padding) - 20px (half button approx) = 20px? No. */
    /* 正确算法：top = parent_padding_top - (button_height/2) + offset */
    /* 简单点：直接定在 content 的右上角内部 */
    top: 15px; 
    right: 15px;
    z-index: 10;
}

/* 如果按钮是在 .modal-header 内部，上面的 absolute 可能会失效，
   因为 header 也是 flex。为了确保万无一失，我们让它绝对定位于 modal-content */

.modal-close:hover {
    color: #333;
    background: #f3f4f6;
    transform: rotate(90deg); /* 增加一个旋转特效 */
}

/* ---------------- 表单美化 ---------------- */
.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 10px;
    display: block;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 15px;
    background: #f9fafb;
    transition: all 0.3s;
    box-sizing: border-box;
    color: var(--text-main);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

/* ---------------- 消息提示 (Toast) ---------------- */
#global-toast, #messageBox {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    z-index: 9999;
    padding: 14px 32px;
    border-radius: 50px;
    background: #1f2937;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    min-width: 200px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    backdrop-filter: blur(5px);
}

#global-toast.show, #messageBox.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ---------------- 响应式 (手机端优化 - 防遮挡最终版) ---------------- */
@media (max-width: 768px) {
    /* ... (保持之前的 nav-header 等样式不变) ... */
    
    .nav-header {
        margin-bottom: 20px;
        padding-top: 15px;
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .nav-header h1 { font-size: 24px; width: 100%; }
    .nav-actions { width: 100%; justify-content: flex-end; }
    .add-category-btn { padding: 8px 16px !important; font-size: 13px !important; }

    .category-section {
        margin-bottom: 30px;
        padding: 0;
        background: transparent;
        border: none;
    }

    /* 🔥 核心修复：分类标题栏布局 */
    .category-header {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 8px; /* 减小间距 */
        margin-bottom: 16px;
        padding: 0 16px;
        height: 40px;
        box-sizing: border-box;
        /* 关键：防止子元素溢出父容器 */
        overflow: hidden; 
    }

    /* 🔥 核心修复：标题区域 (包含图标、文字、数量) */
    .category-title {
        font-size: clamp(15px, 4vw, 19px); /* 字体稍微调小一点，留出空间 */
        font-weight: 700;
        color: var(--text-main);
        display: flex;
        align-items: center;
        gap: 6px;
        margin: 0;
        
        /* 关键防遮挡逻辑 */
        flex: 1;           /* 占据剩余空间 */
        min-width: 0;      /* 允许被压缩到比内容更小 */
        white-space: nowrap; 
        overflow: hidden;
        text-overflow: ellipsis;
        
        /* 确保内部元素不撑破容器 */
        max-width: calc(100% - 110px); /* 🔥 强制预留右侧约 110px 给按钮组 (根据按钮数量调整) */
    }

    .category-title span:first-child {
        font-size: 18px;
        flex-shrink: 0; /* 图标绝不压缩 */
    }

    /* 🔥 核心修复：数量徽章 (最先被牺牲) */
    .category-count-badge {
        font-size: 10px;
        padding: 2px 6px;
        flex-shrink: 0; /* 默认不压缩 */
        /* 如果空间实在不够，可以允许徽章隐藏，或者让它也参与压缩 */
        /* 这里我们选择：当空间不足时，优先压缩标题文字，徽章尽量保留 */
        /* 如果还是遮挡，取消下面这行的注释，让徽章在极窄屏下消失 */
        /* display: none;  */ 
    }
    
    /* 🔥 核心修复：操作按钮组 (绝对优先权) */
    .category-actions {
        display: flex;
        gap: 6px;
        flex-shrink: 0; /* 🔥 关键：按钮组绝不被压缩 */
        opacity: 1 !important;
        z-index: 10;    /* 确保层级在上面 */
        position: relative;
    }

    /* 按钮微型化 */
    .category-actions .btn {
        padding: 5px 8px !important; /* 再缩小一点内边距 */
        font-size: 10px !important;  /* 字体再小一点 */
        line-height: 1;
        height: auto;
        border-radius: 6px;
        min-width: auto;
        display: flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
    }
    
    /* 针对极窄屏幕 (如 iPhone SE 第一代) 的额外优化 */
    @media (max-width: 360px) {
        .category-title {
            max-width: calc(100% - 95px); /* 预留更少空间，逼迫标题更短 */
            font-size: 14px;
        }
        .category-actions .btn {
            padding: 4px 6px !important;
            font-size: 9px !important;
        }
        .category-count-badge {
            display: none; /* 极窄屏下直接隐藏数量徽章，保命要紧 */
        }
    }

    /* ... (保持之前的 website-grid 和卡片样式不变) ... */
    .website-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        padding: 0 16px;
        justify-content: center;
    }
    .website-card-wrapper { height: auto; }
    .website-card {
        flex-direction: row; 
        padding: 10px 26px 10px 10px !important;
        min-height: 68px; 
        border-radius: 10px;
        gap: 8px;
        overflow: hidden;
        box-shadow: 0 2px 5px rgba(0,0,0,0.03);
    }
    .website-icon { width: 32px; height: 32px; min-width: 32px; min-height: 32px; border-radius: 6px; }
    .website-info { gap: 2px; max-width: calc(100% - 35px); }
    .website-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .website-desc { font-size: 10px; -webkit-line-clamp: 1; line-height: 1.2; color: #9ca3af; }
    
    /* 卡片右上角按钮 */
    .admin-actions-bar {
        top: 6px; right: 6px; transform: none !important; opacity: 0.5 !important;
        background: transparent !important; box-shadow: none !important; border: none !important;
        padding: 0 !important; gap: 4px;
    }
    .website-card-wrapper:active .admin-actions-bar { opacity: 1 !important; }
    .action-btn { width: 20px; height: 20px; font-size: 9px; background: rgba(255, 255, 255, 0.9); border-radius: 4px; padding: 0; display: flex; align-items: center; justify-content: center; }
}
    .website-card-wrapper:active .admin-actions-bar {
        opacity: 1 !important;
    }

    .action-btn {
        width: 20px;
        height: 20px;
        font-size: 9px;
        background: rgba(255, 255, 255, 0.9);
        border-radius: 4px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}