/* ==========================================================================
   cc-overlay.css — 项目对通用组件的覆盖层
   加载顺序：cc-reset → cc-tokens → cc-structure → cc-skin-modern → cc-overlay → app.css
   此文件放置项目对 cc-structure 通用组件的定制微调。
   ========================================================================== */

/* ===== Layout 覆盖 ===== */
.sidebar {
  box-shadow: 1px 0 0 rgba(255,255,255,0.04) inset;
}
.sidebar__logo {
  color: #fff;
  box-shadow: 0 10px 28px rgba(0,0,0,0.22);
}
.nav-item {
  color: color-mix(in srgb, var(--text-muted), #ffffff 8%);
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.08); }
.nav-item.active {
  color: #fff;
  background: rgba(255,255,255,0.12);
}
:root[data-theme="fresh"] .nav-item,
:root[data-theme="cartoon"] .nav-item { color: var(--text-muted); }
:root[data-theme="fresh"] .nav-item:hover,
:root[data-theme="cartoon"] .nav-item:hover { color: var(--text-secondary); background: var(--bg-hover); }
:root[data-theme="fresh"] .nav-item.active,
:root[data-theme="cartoon"] .nav-item.active { color: var(--accent); background: var(--accent-soft); }
:root[data-theme="fresh"] .nav-item.active::before,
:root[data-theme="cartoon"] .nav-item.active::before { background: var(--accent); }
:root[data-theme="fresh"] .mobile-tab-bar__btn.active,
:root[data-theme="cartoon"] .mobile-tab-bar__btn.active { color: var(--accent); background: var(--accent-soft); }

:root[data-theme="fresh"] .sidebar {
  box-shadow: 1px 0 0 rgba(8, 145, 178, 0.10), 16px 0 34px rgba(14, 116, 144, 0.10);
}
:root[data-theme="fresh"] .sidebar__logo {
  background: linear-gradient(135deg, #0891b2, #84cc16 62%, #f97316);
  border-radius: 16px;
  box-shadow: 0 16px 32px rgba(8, 145, 178, 0.24);
}
:root[data-theme="fresh"] .nav-item:hover {
  color: var(--accent-hover);
  background: rgba(255,255,255,0.72);
}
:root[data-theme="fresh"] .nav-item.active {
  color: #ffffff;
  background: linear-gradient(135deg, #0891b2, #10b981);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35);
}

:root[data-theme="cartoon"] .sidebar {
  border-right: 2px solid var(--border);
  box-shadow: 4px 0 0 rgba(51, 42, 79, 0.85);
}
:root[data-theme="cartoon"] .sidebar__logo {
  background: linear-gradient(135deg, var(--accent), var(--warning));
  border: 2px solid var(--border);
  box-shadow: 3px 3px 0 var(--border);
}
:root[data-theme="cartoon"] .nav-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.58);
}
:root[data-theme="cartoon"] .nav-item.active {
  color: #ffffff;
  background: var(--accent);
}
:root[data-theme="cartoon"] .nav-item.active::before { background: var(--warning); }

:root[data-theme="business"] .header {
  box-shadow: 0 12px 28px rgba(17, 24, 21, 0.07);
}
:root[data-theme="business"] .sidebar {
  border-right-color: rgba(255, 255, 255, 0.08);
  box-shadow: 1px 0 0 rgba(255,255,255,0.05) inset, 14px 0 34px rgba(17, 24, 21, 0.10);
}
:root[data-theme="business"] .sidebar__logo {
  background: linear-gradient(135deg, #0f766e, #be7a15);
}
:root[data-theme="business"] .nav-item { color: rgba(255,255,255,0.55); }
:root[data-theme="business"] .nav-item:hover {
  background: rgba(255,255,255,0.10);
}
:root[data-theme="business"] .nav-item.active {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.88), rgba(169, 106, 9, 0.78));
}
:root[data-theme="cartoon"] .header {
  border-bottom: 2px solid var(--border);
  box-shadow: 0 3px 0 rgba(51, 42, 79, 0.85);
}
:root[data-theme="cartoon"] .header__title { text-shadow: 1px 1px 0 rgba(247, 169, 40, 0.5); }

/* ===== Button 覆盖 ===== */
.btn--accent { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 8px 18px color-mix(in srgb, var(--accent), transparent 78%); }
.btn--accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--active { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; }

/* ===== Switch 主题覆盖 ===== */
:root[data-theme="cartoon"] .switch__track { height: 22px; border: 2px solid var(--border); }
:root[data-theme="cartoon"] .switch--on .switch__track { background: var(--accent); border-color: var(--border); }

/* ===== Badge 颜色变体 ===== */
/* 注：.badge--success/danger/warning/muted/accent 与 cc-structure.css 字节相同，已删除避免重复 */

/* ===== Theme Picker 主题覆盖 ===== */
:root[data-theme="cartoon"] .theme-picker__dot {
  border: 1.5px solid var(--border);
  box-shadow: 1px 1px 0 var(--border);
}

/* ===== Focus visible (keyboard nav) ===== */
.btn:focus-visible,
.nav-item:focus-visible,
.tab-bar__btn:focus-visible,
.mobile-tab-bar__btn:focus-visible,
.stat-period-btn:focus-visible,
.custom-select:focus-visible,
.dtp-panel button:focus-visible,
.modal__close:focus-visible,
.dtp-trigger:focus-visible,
.model-select-trigger:focus-visible,
.theme-picker__item:focus-visible,
.dp-trigger:focus-visible,
.model-select-option:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

:root[data-theme="cartoon"] .btn:focus-visible,
:root[data-theme="cartoon"] .nav-item:focus-visible { outline-offset: 3px; }

/* ===== Cartoon 通用组件边框覆盖 ===== */
:root[data-theme="cartoon"] .card,
:root[data-theme="cartoon"] .stat-card,
:root[data-theme="cartoon"] .modal-content,
:root[data-theme="cartoon"] .toast,
:root[data-theme="cartoon"] .theme-picker,
:root[data-theme="cartoon"] .custom-select__dropdown,
:root[data-theme="cartoon"] .model-select-dropdown,
:root[data-theme="cartoon"] .dtp-panel {
  border-width: 2px;
}
:root[data-theme="cartoon"] .card__header {
  border-bottom-width: 2px;
}
:root[data-theme="cartoon"] .btn,
:root[data-theme="cartoon"] .input,
:root[data-theme="cartoon"] .tab-bar,
:root[data-theme="cartoon"] .key-display,
:root[data-theme="cartoon"] .json-block {
  border-width: 2px;
}
:root[data-theme="cartoon"] .btn {
  box-shadow: 2px 2px 0 rgba(51, 42, 79, 0.8);
}
:root[data-theme="cartoon"] .btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 rgba(51, 42, 79, 0.88);
}
:root[data-theme="cartoon"] .btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 rgba(51, 42, 79, 0.88);
}
:root[data-theme="cartoon"] .btn--accent,
:root[data-theme="cartoon"] .btn--active {
  color: #fff !important;
  text-shadow: 1px 1px 0 rgba(51, 42, 79, 0.4);
}

/* ===== Tab Bar ===== */
.tab-bar { display: flex; gap: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.tab-bar__btn {
  flex: 1; padding: 8px 16px; border: none; background: var(--bg-input);
  color: var(--text-muted); cursor: pointer; font-size: 13px; font-family: inherit;
  font-weight: 500; transition: background 0.15s, color 0.15s; border-right: 1px solid var(--border);
}
.tab-bar__btn:last-child { border-right: none; }
.tab-bar__btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.tab-bar__btn.active { background: var(--accent); color: #fff; font-weight: 600; }

/* ===== Modal 微调 ===== */
.modal__title { font-size: 14px; font-weight: 600; }
.modal__close {
  background: none; border: none; color: var(--text-muted); cursor: pointer;
  font-size: 20px; line-height: 1; padding: 4px; border-radius: var(--radius-sm);
  transition: background 0.15s; display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
}
.modal__close svg { width: 20px; height: 20px; display: block; }
.modal__close:hover { background: var(--bg-hover); }
.modal__body { padding: 16px 20px; }

/* ===== Toast ===== */

/* Toast 容器：fixed 定位，多 toast 纵向堆叠，不阻塞点击穿透 */
.toast-container {
  position: fixed; bottom: 70px; right: 20px; z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast-container .toast {
  pointer-events: auto;
  position: relative;
  padding: 10px 14px; border-radius: var(--radius);
  background: var(--bg-card-solid); border: 1px solid var(--accent);
  box-shadow: var(--shadow-lg); max-width: 260px; min-width: 0;
  font-size: 13px; line-height: 1.4; color: var(--text-primary);
  transform: translateY(20px); opacity: 0;
  transition: transform 0.25s, opacity 0.25s, border-color 0.15s;
}
.toast-container .toast.show { transform: translateY(0); opacity: 1; }
.toast-container .toast--success { border-color: var(--success); }
.toast-container .toast--error { border-color: var(--danger); }
.toast-container .toast--info { border-color: var(--accent); }

/* ===== Spinner ===== */
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Theme Switch Transition ===== */
.card, .modal-content, .header, .input, .stat-card, .theme-picker,
.btn, .toast, .nav-item, .sidebar, .key-display, .detail-section,
.tab-bar, .modal__header, .badge {
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

/* ===== Detail Grid ===== */
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 14px; font-size: 13px; }
@media (max-width: 640px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-grid__label { color: var(--text-muted); font-size: 11px; }
.detail-grid__value { font-weight: 500; }
.detail-section { margin-bottom: 16px; }
.detail-section__title { font-weight: 600; font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }

/* ===== Scrollbar ===== */
* {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent), transparent 34%) transparent;
}
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--bg-card-solid), transparent 42%);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent), #fff 10%), color-mix(in srgb, var(--accent), var(--warning) 20%));
  border: 2px solid color-mix(in srgb, var(--bg-card-solid), transparent 8%);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}
:root[data-theme="cartoon"] ::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent), var(--warning));
  border-color: #fffefa;
}

/* ===== Key Display ===== */
.key-display {
  background: var(--bg-hover); border-radius: var(--radius-sm);
  padding: 12px 16px; font-family: "SF Mono", Monaco, "Cascadia Code", "Fira Code", monospace;
  font-size: 13px; word-break: break-all; user-select: all;
  border: 1px solid var(--border); color: var(--text-primary);
}

/* ===== JSON Block ===== */
.json-block {
  background: var(--bg-hover); border-radius: var(--radius-sm);
  padding: 14px; font-family: "SF Mono", Monaco, "Cascadia Code", "Fira Code", monospace;
  font-size: 12px; line-height: 1.7; overflow-x: auto; white-space: pre;
  max-height: 400px; overflow-y: auto;
}
.json-key { color: var(--accent); }
.json-string { color: #a5d6a7; }
.json-number { color: #90caf9; }
.json-boolean { color: #ce93d8; }
.json-null { color: var(--text-muted); }
.json-punctuation { color: var(--text-secondary); }

:root[data-theme="fresh"] .json-string { color: #15803d; }
:root[data-theme="fresh"] .json-number { color: #0369a1; }
:root[data-theme="fresh"] .json-boolean { color: #7c3aed; }

:root[data-theme="cartoon"] .json-string { color: #059669; }
:root[data-theme="cartoon"] .json-number { color: #2563eb; }
:root[data-theme="cartoon"] .json-boolean { color: #9333ea; }

/* ===== Markdown Render ===== */
.md-render { font-size: 13px; line-height: 1.65; color: var(--text-primary); }
.md-render h1,.md-render h2,.md-render h3 { color: var(--text-primary); margin: 14px 0 8px; font-weight: 600; }
.md-render h1 { font-size: 18px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.md-render h2 { font-size: 16px; }
.md-render h3 { font-size: 14px; }
.md-render p { margin: 6px 0; }
.md-render ul,.md-render ol { padding-left: 20px; margin: 6px 0; }
.md-render li { margin: 3px 0; }
.md-render code { background: var(--bg-elevated); padding: 1px 5px; border-radius: 4px;
  font-family: 'JetBrains Mono', 'SF Mono', Monaco, monospace; font-size: 12px; }
.md-render pre { background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; overflow-x: auto; margin: 8px 0; }
.md-render pre code { background: none; padding: 0; }
.md-render table { border-collapse: collapse; width: 100%; max-width: 100%;
  overflow-x: auto; display: block; margin: 8px 0; font-size: 12px; }
.md-render th,.md-render td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md-render th { background: var(--bg-elevated); font-weight: 600; }
.md-render blockquote { border-left: 3px solid var(--accent); padding-left: 12px;
  margin: 8px 0; color: var(--text-secondary); }
.md-render hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.md-render a { color: var(--accent); text-decoration: underline; }
.md-render img { max-width: 100%; border-radius: 8px; margin: 8px 0; }
.md-render > *:first-child { margin-top: 0; }
.md-render > *:last-child { margin-bottom: 0; }

/* ===== 3 套主题的通用组件覆盖 ===== */
:root[data-theme="fresh"] .card,
:root[data-theme="fresh"] .stat-card,
:root[data-theme="fresh"] .modal-content,
:root[data-theme="fresh"] .toast,
:root[data-theme="fresh"] .theme-picker,
:root[data-theme="fresh"] .custom-select__dropdown,
:root[data-theme="fresh"] .model-select-dropdown,
:root[data-theme="fresh"] .dtp-panel {
  border-color: rgba(67, 89, 78, 0.14);
  box-shadow: var(--shadow);
}
:root[data-theme="fresh"] .card__header {
  background: linear-gradient(180deg, rgba(255,255,252,0.94), rgba(250,252,247,0.86));
}
:root[data-theme="fresh"] .btn--accent,
:root[data-theme="fresh"] .btn--active {
  box-shadow: 0 10px 22px rgba(8, 145, 178, 0.18);
}

:root[data-theme="cartoon"] .badge {
  border: 1.5px solid currentColor;
  font-weight: 800;
}

.tab-bar__btn--sm { padding: 3px 10px; font-size: 11px; border-radius: 4px; }
