/* ========================================
   THEME SYSTEM - Centralized Theme Management
   ======================================== */

/* ========================================
   BASE THEME VARIABLES (Light Theme)
   Applied to :root for default styling
   ======================================== */

:root {
    /* Brand Colors */
    --color-primary: #3498db;
    --color-primary-dark: #2980b9;
    --color-primary-light: #5dade2;

    --color-secondary: #2c3e50;
    --color-secondary-dark: #1a252f;
    --color-secondary-light: #34495e;

    /* Status Colors */
    --color-success: #27ae60;
    --color-success-light: #2ecc71;
    --color-success-dark: #1e8449;

    --color-error: #e74c3c;
    --color-error-light: #e67e73;
    --color-error-dark: #c0392b;

    --color-warning: #f39c12;
    --color-warning-light: #f5b041;
    --color-warning-dark: #d68910;

    --color-info: #3498db;
    --color-info-light: #5dade2;
    --color-info-dark: #2874a6;

    /* Neutral Colors */
    --color-white: #ffffff;
    --color-black: #000000;

    /* Card Game Colors - Official Gundam Card Game Colors */
    --card-color-red: #d01f10;
    --card-color-blue: #2c52b3;
    --card-color-green: #147e04;
    --card-color-purple: #6C3483;
    --card-color-yellow: #f1c40f;
    --card-color-white: #ecf0f1;
    --card-color-black: #2c3e50;

    /* Card Color Gradients (for darker shades) */
    --card-color-red-dark: #a01808;
    --card-color-blue-dark: #1f3d85;
    --card-color-green-dark: #0e5c03;
    --card-color-purple-dark: #4f2660;

    /* Gray Scale */
    --gray-50: #f8f9fa;
    --gray-100: #e9ecef;
    --gray-200: #dee2e6;
    --gray-300: #ced4da;
    --gray-400: #adb5bd;
    --gray-500: #6c757d;
    --gray-600: #495057;
    --gray-700: #343a40;
    --gray-800: #212529;
    --gray-900: #0d0d0d;

    /* ========================================
       SEMANTIC THEME TOKENS
       These adapt based on the active theme
       ======================================== */

    /* Surface Colors (Backgrounds) */
    --surface-body: #f5f5f5;
    --surface-primary: var(--color-white);
    --surface-secondary: var(--gray-50);
    --surface-tertiary: var(--gray-100);
    --surface-elevated: var(--color-white);
    --surface-overlay: rgba(0, 0, 0, 0.6);

    /* Text Colors */
    --text-primary: #2c3e50;
    --text-secondary: #666666;
    --text-tertiary: #95a5a6;
    --text-disabled: #adb5bd;
    --text-inverse: var(--color-white);

    /* Border Colors */
    --border-primary: #e1e8ed;
    --border-secondary: var(--gray-200);
    --border-tertiary: var(--gray-300);
    --border-focus: var(--color-primary);

    /* Interactive States */
    --interactive-hover: rgba(52, 152, 219, 0.1);
    --interactive-active: rgba(52, 152, 219, 0.2);
    --interactive-disabled: var(--gray-200);

    /* Link Colors */
    --link-color: var(--color-primary);
    --link-hover: var(--color-primary-dark);
    --link-visited: #8e44ad;
    --link-active: var(--color-primary-dark);

    /* Divider/Separator Colors */
    --divider-color: var(--border-primary);
    --divider-strong: var(--border-secondary);

    /* Overlay Colors */
    --overlay-light: rgba(0, 0, 0, 0.3);
    --overlay-medium: rgba(0, 0, 0, 0.6);
    --overlay-heavy: rgba(0, 0, 0, 0.8);

    /* Focus States */
    --focus-ring: 0 0 0 3px rgba(52, 152, 219, 0.3);
    --focus-ring-error: 0 0 0 3px rgba(231, 76, 60, 0.3);
    --focus-ring-success: 0 0 0 3px rgba(39, 174, 96, 0.3);

    /* Selection Colors */
    --selection-bg: rgba(52, 152, 219, 0.2);
    --selection-text: var(--text-primary);

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.2);

    /* Component-Specific */
    --header-bg: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    --header-text: var(--color-white);

    --card-bg: var(--surface-primary);
    --card-border: var(--border-primary);
    --card-shadow: var(--shadow-md);

    --input-bg: var(--surface-primary);
    --input-border: var(--border-secondary);
    --input-text: var(--text-primary);
    --input-placeholder: var(--text-tertiary);

    --button-primary-bg: var(--color-primary);
    --button-primary-hover: var(--color-primary-dark);
    --button-primary-text: var(--color-white);

    --button-secondary-bg: var(--gray-500);
    --button-secondary-hover: var(--gray-600);
    --button-secondary-text: var(--color-white);

    --modal-bg: var(--surface-primary);
    --modal-overlay: var(--surface-overlay);

    --button-danger-bg: var(--color-error);
    --button-danger-hover: var(--color-error-dark);
    --button-danger-text: var(--color-white);

    --button-success-bg: var(--color-success);
    --button-success-hover: var(--color-success-dark);
    --button-success-text: var(--color-white);

    /* Table/List Colors */
    --table-header-bg: var(--surface-secondary);
    --table-header-text: var(--text-primary);
    --table-row-bg: var(--surface-primary);
    --table-row-alt-bg: var(--surface-secondary);
    --table-row-hover-bg: var(--interactive-hover);
    --table-border: var(--border-primary);

    /* Badge/Pill Colors */
    --badge-bg-primary: var(--color-primary);
    --badge-text-primary: var(--color-white);
    --badge-bg-secondary: var(--gray-200);
    --badge-text-secondary: var(--text-primary);
    --badge-bg-success: var(--color-success);
    --badge-text-success: var(--color-white);
    --badge-bg-error: var(--color-error);
    --badge-text-error: var(--color-white);
    --badge-bg-warning: var(--color-warning);
    --badge-text-warning: var(--text-primary);

    /* Progress Bar Colors */
    --progress-bg: var(--gray-200);
    --progress-fill: var(--color-primary);
    --progress-success: var(--color-success);
    --progress-warning: var(--color-warning);
    --progress-error: var(--color-error);

    /* Tooltip Colors */
    --tooltip-bg: var(--gray-800);
    --tooltip-text: var(--color-white);
    --tooltip-shadow: var(--shadow-lg);

    /* Dropdown Colors */
    --dropdown-bg: var(--surface-primary);
    --dropdown-border: var(--border-primary);
    --dropdown-shadow: var(--shadow-lg);
    --dropdown-item-hover-bg: var(--interactive-hover);
    --dropdown-item-active-bg: var(--interactive-active);

    /* Scrollbar Colors */
    --scrollbar-track: var(--surface-secondary);
    --scrollbar-thumb: var(--gray-400);
    --scrollbar-thumb-hover: var(--gray-500);

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 24px;
    --spacing-2xl: 32px;
    --spacing-3xl: 48px;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 9999px;

    /* Typography */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;

    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-base: 250ms ease-in-out;
    --transition-slow: 350ms ease-in-out;
}

/* ========================================
   DARK THEME
   Override semantic tokens for dark mode
   ======================================== */

body.dark-theme {
    /* Brand Colors - Adjusted for dark mode */
    --color-primary: #5dade2;
    --color-primary-dark: #3498db;
    --color-primary-light: #85c1e9;

    /* Gray Scale - Inverted */
    --gray-50: #2c2c2c;
    --gray-100: #333333;
    --gray-200: #3a3a3a;
    --gray-300: #444444;
    --gray-400: #555555;
    --gray-500: #666666;
    --gray-600: #bdc3c7;
    --gray-700: #ecf0f1;
    --gray-800: #ffffff;

    /* Surface Colors */
    --surface-body: #1a1a1a;
    --surface-primary: #2c2c2c;
    --surface-secondary: #333333;
    --surface-tertiary: #3a3a3a;
    --surface-elevated: #2c2c2c;
    --surface-overlay: rgba(0, 0, 0, 0.8);

    /* Text Colors */
    --text-primary: #ecf0f1;
    --text-secondary: #bdc3c7;
    --text-tertiary: #95a5a6;
    --text-disabled: #666666;
    --text-inverse: #2c3e50;

    /* Border Colors */
    --border-primary: #444444;
    --border-secondary: #555555;
    --border-tertiary: #666666;

    /* Interactive States */
    --interactive-hover: rgba(93, 173, 226, 0.15);
    --interactive-active: rgba(93, 173, 226, 0.25);
    --interactive-disabled: #3a3a3a;

    /* Shadows - Darker and more pronounced */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 10px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.7);

    /* Component-Specific */
    --header-bg: linear-gradient(135deg, #2c3e50, #34495e);

    --card-bg: var(--surface-secondary);
    --card-border: var(--border-primary);

    --input-bg: var(--surface-tertiary);
    --input-border: var(--border-secondary);

    --button-secondary-bg: #555555;
    --button-secondary-hover: #666666;

    /* Link Colors */
    --link-visited: #bb8fce;

    /* Overlay Colors - More opaque for dark theme */
    --overlay-light: rgba(0, 0, 0, 0.5);
    --overlay-medium: rgba(0, 0, 0, 0.75);
    --overlay-heavy: rgba(0, 0, 0, 0.9);

    /* Focus States - Brighter for dark theme */
    --focus-ring: 0 0 0 3px rgba(93, 173, 226, 0.4);
    --focus-ring-error: 0 0 0 3px rgba(231, 76, 60, 0.4);
    --focus-ring-success: 0 0 0 3px rgba(46, 204, 113, 0.4);

    /* Selection Colors */
    --selection-bg: rgba(93, 173, 226, 0.3);

    /* Table/List Colors */
    --table-header-bg: var(--surface-tertiary);
    --table-header-text: var(--gray-700); /* Brighter for better contrast */
    --table-row-bg: var(--surface-secondary);
    --table-row-alt-bg: var(--surface-tertiary);
    --table-row-hover-bg: var(--interactive-hover);

    /* Badge/Pill Colors - Darker backgrounds for dark theme */
    --badge-bg-secondary: var(--gray-400);
    --badge-text-secondary: var(--text-primary);

    /* Progress Bar Colors */
    --progress-bg: var(--gray-300);

    /* Tooltip Colors - Lighter for contrast */
    --tooltip-bg: var(--gray-700);
    --tooltip-text: var(--text-primary);

    /* Dropdown Colors */
    --dropdown-bg: var(--surface-tertiary);

    /* Scrollbar Colors */
    --scrollbar-track: var(--surface-tertiary);
    --scrollbar-thumb: var(--gray-500);
    --scrollbar-thumb-hover: var(--gray-600);
}

/* ========================================
   FUTURE THEMES (Examples)
   ======================================== */

/* High Contrast Theme */
body.high-contrast-theme {
    --color-primary: #0066cc;
    --surface-body: #000000;
    --surface-primary: #000000;
    --text-primary: #ffffff;
    --border-primary: #ffffff;
    --shadow-md: 0 0 0 2px #ffffff;
}

/* Sepia Theme (for reduced eye strain) */
body.sepia-theme {
    --surface-body: #f4ecd8;
    --surface-primary: #faf6ed;
    --surface-secondary: #f0e8d5;
    --text-primary: #5c4a37;
    --text-secondary: #786856;
}

/* ========================================
   BASE STYLES USING SEMANTIC TOKENS
   Apply these to components instead of hardcoded colors
   ======================================== */

body {
    background-color: var(--surface-body);
    color: var(--text-primary);
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* Smooth theme transitions */
body.theme-transition,
body.theme-transition *,
body.theme-transition *:before,
body.theme-transition *:after {
    transition: background-color var(--transition-base),
                color var(--transition-base),
                border-color var(--transition-base) !important;
}

/* Text selection styling */
::selection {
    background-color: var(--selection-bg);
    color: var(--selection-text);
}

::-moz-selection {
    background-color: var(--selection-bg);
    color: var(--selection-text);
}

/* Scrollbar styling (webkit browsers) */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-md);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* ========================================
   THEME SYSTEM USAGE GUIDE
   ========================================

   IMPORTANT: Always use CSS variables for colors, never hardcode!

   CORRECT USAGE:
   ✅ background-color: var(--surface-primary);
   ✅ color: var(--text-secondary);
   ✅ border: 1px solid var(--border-primary);

   INCORRECT USAGE:
   ❌ background-color: #ffffff;
   ❌ color: #666666;
   ❌ border: 1px solid #e1e8ed;

   VARIABLE CATEGORIES:

   1. SURFACES (Backgrounds)
      --surface-body: Page background
      --surface-primary: Card/container backgrounds
      --surface-secondary: Subtle backgrounds
      --surface-tertiary: More subdued backgrounds
      --surface-elevated: Floating elements (modals, dropdowns)
      --surface-overlay: Dark overlay for modals

   2. TEXT
      --text-primary: Main text
      --text-secondary: Supporting text
      --text-tertiary: Subtle text (labels, meta info)
      --text-disabled: Disabled state text
      --text-inverse: Text on dark backgrounds

   3. BORDERS
      --border-primary: Main borders
      --border-secondary: Subtle borders
      --border-tertiary: Very subtle borders
      --border-focus: Focus state borders

   4. INTERACTIVE
      --interactive-hover: Hover state backgrounds
      --interactive-active: Active/pressed state backgrounds
      --interactive-disabled: Disabled state backgrounds

   5. STATUS (Semantic colors)
      --color-success: Success states
      --color-error: Error/danger states
      --color-warning: Warning states
      --color-info: Info states

   6. BUTTONS
      --button-primary-bg/hover/text
      --button-secondary-bg/hover/text
      --button-danger-bg/hover/text
      --button-success-bg/hover/text

   7. COMPONENTS
      Use component-specific tokens when available:
      --card-bg, --card-border, --card-shadow
      --input-bg, --input-border, --input-text
      --modal-bg, --modal-overlay
      --table-header-bg, --table-row-hover-bg
      --badge-bg-primary, --badge-text-primary
      --progress-fill, --progress-bg
      --tooltip-bg, --tooltip-text
      --dropdown-bg, --dropdown-item-hover-bg

   8. SPACING & LAYOUT
      --spacing-xs to --spacing-3xl: Consistent spacing
      --radius-sm to --radius-full: Border radius
      --shadow-sm to --shadow-xl: Box shadows

   9. TRANSITIONS
      --transition-fast: Quick interactions (150ms)
      --transition-base: Standard transitions (250ms)
      --transition-slow: Smooth transitions (350ms)

   CREATING NEW THEMES:
   1. Copy the dark-theme block
   2. Rename to your theme (e.g., body.nord-theme)
   3. Override only the semantic tokens you want to change
   4. Test with theme-playground.html

   ======================================== */
