/* ============================================================
   通用组件样式：主题变量 + Toast 提示 + 自定义确认框
   所有页面共用（base.html 里引入）
   ============================================================ */

/* ============================================================
   ★ 全局主题变量（CSS 自定义属性）
   所有页面的颜色都从这里取值。好处：
   1. 改主题色只改这一个地方，全站生效
   2. 暗色模式只需在 html[data-theme="dark"] 里覆盖同名变量，
      所有引用 var() 的地方自动跟着变，不用写两套样式

   用法：color: var(--text-title);
   ============================================================ */
:root {
    /* ---- 品牌色（主渐变，按钮/头像/高亮共用） ---- */
    --brand-grad: linear-gradient(135deg, #667eea, #764ba2);
    --brand-1: #667eea;                       /* 输入框聚焦边框色 */
    --focus-ring: 0 0 0 3px rgba(102, 126, 234, 0.15);  /* 聚焦光圈 */

    /* ---- 侧边栏（深色设计，亮暗两套主题下都不变） ---- */
    --sidebar-grad: linear-gradient(180deg, #2a2f6e 0%, #1e1b4b 100%);
    --menu-text: #c7d2fe;                     /* 菜单未选中文字 */

    /* ---- 文字（从深到浅 4 级） ---- */
    --text-title: #2d3748;                    /* 标题 */
    --text-body: #4a5568;                     /* 正文 */
    --text-muted: #a0aec0;                    /* 次要说明 */
    --text-faint: #c0c6cf;                    /* 最弱（时间戳等） */

    /* ---- 背景与边框 ---- */
    --bg-page: #f5f7fa;                       /* 页面大背景 */
    --bg-card: #ffffff;                       /* 卡片/弹窗 */
    --bg-hover: #f7f8fa;                      /* 列表行 hover */
    --bg-soft: #f0f2f5;                       /* 次级按钮底色 */
    --border: #e2e8f0;                        /* 输入框边框 */
    --line: #f0f2f5;                          /* 列表分隔线 */
    --mask: rgba(0, 0, 0, 0.4);               /* 弹窗遮罩 */
    --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.05);   /* 卡片阴影 */

    /* ---- 语义色（图标/文字用） ---- */
    --blue: #4299e1;
    --green: #48bb78;
    --red: #f56565;
    --purple: #9f7aea;

    /* ---- 语义色淡底（卡片/小按钮背景用） ---- */
    --tint-blue: #eff6ff;
    --tint-green: #f0fdf4;
    --tint-red: #fef2f2;
    --tint-purple: #faf5ff;

    /* ---- 标签芯片 ---- */
    --chip-bg: #f3f0ff;
    --chip-text: #6b46c1;
    --chip-hover: #e9e2ff;
}

/* ============================================================
   ★ 暗色主题
   base.html 的内联脚本会根据 localStorage 给 <html> 设置
   data-theme="dark"，此时下面的变量覆盖 :root 里的同名变量。
   侧边栏本来就是深色，不用覆盖。
   ============================================================ */
html[data-theme="dark"] {
    --text-title: #e2e8f0;
    --text-body: #cbd5e0;
    --text-muted: #8b95a5;
    --text-faint: #5f6b7d;

    --bg-page: #12141d;
    --bg-card: #1c2030;
    --bg-hover: #242940;
    --bg-soft: #262b3d;
    --border: #303650;
    --line: #2a2f45;
    --mask: rgba(0, 0, 0, 0.6);
    --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.45);

    /* 淡底色改为"同色低透明度"，在深色背景上柔和发光 */
    --tint-blue: rgba(66, 153, 225, 0.15);
    --tint-green: rgba(72, 187, 120, 0.15);
    --tint-red: rgba(245, 101, 101, 0.15);
    --tint-purple: rgba(159, 122, 234, 0.15);

    --chip-bg: rgba(159, 122, 234, 0.15);
    --chip-text: #b794f4;
    --chip-hover: rgba(159, 122, 234, 0.25);

    /* placeholder 颜色在暗色模式下也保持极淡，否则暗色背景上的亮白 placeholder
       会像"高亮文字"一样刺眼，和正文/标签的层级完全混掉（截图里 "元气满满的一天..." 就是这个问题） */
}

/* ============================================================
   ★ 全局 placeholder 样式
   所有 input / textarea 的 placeholder 统一从 --text-muted 取值，
   再降 0.7 透明度（暗色模式下 common.css 末尾单独覆盖，用更暗的 text-faint）。
   这样标题输入框、标签选择、搜索框、编辑器 placeholder 都走同一条规则，
   层级明确：正文（实色） > 标签（chip） > placeholder（极淡提示）
   ============================================================ */
::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
    font-style: italic;   /* 斜体 = 语义上的"提示词"，和真实输入的正文区分开 */
}

html[data-theme="dark"] ::placeholder {
    /* 暗色模式下调到最弱的 text-faint，避免刺眼 */
    color: var(--text-faint);
    opacity: 0.6;
}

/* ===== Toast 提示（顶部弹出，自动消失） ===== */
.toast {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    color: #fff;
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    max-width: 80vw;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 不同类型不同颜色 */
.toast-info { background: var(--blue); }      /* 普通提示：蓝 */
.toast-success { background: var(--green); }  /* 成功：绿 */
.toast-error { background: var(--red); }      /* 失败：红 */

/* ===== 自定义确认框（模态框） ===== */
.confirm-mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--mask);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.confirm-box {
    width: 320px;
    background: var(--bg-card);
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.confirm-message {
    font-size: 15px;
    color: var(--text-title);
    margin-bottom: 24px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.confirm-cancel,
.confirm-ok {
    height: 38px;
    padding: 0 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.confirm-cancel:hover,
.confirm-ok:hover {
    opacity: 0.85;
}

.confirm-cancel {
    background: var(--bg-soft);
    color: var(--text-body);
}

.confirm-ok {
    background: var(--brand-grad);
    color: #fff;
}

/* ===== 通用模态框（新增/编辑弹窗共用，所有页面可复用） ===== */
.modal-mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--mask);
    display: none;
    justify-content: center;
    /* 默认从上往下露出——小窗口（如 720px 宽但窗口只有 360px 宽）时，
       flex center 会把弹窗挤在中间导致：上下被遮罩压住、底部按钮被挤出可视区。
       改为 flex-start + padding，弹窗从顶部开始显示，底部被遮罩盖住时
       弹窗外层自己的 overflow:auto 就能滚动，保证按钮永远可见 */
    align-items: flex-start;
    padding: 20px 16px;
    overflow-y: auto;
    z-index: 100;
}

.modal-mask.show {
    display: flex;
}

.modal {
    width: 360px;
    background: var(--bg-card);
    border-radius: 14px;
    padding: 28px;
}

.modal-title {
    font-size: 18px;
    color: var(--text-title);
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.modal-cancel,
.modal-confirm {
    height: 38px;
    padding: 0 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.modal-cancel:hover,
.modal-confirm:hover {
    opacity: 0.85;
}

.modal-cancel {
    background: var(--bg-soft);
    color: var(--text-body);
}

.modal-confirm {
    background: var(--brand-grad);
    color: #fff;
}

/* ===== 主题切换按钮（放在侧边栏底部） ===== */
.theme-toggle {
    width: 100%;
    height: 38px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--menu-text);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.18);
}
