/**
 * ==========================================
 * style.css - 核心样式文件（升级版 v4）
 * 支持两种展示风格切换
 * Style 0: 经典图标网格（原版）
 * Style 2: 缤纷模式（列表详情 + 用户自定义背景色）
 * ==========================================
 */

/* ==================== CSS 变量定义 ==================== */
:root {
    /* 毛玻璃效果颜色 */
    --glass: rgba(255, 255, 255, 0.15);
    --glass-hover: rgba(255, 255, 255, 0.3);
    --glass-border: rgba(255, 255, 255, 0.1);

    /* 文字颜色 */
    --text: #ffffff;
    --text-dim: rgba(255, 255, 255, 0.85);

    /* 主题色 */
    --primary: #399dff;

    /* 圆角与尺寸 */
    --radius: 15px;
    --card-w: 85px;
}

/* ==================== 全局重置 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* ==================== 页面主体样式 ==================== */
body {
    background-color: #111;
    background-repeat: no-repeat;
    background-position: center center;
    background-attachment: fixed;
    background-size: cover;
    min-height: 100vh;
    color: var(--text);
    overflow-x: hidden;
    transition: background-image 0.8s ease-in-out;
}

/* 高级磨砂玻璃模糊滤镜 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: -1;
}

/* ==================== 主容器 ==================== */
.container {
    max-width: 55rem;
    margin: 0 auto;
    padding: 150px 15px 100px;
    text-align: center;
    position: relative;
}

/* ==================== 分类标签栏 ==================== */
.tab-container {
    position: fixed;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 20px;
    scrollbar-width: none;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-radius: 35px;
    z-index: 100;
    max-width: calc(100vw - 200px);
}

.tab-container::-webkit-scrollbar {
    display: none;
}

.tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
}

/* ==================== 分类按钮样式 ==================== */
.tab-btn {
    white-space: nowrap;
    padding: 8px 22px;
    border-radius: 25px;
    border: 1px solid var(--glass-border);
    background: var(--glass);
    color: var(--text);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    font-weight: bold;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.05);
}

.tab-btn.hidden-item {
    opacity: 0.4;
    text-decoration: line-through;
}

/* ==================== 分类管理按钮 ==================== */
.manage-cat-btn {
    background: transparent;
    border: 1px dashed var(--glass-border);
    color: var(--text-dim);
    padding: 8px 16px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 15px;
    white-space: nowrap;
}

/* ==================== 导航网格布局（Style 0 默认） ==================== */
.nav-grid {
    display: none;
    gap: 15px;
    margin: 0 auto;
    width: 100%;
    grid-template-columns: repeat(auto-fill, minmax(var(--card-w, 85px), 1fr));
    animation: fadeInUp 0.6s ease-out;
}

.nav-grid.active {
    display: grid;
}

/* 淡入上浮动画 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== 卡片样式（Style 0 默认） ==================== */
.card {
    background: var(--glass);
    border: none;
    border-radius: var(--radius);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    cursor: pointer;
    min-height: 85px; /* 确保这里是固定的 85px */
    height: 85px; /* 确保这里是固定的 85px */
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card:hover {
    background: var(--glass-hover);
    transform: translateY(-2px);
    /* 使用主题色 var(--primary) 产生光晕效果 */
    box-shadow: 0 0 15px rgba(57, 157, 255, 0.5), 0 0 30px rgba(57, 157, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3); /* 强化边缘发光感 */
}

.card.sortable-ghost {
    opacity: 0.4;
    background: var(--primary);
}

.card.hidden-item {
    opacity: 0.3;
    filter: grayscale(1);
}

.card a {
    text-decoration: none;
    color: inherit;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
}

/* ==================== 卡片提示框 ==================== */
.card[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: rgba(25, 25, 25, 0.95);
    backdrop-filter: blur(8px);
    color: #eee;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    white-space: pre-wrap;
    z-index: 1000;
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    pointer-events: none;
    width: max-content;
    max-width: 200px;
    text-align: center;
    line-height: 1.5;
}

.card[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    border: 6px solid transparent;
    border-top-color: rgba(25, 25, 25, 0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    z-index: 1000;
    pointer-events: none;
}

.card[data-tooltip]:hover::after,
.card[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ==================== 卡片图标与标题（Style 0） ==================== */
.icon-wrapper {
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 4px auto;
}

.card img {
    width: 25px;
    height: 25px;
    border-radius: 6px;
    object-fit: contain;
}

.card .emoji-icon {
    font-size: 24px;
}

.card h3 {
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
    color: #fff;
    line-height: 1;
    min-height: 1.5em;
}

/* ==================== 管理操作按钮 ==================== */
.admin-actions {
    position: absolute;
    top: 5px;
    right: 5px;
    display: flex;
    gap: 3px;
    z-index: 20;
    opacity: 1;
}

.action-mini {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 22px;
    height: 22px;
    border-radius: 5px;
    color: #fff;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==================== 右上角固定面板（样式切换 + 管理员工具） ==================== */
.fab {
    position: fixed;
    top: 6rem;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 200;
    align-items: center;
}

.style-switcher-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    padding: 12px 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.style-switcher-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.style-btn {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.65);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: all 0.25s ease;
    font-size: 11px;
    font-weight: 600;
}

.style-btn i {
    font-size: 16px;
    line-height: 1;
}

.style-btn span {
    font-size: 9px;
    line-height: 1;
}

.style-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.style-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 16px rgba(57, 157, 255, 0.5);
}

/* 管理员 FAB 按钮 */
.fab-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text);
    backdrop-filter: blur(10px);
    transition: 0.3s;
    font-size: 11px;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.fab-btn:hover {
    background: var(--primary);
    transform: scale(1.1);
}

/* ==================== 模态框 ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: rgba(30, 30, 30, 0.95);
    width: 90%;
    max-width: 450px;
    padding: 25px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    backdrop-filter: blur(15px);
}

/* ==================== 表单元素 ==================== */
.form-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}

.form-row label {
    width: 85px;
    text-align: left;
    font-size: 13px;
    color: #ccc;
    flex-shrink: 0;
    font-weight: bold;
}

input,
select {
    flex: 1;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    outline: none;
    font-size: 14px;
    width: 100%;
}

input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* ==================== 图标预览容器 ==================== */
.preview-container {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 20px;
    border-radius: 8px;
    margin-left: 8px;
}

.preview-container img {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* ==================== Toast 提示 ==================== */
#toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(50px);
    background: #27ae60;
    color: white;
    padding: 12px 30px;
    border-radius: 30px;
    border: 1px solid var(--glass-border);
    z-index: 3000;
    text-align: center;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    pointer-events: none;
}

#toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ==================== 加载动画 ==================== */
.global-spinner {
    width: 45px;
    height: 45px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#global-loading-overlay {
    display: none;
    flex-direction: column;
}

/* ==================== 骨架屏 ==================== */
#skeleton-screen {
    display: none;
    width: 100%;
    margin-top: 40px;
}

.skel-tabs {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 35px;
    flex-wrap: wrap;
}

.skel-tab {
    width: 80px;
    height: 35px;
    border-radius: 40px;
    background: rgba(255, 255, 255, 0.05);
}

.skel-grid {
    display: grid;
    gap: 15px;
    margin: 0 auto;
    width: 100%;
    max-width: 55rem;
    grid-template-columns: repeat(auto-fill, minmax(var(--card-w, 85px), 1fr));
}

.skel-card {
    height: 85px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
}

.skel-anim::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    100% { left: 150%; }
}

/* ==================== 页脚信息 ==================== */
.footer-info {
    position: fixed;
    bottom: 10px;
    left: 0;
    right: 0;
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
    pointer-events: none;
}

/* ==================== 拖拽排序相关 ==================== */
.cat-item-row.sortable-ghost {
    background: var(--primary) !important;
    opacity: 0.5;
}

.drag-handle {
    cursor: grab;
    color: #666;
    margin-right: 5px;
    font-size: 18px;
}

/* ==================== 布局容器 ==================== */
#layout-wrapper {
    display: block;
    width: 100%;
}


/* ==================================================================================
   缤纷模式 — 列表详情模式 + 自定义网格背景色
   高宽比与默认样式完全一致（正方形），背景色由用户自定义
   ================================================================================== */

body.view-style-2 .nav-grid.active {
    grid-template-columns: repeat(auto-fill, minmax(var(--card-w, 85px), 1fr));
    gap: 15px;
}

body.view-style-2 .card {
    border-radius: var(--radius);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: none;
    justify-content: flex-start;
    transition: all 0.25s ease;
}

/* 有自定义背景色的卡片 */
body.view-style-2 .card.has-bg {
    background: var(--card-bg-color, rgba(255,255,255,0.15));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* 悬浮时光泽效果 */
body.view-style-2 .card.has-bg:hover {
    transform: translateY(-2px);
    /* 这里的光晕会叠加在卡片原有阴影上，使其更有厚度 */
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.3), 
        0 0 15px var(--card-bg-color, rgba(255,255,255,0.2)), /* 随卡片颜色的光晕 */
        0 0 30px rgba(255, 255, 255, 0.1);
}

body.view-style-2 .card:not(.has-bg):hover {
    background: rgba(110, 115, 135, 0.32);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-color: rgba(255, 255, 255, 0.4);
    /* 白色/浅灰色柔和光晕 */
    box-shadow: 
        0 8px 20px rgba(0, 0, 0, 0.3),
        0 0 15px rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

body.view-style-2 .card a {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    gap: 10px;
}

/* 缤纷模式: 图标区域 — 无背景，透明底 */
body.view-style-2 .icon-wrapper {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 8px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    overflow: hidden;
    flex-shrink: 0;
}

body.view-style-2 .card img {
    width: 24px;
    height: 24px;
    border-radius: 5px;
    object-fit: contain;
}

body.view-style-2 .card .emoji-icon {
    font-size: 20px;
}

/* 缤纷模式: 文字区域 */
body.view-style-2 .card-text-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

body.view-style-2 .card h3 {
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    -webkit-line-clamp: unset;
    display: block;
    color: #fff;
    line-height: 1.3;
    min-height: unset;
}

/* 缤纷模式 tooltip */
body.view-style-2 .card[data-tooltip]::after {
    left: 50%;
    transform: translateX(-50%) translateY(10px);
}

body.view-style-2 .card[data-tooltip]:hover::after {
    transform: translateX(-50%) translateY(0);
}

body.view-style-2 .card[data-tooltip]::before {
    display: none;
}


/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    .tab-container {
        top: 1rem;
        padding: 8px 14px;
        gap: 6px;
        max-width: calc(100vw - 100px);
    }

    .tab-btn {
        padding: 6px 14px;
        font-size: 14px;
    }

    .container {
        padding-top: 100px;
    }

    body.view-style-2 .nav-grid.active {
        gap: 12px;
    }

}

@media (max-width: 480px) {
    body.view-style-2 .nav-grid.active {
        grid-template-columns: repeat(auto-fill, minmax(var(--card-w, 85px), 1fr));
    }
}
