/**
 * CSS Variables - History Detail 全局变量系统
 *
 * 职责：定义所有可复用的设计令牌（Design Tokens）
 * 作用域：全局（:root）
 * 修改时机：仅在需要全局调整设计系统时修改
 *
 * 组织结构：
 * 1. Z-Index 层级系统
 * 2. 颜色系统 (Modern Slate & Indigo Palette - Refined for Minimalism)
 * 3. 尺寸系统
 * 4. 间距与圆角
 * 5. 动画与过渡
 * 6. 断点
 */

:root {
  /* ==================== Z-Index 层级系统 ==================== */
  --z-base: 1;
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-immersive-container: 1999;
  --z-immersive-controls: 2000;
  --z-modal-backdrop: 2100; /* Keep overlays above immersive layout */
  --z-modal: 2110;
  --z-popover: 2120;
  --z-tooltip: 2130;
  --z-lightbox: 2300;
  --z-critical: 9999;

  /* ==================== 颜色系统 (Modernized & Minimalist) ==================== */

  /* Slate Palette (Neutral) - Refined for lighter, airier feel */
  --slate-50: #f9fafb;
  --slate-100: #f3f4f6;
  --slate-200: #e5e7eb;
  --slate-300: #d1d5db;
  --slate-400: #9ca3af;
  --slate-500: #6b7280;
  --slate-600: #4b5563;
  --slate-700: #374151;
  --slate-800: #1f2937;
  --slate-900: #111827;

  /* Indigo Palette (Primary) - Slightly more sophisticated */
  --indigo-50: #eef2ff;
  --indigo-100: #e0e7ff;
  --indigo-500: #6366f1;
  --indigo-600: #4f46e5;
  --indigo-700: #4338ca;

  /* Semantic Mapping */
  --color-primary: var(--indigo-600);
  --color-primary-hover: var(--indigo-700);
  --color-primary-active: var(--indigo-800);
  --color-primary-light: var(--indigo-50);

  /* Backgrounds */
  --color-bg-primary: #ffffff; /* Primary surface (alias of base for legacy vars) */
  --color-bg-base: #ffffff;
  --color-bg-secondary: #fafafa; /* Lighter than slate-50 for subtle contrast */
  --color-bg-tertiary: var(--slate-50);
  --color-bg-overlay: rgba(255, 255, 255, 0.85); /* More translucent */
  --color-bg-dark: var(--slate-900);

  /* Text */
  --color-text-primary: #1f2937; /* Soft black */
  --color-text-secondary: #6b7280;
  --color-text-muted: #9ca3af;
  --color-text-inverse: #ffffff;

  /* Borders - Much lighter for minimalism */
  --color-border-light: #f3f4f6; /* Very subtle */
  --color-border-medium: #e5e7eb;
  --color-border-dark: #d1d5db;

  /* Functional Colors */
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #3b82f6;

  /* Highlights */
  --color-highlight-bg: #fffbeb; /* Amber 50 - lighter */
  --color-highlight-border: #fcd34d;
  --color-selection-bg: var(--indigo-50);

  /* Shadows (Ultra Minimalist & Diffused) */
  --color-shadow-light: rgba(0, 0, 0, 0.02);
  --color-shadow-medium: rgba(0, 0, 0, 0.04);
  --color-shadow-strong: rgba(0, 0, 0, 0.08);

  /* ==================== Sidebar Dimensions ==================== */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 76px;
  --sidebar-z-index: 50;
  --sidebar-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  --sidebar-nav-item-padding: 0.75rem 0.875rem;
  --sidebar-nav-item-font-size: 0.9375rem;
  --sidebar-section-header-padding: 0.625rem 0.875rem;
  --sidebar-section-content-padding: 0.5rem 0;

  /* ==================== Legacy/Specific Components ==================== */
  --toc-button-size: 32px;
  --toc-button-left: 16px;
  --toc-button-top: 16px;
  --toc-button-z-index: var(--z-fixed);
  --toc-popup-width: 160px;
  --toc-popup-max-height: 70vh;
  --toc-popup-left: 16px;
  --toc-popup-top: 56px;
  --toc-popup-z-index: var(--z-popover);
  --toc-item-height: 32px;
  --toc-item-padding-x: 12px;
  --toc-item-padding-y: 6px;
  --toc-indent-width: 20px;

  --dock-width: 280px;
  --dock-min-width: 200px;
  --dock-max-width: 400px;
  --dock-collapsed-height: 40px;
  --dock-expanded-height: auto;
  --dock-max-height: 300px;
  --dock-position-bottom: 20px;
  --dock-position-left: 20px;
  --dock-z-index: var(--z-fixed);
  --dock-stat-item-height: 28px;
  --dock-stat-font-size: 13px;

  --immersive-toc-width: 15%;
  --immersive-toc-min-width: 200px;
  --immersive-toc-max-width: 350px;
  --immersive-main-flex: 1;
  --immersive-main-min-width: 400px;
  --immersive-chatbot-width: 20%;
  --immersive-chatbot-min-width: 280px;
  --immersive-chatbot-max-width: 500px;
  --immersive-resize-handle-width: 6px;
  --immersive-resize-handle-hover-width: 10px;
  --immersive-container-z-index: var(--z-immersive-container);
  --immersive-toggle-z-index: var(--z-immersive-controls);

  /* ==================== Modal Dimensions ==================== */
  --modal-backdrop-z-index: var(--z-modal-backdrop);
  --modal-content-z-index: var(--z-modal);
  --modal-width-small: 400px;
  --modal-width-medium: 600px;
  --modal-width-large: 800px;
  --modal-width-xlarge: 1000px;
  --modal-max-height: 85vh;
  --modal-padding: 24px;

  /* ==================== Lightbox ==================== */
  --lightbox-z-index: var(--z-lightbox);
  --lightbox-backdrop-bg: rgba(0, 0, 0, 0.9);
  --lightbox-max-width: 90vw;
  --lightbox-max-height: 90vh;

  /* ==================== Chatbot ==================== */
  --chatbot-config-modal-z-index: 999999;
  --chatbot-message-action-z-index: var(--z-dropdown);
  --chatbot-input-min-height: 60px;
  --chatbot-input-max-height: 200px;
  --chatbot-message-padding: 12px 16px;

  /* ==================== Spacing ==================== */
  --spacing-xs: 0.25rem;  /* 4px */
  --spacing-sm: 0.5rem;   /* 8px */
  --spacing-md: 1rem;     /* 16px */
  --spacing-lg: 1.5rem;   /* 24px */
  --spacing-xl: 2rem;     /* 32px */
  --spacing-xxl: 3rem;    /* 48px */

  /* ==================== Radius ==================== */
  --radius-sm: 0.25rem;   /* 4px */
  --radius-md: 0.375rem;  /* 6px */
  --radius-lg: 0.5rem;    /* 8px */
  --radius-xl: 0.75rem;   /* 12px */
  --radius-2xl: 1rem;     /* 16px */
  --radius-round: 50%;

  /* ==================== Shadows (Refined for High-end Minimalism) ==================== */
  /* Much lighter, more diffuse shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.04), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);

  --shadow-float: 0 4px 20px rgba(0, 0, 0, 0.06); /* Special soft float shadow */
  --shadow-modal: 0 20px 50px rgba(0, 0, 0, 0.08);

  /* ==================== Animations ==================== */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);

  --animation-duration-short: 200ms;
  --animation-duration-base: 300ms;

  /* ==================== Typography ==================== */
  --font-family-base: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-family-monospace: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-md: 1.125rem;   /* 18px */
  --font-size-lg: 1.25rem;    /* 20px */
  --font-size-xl: 1.5rem;     /* 24px */
  --font-size-xxl: 1.875rem;  /* 30px */

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.25;
  --line-height-base: 1.6;
  --line-height-relaxed: 1.75;

  /* ==================== Breakpoints ==================== */
  --breakpoint-mobile: 700px;
  --breakpoint-tablet: 768px;
  --breakpoint-desktop: 1024px;
  --breakpoint-wide: 1280px;

  /* ==================== Buttons ==================== */
  --button-size-tiny: 28px;
  --button-size-small: 32px;
  --button-size-medium: 38px;
  --button-size-large: 44px;

  /* ==================== Utils ==================== */
  --scrollable-overflow: auto;
  --dragging-cursor: grabbing;
  --dragging-user-select: none;
  --disabled-opacity: 0.5;
  --disabled-cursor: not-allowed;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark mode foundations can be added here mapping to Slate-800 etc. */
  }
}
