/* <img src="/static/icons/circle-check.svg" class="icon-sm" alt="" loading="lazy"> 1.上传进度 2.记住我 3.引用回复 4.确认弹窗 5.通知红点 6.Toast统一 7.页面动画 8.快捷操作 9.空对话引导 10.消息菜单增强 11.骨架屏 */
/* KnowledgeGPT - Custom Styles */

/* icon-sm: already defined in base.html, just add extras */
.icon-sm-2x { display: inline-block; width: 20px; height: 20px; vertical-align: -4px; margin: 0 3px; }

/* sidebar protection */
#sidebar { display: flex !important; flex-shrink: 0 !important; }
#sidebar:not(.w-16) { width: 16rem !important; min-width: 16rem !important; }
#sidebar.w-16 { width: 4rem !important; min-width: 4rem !important; }

/* <img src="/static/icons/circle-check.svg" class="icon-sm" alt="" loading="lazy"> 主题色系统 */
:root {
    --theme-primary: #6366f1;
    --theme-primary-hover: #4f46e5;
    --theme-primary-light: #eef2ff;
}
[data-theme-color="blue"] {
    --theme-primary: #3b82f6;
    --theme-primary-hover: #2563eb;
    --theme-primary-light: #eff6ff;
}
[data-theme-color="green"] {
    --theme-primary: #10b981;
    --theme-primary-hover: #059669;
    --theme-primary-light: #ecfdf5;
}
[data-theme-color="rose"] {
    --theme-primary: #f43f5e;
    --theme-primary-hover: #e11d48;
    --theme-primary-light: #fff1f2;
}
[data-theme-color="amber"] {
    --theme-primary: #f59e0b;
    --theme-primary-hover: #d97706;
    --theme-primary-light: #fffbeb;
}
[data-theme-color="teal"] {
    --theme-primary: #14b8a6;
    --theme-primary-hover: #0d9488;
    --theme-primary-light: #f0fdfa;
}

/* Loading spinner */
.spinner {
    border: 3px solid #e5e7eb;
    border-top: 3px solid #6366f1;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Typing indicator */
.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #6366f1;
    border-radius: 50%;
    margin: 0 2px;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* File drop zone */
.drop-zone {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    transition: all 0.3s ease;
}

.drop-zone.drag-over {
    border-color: #6366f1;
    background: #eef2ff;
}

/* Chat messages */
.chat-bubble-user {
    background: #6366f1;
    color: white;
    border-radius: 18px 18px 4px 18px;
    max-width: 75%;
    padding: 12px 18px;
}

.chat-bubble-assistant {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 18px 18px 18px 4px;
    max-width: 85%;
    padding: 12px 18px;
}

/* Source tags */
.source-tag {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 9999px;
}

/* Sidebar */
.sidebar-item {
    transition: all 0.2s ease;
}

.sidebar-item:hover {
    background: #eef2ff;
}

.sidebar-item.active {
    background: #eef2ff;
    color: #6366f1;
    font-weight: 600;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Progress bar */
.progress-bar {
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: #6366f1;
    transition: width 0.3s ease;
}

/* Status badges */
.badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-weight: 600;
}

.badge-green { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f3f4f6; color: #4b5563; }

/* Toast notifications (legacy, using app.js showToast instead) */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    min-width: 280px;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
    cursor: pointer;
}

.toast-success { background: #16a34a; color: white; }
.toast-error { background: #dc2626; color: white; }
.toast-info { background: #2563eb; color: white; }
.toast-warning { background: #ca8a04; color: white; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* <img src="/static/icons/circle-check.svg" class="icon-sm" alt="" loading="lazy"> Item 7: 页面淡入动画 */
#app {
    animation: pageFadeIn 0.3s ease-in;
}

@keyframes pageFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Card hover */
.card-hover {
    transition: all 0.2s ease;
}

.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

/* Fade in */
.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════
   骨架屏 (Skeleton Loading)
   ═══════════════════════════════════════════ */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}
.skeleton-text { height: 16px; margin-bottom: 8px; }
.skeleton-text-sm { height: 12px; margin-bottom: 6px; }
.skeleton-title { height: 24px; width: 60%; margin-bottom: 12px; }
.skeleton-card { height: 120px; border-radius: 12px; }
.skeleton-circle { width: 40px; height: 40px; border-radius: 50%; }
@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ═══════════════════════════════════════════
   暗黑模式 (Dark Mode)
   ═══════════════════════════════════════════ */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --accent: #6366f1;
}

[data-theme="dark"] body,
[data-theme="dark"] .bg-gray-50 {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-white rounded-xl,
[data-theme="dark"] .bg-white rounded-lg {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .border-gray-200,
[data-theme="dark"] .border-gray-100 {
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .text-gray-900,
[data-theme="dark"] .text-gray-800,
[data-theme="dark"] .font-semibold,
[data-theme="dark"] .font-bold {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .text-gray-500,
[data-theme="dark"] .text-gray-600,
[data-theme="dark"] .text-gray-700,
[data-theme="dark"] .text-sm {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .text-gray-400,
[data-theme="dark"] .text-xs {
    color: var(--text-muted) !important;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background-color: var(--bg-input) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .bg-gray-50,
[data-theme="dark"] .bg-gray-100 {
    background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] pre,
[data-theme="dark"] code {
    background-color: #0d1117 !important;
    color: #e6edf3 !important;
}

[data-theme="dark"] .canvas-area {
    background-color: #0d1117 !important;
}

[data-theme="dark"] .hover\:bg-gray-50:hover {
    background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] kbd {
    background-color: var(--bg-input) !important;
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #334155 25%, #475569 50%, #334155 75%);
    background-size: 200% 100%;
}

/* ═══════════════════════════════════════════
   移动端适配 (Mobile Responsive)
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
    /* 侧边栏默认收起 */
    #sidebar {
        position: fixed !important;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 280px !important;
    }
    #sidebar.mobile-open {
        transform: translateX(0);
    }
    /* 遮罩 */
    #sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    #sidebar-overlay.active {
        display: block;
    }
    /* 汉堡菜单按钮 */
    .mobile-menu-btn {
        display: flex !important;
    }
    /* 网格自适应 */
    .grid-cols-2, .grid-cols-3, .grid-cols-4 {
        grid-template-columns: 1fr !important;
    }
    .lg\:grid-cols-2, .lg\:grid-cols-3, .lg\:grid-cols-4 {
        grid-template-columns: 1fr !important;
    }
    /* 表格横向滚动 */
    table {
        display: block;
        overflow-x: auto;
    }
    /* <img src="/static/icons/circle-check.svg" class="icon-sm" alt="" loading="lazy"> 聊天输入框移动端优化 */
    #queryInput {
        font-size: 16px !important; /* 防止iOS缩放 */
    }
    /* <img src="/static/icons/circle-check.svg" class="icon-sm" alt="" loading="lazy"> 对话列表面板移动端隐藏 */
    .w-72 {
        width: 100% !important;
        position: absolute;
        z-index: 10;
        height: 100%;
    }
    /* <img src="/static/icons/circle-check.svg" class="icon-sm" alt="" loading="lazy"> 更紧凑的间距 */
    .px-8 {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    .py-6 {
        padding-top: 12px !important;
        padding-bottom: 12px !important;
    }
    /* <img src="/static/icons/circle-check.svg" class="icon-sm" alt="" loading="lazy"> 模态框全屏 */
    .max-w-md, .max-w-sm, .max-w-lg {
        max-width: calc(100vw - 16px) !important;
    }
}

.mobile-menu-btn {
    display: none;
}
