/**
 * 主题扩展：暗夜 / 白昼
 *
 * 1. 补齐并统一暗夜模式的默认变量（与原有 Zinc 配色一致）
 * 2. 通过 :root[data-theme="light"] 覆盖为白昼配色
 * 3. 提供全站主题切换按钮样式
 */

:root {
    /* 兼容不同页面各自定义的变量别名 */
    --border-color: #27272a;
    --text-sub: #a1a1aa;
    --text-secondary: #a1a1aa;
    --bg-card-hover: #1c1c1f;

    /* 半透明白色叠加层（暗色表面上的微弱提亮） */
    --surface-1: rgba(255, 255, 255, 0.02);
    --surface-2: rgba(255, 255, 255, 0.03);
    --surface-3: rgba(255, 255, 255, 0.05);
    --surface-4: rgba(255, 255, 255, 0.08);
    --surface-5: rgba(255, 255, 255, 0.1);
    --surface-6: rgba(255, 255, 255, 0.2);
    --surface-7: rgba(255, 255, 255, 0.5);

    /* 半透明黑色内凹层（输入区、面板底、遮罩） */
    --inset-1: rgba(0, 0, 0, 0.1);
    --inset-2: rgba(0, 0, 0, 0.2);
    --inset-3: rgba(0, 0, 0, 0.3);
    --inset-4: rgba(0, 0, 0, 0.4);

    --text-faint: rgba(255, 255, 255, 0.7);

    color-scheme: dark;
}

:root[data-theme="light"] {
    --bg-dark: #f4f4f6;
    --bg-panel: #ffffff;
    --bg-hover: #e9e9ee;
    --bg-card: #ffffff;
    --bg-card-hover: #f3f3f6;

    --border: #d9d9e0;
    --border-color: #d9d9e0;
    --border-subtle: #e6e6ea;
    --border-light: rgba(0, 0, 0, 0.08);

    --text-main: #1c1c22;
    --text-sub: #55555f;
    --text-secondary: #55555f;
    --text-muted: #85858f;
    --text-faint: rgba(0, 0, 0, 0.6);

    --dock-bg: rgba(255, 255, 255, 0.9);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.12), 0 4px 6px -4px rgba(0, 0, 0, 0.08);

    --surface-1: rgba(0, 0, 0, 0.02);
    --surface-2: rgba(0, 0, 0, 0.035);
    --surface-3: rgba(0, 0, 0, 0.05);
    --surface-4: rgba(0, 0, 0, 0.07);
    --surface-5: rgba(0, 0, 0, 0.09);
    --surface-6: rgba(0, 0, 0, 0.14);
    --surface-7: rgba(0, 0, 0, 0.3);

    --inset-1: rgba(0, 0, 0, 0.03);
    --inset-2: rgba(0, 0, 0, 0.05);
    --inset-3: rgba(0, 0, 0, 0.07);
    --inset-4: rgba(0, 0, 0, 0.1);

    /* 登录页 */
    --login-card-bg: #ffffff;
    --login-input-bg: #f7f7f9;

    color-scheme: light;
}

/* 页面底色平滑过渡 */
html,
body {
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* --- 主题切换按钮 --- */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: transparent;
    border: none;
    color: var(--text-sub);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 12px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.theme-toggle-btn:hover {
    background: var(--surface-3);
    color: var(--text-main);
}

.theme-toggle-btn .material-icons-round {
    font-size: 20px;
}

.theme-toggle-floating {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* 侧边栏内的主题按钮（首页） */
.sidebar-theme-toggle {
    margin: 8px 12px 12px;
    width: calc(100% - 24px);
    justify-content: flex-start;
    color: var(--text-secondary);
}

.sidebar-theme-toggle .theme-toggle-text {
    font-size: 12px;
}

/* 生成页左侧栏的主题按钮 */
.sidebar-bottom-actions .theme-toggle-btn {
    width: 100%;
    flex-direction: column;
    gap: 4px;
    padding: 10px 0;
    border-radius: 0;
}

.sidebar-bottom-actions .theme-toggle-btn .theme-toggle-text,
.sidebar-bottom-actions .theme-toggle-btn .theme-toggle-text-short {
    font-size: 10px;
    color: var(--text-sub);
}

/* 白昼模式下的细节修正 */
:root[data-theme="light"] .modal {
    background: rgba(0, 0, 0, 0.45);
}

:root[data-theme="light"] .project-card-cover {
    background: linear-gradient(135deg, #dcdce3 0%, #f1f1f4 100%);
    color: rgba(0, 0, 0, 0.15);
}

:root[data-theme="light"] .cover-preview {
    border-color: var(--border-color);
}

/* 媒体预览画布保持深色，避免图片泛白 */
:root[data-theme="light"] .stage,
:root[data-theme="light"] .preview-section,
:root[data-theme="light"] .preview-column,
:root[data-theme="light"] .preview-item,
:root[data-theme="light"] .view-preview,
:root[data-theme="light"] .ref-image-item,
:root[data-theme="light"] .outfit-preview,
:root[data-theme="light"] .clip-segment .segment-thumbnail {
    background-color: #000;
}
