
:root {
    --bg: #f5f3ef;
    --bg-page: #f5f3ef;
    --bg-card: #ffffff;
    --bg-sidebar: #1a1814;
    --text: #1a1814;
    --text-muted: #8a8580;
    --text-subtle: #b5b0a8;
    --border: #e6e2da;
    --sidebar-text: rgba(255,255,255,.55);
    --sidebar-active-bg: rgba(124,58,237,.15);
    --sidebar-active-text: #a78bfa;
    --accent: #7c3aed;
    --accent-hover: #6d28d9;
    --accent-light: #f3e8ff;
    --accent-glow: rgba(124,58,237,.25);
    --danger: #e05555;
    --danger-light: #fde8e8;
    --success: #4dab6f;
    --success-light: #e6f4ea;
    --blue: #3a8fd9;
    --blue-light: #e8f2fb;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.05);
    --shadow-card: 0 2px 12px rgba(0,0,0,.06), 0 0 0 1px rgba(0,0,0,.02);
    --shadow-card-hover: 0 8px 30px rgba(124,58,237,.12), 0 0 0 1px rgba(124,58,237,.08);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 7px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.dark-mode {
    --bg: #121110;
    --bg-page: #121110;
    --bg-card: #1e1d1a;
    --bg-sidebar: #0e0d0b;
    --text: #ece8de;
    --text-muted: #8a8580;
    --text-subtle: #5a5550;
    --border: #2e2c27;
    --sidebar-text: rgba(255,255,255,.5);
    --sidebar-active-bg: rgba(124,58,237,.15);
    --sidebar-active-text: #a78bfa;
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --accent-light: #221733;
    --accent-glow: rgba(139,92,246,.2);
    --danger: #e06c6c;
    --danger-light: #2d1f1f;
    --success: #5ab87a;
    --success-light: #1a2d1f;
    --blue: #529cca;
    --blue-light: #1a2a33;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
    --shadow-card: 0 2px 12px rgba(0,0,0,.3), 0 0 0 1px rgba(255,255,255,.03);
    --shadow-card-hover: 0 8px 30px rgba(124,58,237,.12), 0 0 0 1px rgba(124,58,237,.06);
}

* { font-family: var(--font); }

body {
    background: var(--bg-page);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
    line-height: 1.6;
    transition: background .3s, color .3s;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-card);
    color: var(--text);
    transition: box-shadow .3s, transform .3s, border-color .3s;
}
.card:hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-2px);
    border-color: rgba(124,58,237,.12);
}

/* Stat gradient cards */
.stat-card {
    border: none !important;
    border-radius: var(--radius) !important;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.stat-card h6 { font-size: .78rem; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; opacity: .9; }
.stat-card h2 { font-weight: 800; font-size: 1.85rem; letter-spacing: -.5px; }
.stat-card-gold { background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 50%, #9d70f5 100%) !important; }
.stat-card-blue { background: linear-gradient(135deg, #2e7ab8 0%, #3a8fd9 50%, #52a5e8 100%) !important; }
.stat-card-rose { background: linear-gradient(135deg, #c94040 0%, #e05555 50%, #f06e6e 100%) !important; }
.stat-card::after {
    content: '';
    position: absolute;
    top: -35%;
    right: -15%;
    width: 140px;
    height: 140px;
    background: rgba(255,255,255,.1);
    border-radius: 50%;
}
.stat-card::before {
    content: '';
    position: absolute;
    bottom: -25%;
    left: -10%;
    width: 80px;
    height: 80px;
    background: rgba(255,255,255,.06);
    border-radius: 50%;
}

/* Hero card */
.hero-card {
    border: none !important;
    border-radius: var(--radius) !important;
    background: linear-gradient(135deg, #1a1814 0%, #2a2518 50%, #3a2e10 100%) !important;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.dark-mode .hero-card {
    background: linear-gradient(135deg, #0e0d0b 0%, #1a1814 50%, #2a2518 100%) !important;
}
.hero-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -5%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(124,58,237,.2) 0%, transparent 70%);
    border-radius: 50%;
    animation: heroGlow 6s ease-in-out infinite alternate;
}
.hero-card::after {
    content: '';
    position: absolute;
    bottom: -40%;
    left: 8%;
    width: 280px;
    height: 280px;
    background: radial-gradient(circle, rgba(139,92,246,.1) 0%, transparent 70%);
    border-radius: 50%;
    animation: heroGlow 8s ease-in-out infinite alternate-reverse;
}
@keyframes heroGlow {
    0%   { transform: translate(0, 0) scale(1); }
    100% { transform: translate(25px, -15px) scale(1.15); }
}
.hero-card .btn-hero-primary {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: #1a1814;
    border: none;
    font-weight: 700;
    border-radius: var(--radius-sm);
    padding: .65rem 1.8rem;
    box-shadow: 0 2px 12px rgba(124,58,237,.35);
    transition: transform .2s, box-shadow .2s;
}
.hero-card .btn-hero-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(124,58,237,.45);
    color: #1a1814;
}
.hero-card .btn-hero-outline {
    border: 2px solid rgba(255,255,255,.25);
    color: #fff;
    background: transparent;
    border-radius: var(--radius-sm);
    padding: .65rem 1.8rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
}
.hero-card .btn-hero-outline:hover {
    background: rgba(255,255,255,.1);
    border-color: rgba(255,255,255,.4);
    color: #fff;
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 240px;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 1030;
    transition: transform .3s;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 1.1rem 1rem .85rem;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -.3px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand-icon {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    color: #1a1814;
    font-weight: 800;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(124,58,237,.3);
}
.sidebar-nav {
    flex: 1;
    padding: .6rem .5rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: .5rem .75rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .88rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: background .15s, color .15s;
}
.sidebar-link:hover {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}
.sidebar-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 600;
}
.sidebar-link svg { flex-shrink: 0; opacity: .6; }
.sidebar-link.active svg, .sidebar-link:hover svg { opacity: 1; }
.sidebar-footer {
    padding: .5rem .5rem .75rem;
    border-top: 1px solid rgba(255,255,255,.06);
}
.theme-toggle {
    width: 100%;
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
}

/* Main content with sidebar */
.main-with-sidebar {
    margin-left: 240px;
    padding: 2rem 2.5rem;
    max-width: 100%;
}

/* ---- Navbar (logged-out) ---- */
.navbar-dark.bg-dark {
    background-color: var(--bg-sidebar) !important;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.navbar-brand { font-weight: 700; color: #fff !important; }
.navbar-dark .navbar-nav .nav-link { color: var(--sidebar-text); }
.navbar-dark .navbar-nav .nav-link:hover { color: #a78bfa; }

/* ---- Buttons ---- */
.btn-primary {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    border: none;
    color: #1a1814;
    border-radius: var(--radius-sm);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(124,58,237,.25);
    transition: transform .15s, box-shadow .15s;
}
.btn-primary:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(124,58,237,.35);
    color: #1a1814;
}
.btn-outline-primary {
    border-radius: var(--radius-sm);
    border-color: var(--accent);
    color: var(--accent);
}
.btn-outline-primary:hover {
    background: var(--accent-light);
}
.btn-outline-danger { border-radius: var(--radius-sm); }

/* ---- Tables ---- */
.table { color: var(--text); }
.dark-mode .table { --bs-table-bg: transparent; --bs-table-hover-bg: rgba(255,255,255,.03); color: var(--text); }
.dark-mode .table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-bg: rgba(255,255,255,.015); }

/* ---- Forms ---- */
.dark-mode .form-control, .dark-mode .form-select { background: var(--bg-card); border-color: var(--border); color: var(--text); }
.dark-mode .form-control:focus { background: var(--bg-card); color: var(--text); }

/* ---- Badges ---- */
.badge.bg-success { background: linear-gradient(135deg, #4dab6f 0%, #5ab87a 100%) !important; }
.badge.bg-warning { background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%) !important; color: #1a1814 !important; font-weight: 600; }
.dark-mode .badge { opacity: .9; }

/* ---- Model tags ---- */
.model-tag {
    background: var(--accent-light);
    padding: 2px 10px;
    border-radius: var(--radius-xs);
    font-size: .83em;
    margin-right: 4px;
    color: var(--accent);
    font-weight: 600;
}

/* ---- Text overrides ---- */
.dark-mode .text-muted { color: var(--text-muted) !important; }
.dark-mode .text-secondary { color: var(--text-muted) !important; }
.dark-mode .text-dark { color: var(--text) !important; }
.dark-mode .bg-light { background-color: var(--bg-card) !important; }

/* ---- Code ---- */
code { color: #b85c2a; font-size: .9em; }
.dark-mode code { color: #e8a060; }
.api-key-display { user-select: all; font-size: .83em; }

/* ---- Links ---- */
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* ---- Footer ---- */
footer { color: var(--text-subtle) !important; }

/* ---- Mobile sidebar ---- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.5);
    z-index: 1029;
}
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-open .sidebar-overlay { display: block; }
    .main-with-sidebar { margin-left: 0; padding: 1.5rem; }
}

/* Chat floating window */
.chat-window {
    position: fixed;
    bottom: auto;
    top: calc(33vh + 40px);
    right: 20px;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 480px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,.15);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    transform: translateX(0);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
}
/* 收起状态：整体滑出屏幕右侧（留出 8px 缝隙提示还能滑回来） */
.chat-window.chat-closed {
    transform: translateX(calc(100vw + 400px));
    transition: transform .3s cubic-bezier(.4,0,.2,1);
}
/* 滑入动画：每次从收起态展开时重放 */
.chat-window.chat-sliding.chat-open {
    animation: chat-slide-in .3s cubic-bezier(.4,0,.2,1);
}
@keyframes chat-slide-in {
    from { transform: translateX(calc(100vw + 400px)); }
    to   { transform: translateX(0); }
}
/* 悬浮客服按钮：贴右边缘、视口垂直 1/3 处（窗口展开态的上沿位置），滚动不动 */
.chat-fab {
    position: fixed;
    top: calc(33vh + 40px);
    right: 0;
    z-index: 9998;
    width: 52px;
    height: 52px;
    border-radius: 26px 0 0 26px;
    background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: -2px 4px 12px rgba(0,0,0,.18);
    cursor: pointer;
    border: none;
    transition: width .25s ease, background .2s ease;
}
.chat-fab:hover { width: 64px; }
.chat-fab .chat-fab-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e74c3c;
    border: 2px solid #fff;
    animation: chat-fab-pulse 1.2s ease-in-out infinite;
}
@keyframes chat-fab-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.35); opacity: .7; }
}
/* 新消息到达时的弹跳提示 */
.chat-fab.chat-fab-ping { animation: chat-fab-ping .5s ease; }
@keyframes chat-fab-ping {
    0%, 100% { transform: translateX(0); }
    40% { transform: translateX(6px) scale(1.06); }
}
.dark-mode .chat-window {
    background: #1e1d1a;
    border-color: #2e2c27;
}
.chat-header {
    background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%);
    color: #fff;
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
}
.chat-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.model-tag {
    background: #f5f3ef;
    border: 1px solid #e6e2da;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.9rem;
    color: #1a1814;
    white-space: nowrap;
    line-height: 1.4;
}
.dark-mode .model-tag {
    background: #2a2520;
    border-color: #3a3530;
    color: #ece8de;
}

/* 联系客服 QQ群二维码悬浮 */
.chat-link {
    position: relative;
}
.chat-qrcode-popup {
    position: fixed;
    left: 245px;
    top: 50%;
    transform: translateY(-50%) scale(0.8);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    padding: 12px;
    z-index: 10000;
    text-align: center;
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
}
.chat-qrcode-popup img {
    width: 176px;
    height: 176px;
    display: block;
    border-radius: 8px;
}
.chat-qrcode-tip {
    margin-top: 8px;
    font-size: 13px;
    color: #666;
    font-weight: 500;
}
.chat-link:hover .chat-qrcode-popup {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) scale(1);
    pointer-events: auto;
}

/* QQ群二维码呼吸灯效果 */
.sidebar-qr-breathing {
    margin: 0 .5rem .5rem;
    padding: 10px;
    background: rgba(255,255,255,.05);
    border-radius: 8px;
    text-align: center;
    animation: qrBreathing 2.5s ease-in-out infinite;
}
.sidebar-qr-breathing img {
    width: 120px;
    height: 120px;
    border-radius: 6px;
    display: block;
    margin: 0 auto 6px;
}
.sidebar-qr-text {
    font-size: 11px;
    color: rgba(255,255,255,.6);
    font-weight: 500;
}
.sidebar-qr-link {
    display: block;
    margin-top: 8px;
    font-size: 11px;
    color: rgba(255,255,255,.7);
    text-decoration: none;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 4px;
    padding: 4px 8px;
    background: rgba(255,255,255,.05);
    transition: all 0.2s;
}
.sidebar-qr-link:hover {
    background: rgba(255,255,255,.1);
    color: rgba(255,255,255,.9);
    text-decoration: none;
}
@keyframes qrBreathing {
    0%, 100% { opacity: 0.3; transform: scale(0.97); }
    50% { opacity: 1; transform: scale(1); }
}
.dark-mode .sidebar-qr-breathing {
    background: rgba(0,0,0,.2);
}

/* 侧边栏新消息提示 */
.sidebar-new-msg {
    margin: 0 .5rem;
    padding: 8px 10px;
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all .2s ease;
}
.sidebar-new-msg:hover {
    background: rgba(255,255,255,.1);
    border-color: rgba(255,255,255,.2);
    transform: translateY(-1px);
}
.sidebar-new-msg-icon {
    font-size: 16px;
    flex-shrink: 0;
}
.sidebar-new-msg-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.sidebar-new-msg-label {
    font-size: 10px;
    color: rgba(255,255,255,.6);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 2px;
}
.sidebar-new-msg-text {
    font-size: 12px;
    color: rgba(255,255,255,.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-new-msg-arrow {
    font-size: 18px;
    color: rgba(255,255,255,.4);
    flex-shrink: 0;
    transition: transform .2s ease;
}
.sidebar-new-msg:hover .sidebar-new-msg-arrow {
    transform: translateX(3px);
    color: rgba(255,255,255,.8);
}
.sidebar-new-msg-text.scrolling {
    animation: scrollText 8s linear infinite;
}
@keyframes scrollText {
    0% { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

/* 跑马灯滚动动画 */
@keyframes marquee-scroll {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

.sidebar-new-msg-text.scrolling {
    display: inline-block;
    animation: marquee-scroll 6s linear infinite;
    white-space: nowrap;
    min-width: 100%;
}
