/**
 * ==========================================
 * style.css - 核心样式文件
 * 基于 Glassmorphism（毛玻璃）设计风格
 * ==========================================
 */

/* ==================== 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: 8px;
    margin-bottom: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 15px;
    scrollbar-width: none;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-radius: 25px;
    z-index: 100;
    max-width: calc(100vw - 30px);
}

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

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

/* ==================== 分类按钮样式 ==================== */
/* 分类按钮 - 毛玻璃风格 */
.tab-btn {
    white-space: nowrap;                         /* 保证文字不换行 */
    padding: 5px 15px;                           /* 内边距 */
    border-radius: 20px;                         /* 药丸状圆角 */
    border: 1px solid var(--glass-border);       /* 半透明边框 */
    background: var(--glass);                    /* 毛玻璃背景 */
    color: var(--text);                          /* 纯白文字 */
    cursor: pointer;
    transition: all 0.3s ease;                   /* 平滑过渡动画 */
    font-size: 12px;
    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: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
}

/* ==================== 导航网格布局 ==================== */
.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);
    }
}

/* ==================== 卡片样式 ==================== */
.card {
    background: var(--glass);
    border: none;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    position: relative;
    cursor: pointer;
    min-height: 85px;
    height: 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);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

/* 拖拽时的幽灵样式 */
.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);
}

/* ==================== 卡片图标与标题 ==================== */
.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;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100;
}

.fab-btn {
    width: 50px;
    height: 50px;
    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: 12px;
    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%;
}

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

    .tab-btn {
        padding: 5px 10px;
        font-size: 12px;
    }

    .container {
        padding-top: 90px;
    }
}
