/**
 * Moka 统一样式文件
 * V13 自适应布局版本
 */

/* ==================== 全局样式 ==================== */
* {
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

/* Auth Modal V13 样式 */
#authModal {
    display: none;
}
#authModal:not(.hidden) {
    display: flex;
}
#authModal .auth-panel {
    display: block;
}
#authModal .auth-panel.hidden {
    display: none;
}

:root {
    --brand-color: #3b82f6;
    --brand-dark: #2563eb;
    --bg-light: #f8fafc;
    --bg-dark: #070b14;
    --sidebar-width: clamp(180px, 15vw, 260px);
    
    /* 兼容变量 */
    --primary-color: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-active: #2563eb;
    --success-color: #52c41a;
    --warning-color: #faad14;
    --danger-color: #f5222d;
    --info-color: #13c2c2;
    --text-primary: #262626;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-hover: #f1f5f9;
    --border-color: #e5e7eb;
    
    /* 圆角 */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* 阴影 */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    
    /* 过渡 */
    --transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
    --transition-fast: all 0.2s ease;
}

/* 暗色模式变量 */
.dark, .dark-theme {
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    --bg-primary: #1e293b;
    --bg-secondary: #0f172a;
    --bg-hover: #334155;
    --border-color: #334155;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg-light);
    font-family: 'Plus Jakarta Sans', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    transition: background 0.3s ease;
    -webkit-font-smoothing: antialiased;
}

html.dark body,
body.dark-theme {
    background: var(--bg-dark);
}

/* ==================== 应用容器 ==================== */
.app-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    height: 100vh;
    max-width: 1920px;
    margin: 0 auto;
    overflow: hidden;
}

@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
    }
    /* 移动端侧边栏滑出式（用复合选择器提高优先级，覆盖 .sidebar 的 sticky） */
    .sidebar.sidebar-desktop {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: clamp(200px, 70vw, 320px);
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        border-right: 1px solid rgba(0,0,0,0.08);
        box-shadow: none;
        height: 100vh;
        overflow-y: auto;
        padding: clamp(0.75rem, 4vw, 1.5rem);
    }
    .sidebar.sidebar-desktop.show {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.12);
    }
    .mobile-nav {
        display: flex !important;
    }
}

/* 前台移动端侧边栏遮罩 */
.sidebar-mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 199;
    opacity: 0;
    transition: opacity 0.3s;
}
.sidebar-mobile-overlay.show {
    display: block;
    opacity: 1;
}

/* 前台侧边栏移动端关闭按钮 */
.sidebar-mobile-close {
    display: none;
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(0,0,0,0.05);
    color: #64748b;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}
.sidebar-mobile-close:hover {
    background: rgba(0,0,0,0.1);
    color: #ef4444;
}
html.dark .sidebar-mobile-close {
    background: rgba(255,255,255,0.1);
    color: #94a3b8;
}
html.dark .sidebar-mobile-close:hover {
    background: rgba(255,255,255,0.15);
    color: #ef4444;
}
@media (max-width: 1024px) {
    .sidebar-mobile-close {
        display: flex;
    }
}

@media (min-width: 1025px) {
    .mobile-nav {
        display: none !important;
    }
}

/* ==================== 侧边栏 ==================== */
.sidebar {
    height: 100vh;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    padding: clamp(0.75rem, 2vw, 1.5rem);
}

html.dark .sidebar,
.dark-theme .sidebar {
    background: rgba(15, 23, 42, 0.9);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

/* 导航区域独立滚动 */
.sidebar nav,
.sidebar-nav,
#sidebar-nav,
#category-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.sidebar nav::-webkit-scrollbar,
.sidebar-nav::-webkit-scrollbar,
#sidebar-nav::-webkit-scrollbar,
#category-nav::-webkit-scrollbar {
    display: none;
}

/* 用户卡片固定底部 */
.sidebar > div:last-child {
    flex-shrink: 0;
    margin-top: auto;
}

/* ==================== 主内容区 ==================== */
.main-content {
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.main-content::-webkit-scrollbar {
    width: 6px;
}

.main-content::-webkit-scrollbar-track {
    background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.3);
    border-radius: 10px;
}

.main-content::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.5);
}

/* 全局滚动条美化 */
*::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
    border-radius: 4px;
}

*::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.6);
}

/* 暗黑模式滚动条 */
.dark *::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.4);
}

.dark *::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.6);
}

/* Firefox 滚动条 */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
}

.dark * {
    scrollbar-color: rgba(100, 116, 139, 0.4) transparent;
}

/* ==================== 顶部导航栏 ==================== */
.top-nav {
    height: clamp(56px, 10vw, 72px);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(24px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(0.75rem, 4vw, 1.5rem);
}

@media (min-width: 1024px) {
    .top-nav {
        padding: 0 2.5rem;
    }
}

html.dark .top-nav,
.dark-theme .top-nav {
    background: rgba(7, 11, 20, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* ==================== 玻璃态卡片 ==================== */
.glass-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.04);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html.dark .glass-card,
.dark-theme .glass-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.glass-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 48px rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.3);
}

html.dark .glass-card:hover,
.dark-theme .glass-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(59, 130, 246, 0.4);
}

/* 卡片悬停提示框 */
.glass-card[data-tooltip] {
    overflow: visible;
}
.glass-card[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    padding: 8px 14px;
    background: rgba(15, 23, 42, 0.92);
    color: #fff;
    font-size: 12px;
    line-height: 1.5;
    border-radius: 10px;
    white-space: normal;
    max-width: 260px;
    width: max-content;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 50;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
}
.glass-card[data-tooltip]::after {
    content: '';
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(15, 23, 42, 0.92);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 50;
}
.glass-card[data-tooltip]:hover::before {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}
.glass-card[data-tooltip]:hover::after {
    opacity: 1;
}

/* 移动端不显示 tooltip */
@media (max-width: 768px) {
    .glass-card[data-tooltip]::before,
    .glass-card[data-tooltip]::after {
        display: none;
    }
}

/* ========== H5端卡片自适应 ========== */
@media (max-width: 640px) {
    /* 卡片圆角缩小 */
    .glass-card {
        border-radius: 14px;
    }

    /* 移动端取消hover上浮，避免点击跳动 */
    .glass-card:hover {
        transform: none;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.04);
    }

    /* 可点击卡片：减少内边距和间距 */
    a.glass-card {
        padding: 0.5rem 0.625rem !important;
        gap: 0.5rem !important;
    }

    /* Logo容器缩小: 56px → 40px */
    .glass-card > .flex-shrink-0 {
        width: 2.5rem !important;
        height: 2.5rem !important;
        min-width: 2.5rem;
        border-radius: 0.75rem !important;
    }

    /* Logo图片缩小 */
    .glass-card > .flex-shrink-0 > img {
        width: 1.375rem !important;
        height: 1.375rem !important;
    }

    /* Logo内图标缩小 */
    .glass-card > .flex-shrink-0 > [data-lucide] {
        width: 1.25rem !important;
        height: 1.25rem !important;
    }

    /* 卡片文字始终显示为深色/黑色，不需hover */
    .glass-card h3,
    .glass-card h4 {
        color: #1e293b !important;
        font-size: 12px;
    }
    .glass-card p {
        color: #475569 !important;
    }

    /* 暗黑模式下卡片文字保持可见 */
    html.dark .glass-card h3,
    html.dark .glass-card h4,
    .dark-theme .glass-card h3,
    .dark-theme .glass-card h4 {
        color: #f1f5f9 !important;
    }
    html.dark .glass-card p,
    .dark-theme .glass-card p {
        color: #94a3b8 !important;
    }

    /* 右上角箭头在移动端始终隐藏 */
    .glass-card .absolute.top-3.right-3 {
        display: none;
    }
}

/* 超小屏（<375px）进一步缩小 */
@media (max-width: 374px) {
    a.glass-card {
        padding: 0.375rem 0.5rem !important;
        gap: 0.375rem !important;
    }
    .glass-card > .flex-shrink-0 {
        width: 2.25rem !important;
        height: 2.25rem !important;
        min-width: 2.25rem;
    }
    .glass-card > .flex-shrink-0 > img {
        width: 1.25rem !important;
        height: 1.25rem !important;
    }
    .glass-card h3,
    .glass-card h4 {
        font-size: 11px;
    }
    .glass-card p {
        font-size: 9px;
    }
}

/* 不需要 hover 效果的卡片 */
.glass-card-static {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.04);
}

html.dark .glass-card-static,
.dark-theme .glass-card-static {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* ==================== 导航链接 ==================== */
.nav-link {
    color: #64748b;
    transition: all 0.2s ease;
    position: relative;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0 0.75rem 0.75rem 0;
    font-size: 0.875rem;
}

/* 移动端导航链接自适应 */
@media (max-width: 1024px) {
    .nav-link {
        gap: clamp(0.375rem, 2vw, 0.75rem);
        padding: clamp(0.5rem, 2vw, 0.75rem) clamp(0.5rem, 3vw, 1rem);
        font-size: clamp(0.75rem, 3.5vw, 0.875rem);
    }
}

html.dark .nav-link,
.dark-theme .nav-link {
    color: #94a3b8;
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.15) 0%, transparent 100%);
    border-left: 4px solid var(--brand-color);
    color: var(--brand-color);
    font-weight: 700;
}

html.dark .nav-link.active,
.dark-theme .nav-link.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.25) 0%, transparent 100%);
}

.nav-link:hover {
    color: var(--brand-color);
    background: rgba(59, 130, 246, 0.05);
}

/* ==================== 动画 ==================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ==================== 模态框 ==================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: clamp(8px, 3vw, 24px);
}

.modal-backdrop.active {
    display: flex;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: clamp(16px, 4vw, 24px);
    padding: clamp(1rem, 4vw, 2rem);
    max-width: min(480px, calc(100vw - 2rem));
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

html.dark .modal-content,
.dark-theme .modal-content {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ==================== Toast 提示 ==================== */
.toast-container {
    position: fixed;
    top: clamp(12px, 3vw, 20px);
    right: clamp(12px, 3vw, 20px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(400px, calc(100vw - 24px));
}

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: clamp(8px, 2vw, 12px) clamp(12px, 3vw, 20px);
    border-radius: clamp(8px, 2vw, 12px);
    font-size: clamp(12px, 3vw, 14px);
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: toastIn 0.3s ease;
}

.toast-icon {
    font-size: 16px;
}

.toast-content {
    flex: 1;
}

.toast-close {
    display: none; /* 隐藏关闭按钮 */
}

.toast-success {
    background: #10b981;
    color: white;
}

.toast-error {
    background: #ef4444;
    color: white;
}

.toast-warning {
    background: #f59e0b;
    color: white;
}

.toast-info {
    background: var(--brand-color);
    color: white;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast-out {
    animation: toastOut 0.3s ease forwards;
}

/* ==================== 移动端底部导航 ==================== */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: clamp(56px, 10vw, 72px);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 clamp(0.5rem, 2vw, 1rem);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

html.dark .mobile-bottom-nav,
.dark-theme .mobile-bottom-nav {
    background: rgba(15, 23, 42, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

@media (min-width: 1025px) {
    .mobile-bottom-nav {
        display: none;
    }
}

/* 移动端调整浮动按钮位置 */
@media (max-width: 1024px) {
    .float-buttons-wrapper {
        --float-offset-y: 100px !important;
    }
}

/* ==================== 页脚 ==================== */
.site-footer {
    padding: 2rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    text-align: center;
    font-size: 0.75rem;
    color: #64748b;
    margin-top: auto;
}

/* 手机端页脚底部留出空间避免被底部导航遮挡 */
@media (max-width: 1024px) {
    .site-footer {
        padding-bottom: calc(clamp(56px, 10vw, 72px) + env(safe-area-inset-bottom, 0px) + 12px);
    }
}

html.dark .site-footer,
.dark-theme .site-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    color: #94a3b8;
}

.site-footer a {
    color: inherit;
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--brand-color);
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 0.8rem;
}

.footer-divider {
    color: #cbd5e1;
    font-size: 0.7rem;
}

html.dark .footer-divider,
.dark-theme .footer-divider {
    color: #475569;
}

/* ==================== 响应式网格 ==================== */
.grid-cols-responsive {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(1, 1fr);
}

@media (min-width: 640px) {
    .grid-cols-responsive {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .grid-cols-responsive {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.25rem;
    }
}

@media (min-width: 1280px) {
    .grid-cols-responsive {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 1536px) {
    .grid-cols-responsive {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (min-width: 1800px) {
    .grid-cols-responsive {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* ==================== 骨架屏 ==================== */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

html.dark .skeleton,
.dark-theme .skeleton {
    background: linear-gradient(90deg, #1a1a1a 25%, #2a2a2a 50%, #1a1a1a 75%);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==================== 表单元素 ==================== */
.form-input {
    width: 100%;
    height: clamp(40px, 8vw, 48px);
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: clamp(8px, 2vw, 12px);
    padding: 0 1rem;
    font-size: 0.875rem;
    color: #1e293b;
    outline: none;
    transition: all 0.2s ease;
}

html.dark .form-input,
.dark-theme .form-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
}

.form-input:focus {
    border-color: var(--brand-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.btn-primary {
    height: clamp(40px, 8vw, 48px);
    background: var(--brand-color);
    color: white;
    border: none;
    border-radius: clamp(8px, 2vw, 12px);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    background: var(--brand-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

/* ==================== 工具类 ==================== */
.text-brand { color: var(--brand-color); }
.bg-brand { background-color: var(--brand-color); }
.border-brand { border-color: var(--brand-color); }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
