/* ============================================
   THEMES — CSS Custom Properties
   Dark (default) + Light mode
   ============================================ */
 
:root {
    /* Background */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-header: #404040;
    --bg-card: #363636;
    --bg-input: #2d2d2d;
    --bg-hover: #444444;

    /* Text */
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #888888;
    --text-link: #4fc3f7;
    --text-link-hover: #81d4fa;

    /* Borders */
    --border-color: #555555;
    --border-focus: #4fc3f7;

    /* Status */
    --color-live: #4caf50;
    --color-offline: #f44336;
    --color-warn: #ff9800;
    --color-stale: #ef5350;

    /* Tier badges */
    --tier1-bg: #2e7d32;
    --tier1-text: #ffffff;
    --tier2-bg: #1565c0;
    --tier2-text: #ffffff;
    --tier3-bg: #6a1b9a;
    --tier3-text: #ffffff;

    /* Quick exit */
    --exit-bg: #d32f2f;
    --exit-text: #ffffff;

    /* Buttons */
    --btn-primary-bg: #00337f;
    --btn-primary-text: #ffffff;
    --btn-primary-hover: #004399;
    --btn-save-bg: #2d2d2d;
    --btn-save-text: #e0e0e0;
    --btn-save-border: #555555;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5);

    /* Spacing scale */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-md: 1rem;
    --font-size-lg: 1.25rem;
    --font-size-xl: 1.5rem;
    --font-size-2xl: 2rem;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-bold: 700;

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
}

/* ============================================
   LIGHT THEME
   ============================================ */

[data-theme="light"] {
    /* Background */
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-header: #5e5e5f;
    --bg-card: #f8f8f8;
    --bg-input: #ffffff;
    --bg-hover: #eeeeee;

    /* Text */
    --text-primary: #1a1a1a;
    --text-secondary: #333333;
    --text-muted: #666666;
    --text-link: #00337f;
    --text-link-hover: #004399;

    /* Borders */
    --border-color: #cccccc;
    --border-focus: #0277bd;

    /* Buttons */
    --btn-save-bg: #ffffff;
    --btn-save-text: #333333;
    --btn-save-border: #cccccc;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* ============================================
   AUTO THEME — follows OS preference
   ============================================ */

   @media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
        --bg-primary: #f5f5f5;
        --bg-secondary: #ffffff;
        --bg-header: #2c3e50;
        --bg-card: #f8f8f8;
        --bg-input: #ffffff;
        --bg-hover: #eeeeee;
        --text-primary: #1a1a1a;
        --text-secondary: #333333;
        --text-muted: #666666;
        --text-link: #00337f;
        --text-link-hover: #004399;
        --border-color: #cccccc;
        --border-focus: #0277bd;
        --btn-save-bg: #ffffff;
        --btn-save-text: #333333;
        --btn-save-border: #cccccc;
        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
        --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.12);
        --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
    }
}

.theme-toggle-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px var(--space-md);
    border: 2px solid #ffffff;
    border-radius: 20px;
    cursor: pointer;
    user-select: none;
    transition: background-color var(--transition-fast),
                border-color var(--transition-fast);
}

.theme-toggle-pill input {
    appearance: none;
    width: 36px;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    transition: background-color var(--transition-fast);
    flex-shrink: 0;
}

.theme-toggle-pill input::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background-color: #ffffff;
    border-radius: 50%;
    transition: transform var(--transition-fast);
}

.theme-toggle-pill input:checked {
    background-color: var(--btn-primary-bg);
}

.theme-toggle-pill input:checked::after {
    transform: translateX(16px);
}

.theme-toggle-status {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: #ffffff;
    white-space: nowrap;
}