/**
 * GRIDLY CLOUD — DESIGN TOKENS
 * ================================
 * Unified token system shared with main Gridly app.
 * Same variable names, same semantics — consistent brand across products.
 * See DESIGN_SYSTEM.md for complete documentation.
 *
 * Dark mode = :root (default)
 * Light mode = [data-theme="light"]
 */

/* ==========================================================================
   CASCADE LAYERS — prioritet: base < components < utilities
   ========================================================================== */
@layer base, components, utilities;

/* ==========================================================================
   DARK THEME (Default)
   ========================================================================== */
:root {
    color-scheme: dark;

    /* Backgrounds */
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-card: #141414;
    --bg-tertiary: #252525;
    --bg-elevated: #1f1f1f;

    /* Text */
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #888888;
    --text-inverted: #0a0a0a;

    /* Brand (identical in both modes) */
    --brand-solar: #FFB800;
    --brand-solar-dim: #CC9500;
    --brand-solar-glow: rgba(255, 184, 0, 0.4);
    --brand-battery: #00D4AA;
    --brand-battery-dim: #00A888;
    --brand-battery-glow: rgba(0, 212, 170, 0.4);
    --brand-grid: #7C7C7C;
    --brand-grid-dim: #5C5C5C;
    --brand-home: #4A90E2;
    --brand-home-dim: #3A70B2;
    --brand-home-glow: rgba(74, 144, 226, 0.4);

    /* Status — base colors only; use color-mix() for bg/border */
    --status-success: #4CAF50;
    --status-warning: #FF9800;
    --status-error: #f44336;
    --status-info: #2196F3;

    /* States */
    --state-positive: #00D4AA;
    --state-negative: #ff6b6b;
    --state-neutral: #a0a0a0;
    --state-active: #FFB800;
    --state-disabled: #444444;
    --state-hover: #333333;

    /* UI */
    --ui-border: #2a2a2a;
    --ui-border-light: rgba(255, 255, 255, 0.1);
    --ui-border-focus: #FFB800;
    --ui-shadow: rgba(0, 0, 0, 0.3);
    --ui-shadow-heavy: rgba(0, 0, 0, 0.5);
    --ui-shadow-glow: rgba(255, 184, 0, 0.3);
    --ui-overlay: rgba(0, 0, 0, 0.6);
    --ui-focus-ring: rgba(255, 184, 0, 0.3);
    --ui-focus-ring-battery: rgba(0, 212, 170, 0.2);

    /* Highlights */
    --ui-highlight-subtle: rgba(255, 255, 255, 0.05);
    --ui-highlight: rgba(255, 255, 255, 0.1);
    --ui-highlight-strong: rgba(255, 255, 255, 0.2);

    /* Links */
    --link-color: #3b82f6;
    --link-color-hover: #60a5fa;

    /* Button primary (solar-gul across all products) */
    --btn-primary-bg: var(--brand-solar);
    --btn-primary-hover: var(--brand-solar-dim);
    --btn-primary-text: #000000;

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

    /* Shadows */
    --ui-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --ui-shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.2);
    --ui-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.2);
    --ui-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.3);
    --ui-shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.5);

    /* Z-index */
    --z-base: 1;
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-toast: 1080;

    /* Line-height */
    --leading-none: 1;
    --leading-tight: 1.2;
    --leading-normal: 1.5;
    --leading-relaxed: 1.6;

    /* Typography (fluid) */
    --font-size-xs: clamp(0.6rem, 0.55rem + 0.15vw, 0.65rem);
    --font-size-sm: clamp(0.7rem, 0.65rem + 0.15vw, 0.75rem);
    --font-size-base: clamp(0.8rem, 0.75rem + 0.2vw, 0.875rem);
    --font-size-md: clamp(0.9rem, 0.85rem + 0.2vw, 1rem);
    --font-size-lg: clamp(1rem, 0.95rem + 0.2vw, 1.125rem);
    --font-size-xl: clamp(1.1rem, 1rem + 0.3vw, 1.25rem);
    --font-size-2xl: clamp(1.25rem, 1.1rem + 0.4vw, 1.5rem);
    --font-size-3xl: clamp(1.5rem, 1.3rem + 0.5vw, 2rem);

    /* Layout */
    --radius-xs: 3px;
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 9999px;
    --radius-circle: 50%;

    /* Transitions (explicit properties — avoid animating layout properties) */
    --transition-fast: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    --transition-normal: color 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: color 0.5s ease, background-color 0.5s ease, border-color 0.5s ease, opacity 0.5s ease, transform 0.5s ease, box-shadow 0.5s ease;

    /* Scrollbar */
    --scrollbar-track: transparent;
    --scrollbar-thumb: rgba(255, 255, 255, 0.15);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.25);

    /* Portal: Role badges */
    --role-admin-bg: #1a1533;
    --role-admin-text: #a5b4fc;
    --role-installer-bg: #0a2a2e;
    --role-installer-text: #67e8f9;
    --role-user-bg: #0a1a2e;
    --role-user-text: #93c5fd;

    /* Portal: Action badges */
    --action-user-bg: #0a1a2e;
    --action-user-text: #93c5fd;
    --action-device-bg: #0a2a1a;
    --action-device-text: #4ade80;
    --action-license-bg: #2a1a0a;
    --action-license-text: #fbbf24;
    --action-command-bg: #1a1533;
    --action-command-text: #a5b4fc;
}

/* ==========================================================================
   LIGHT THEME
   ========================================================================== */
[data-theme="light"] {
    color-scheme: light;

    /* Backgrounds */
    --bg-primary: #f8f9fa;
    --bg-secondary: #f0f0f0;
    --bg-card: #ffffff;
    --bg-tertiary: #e8e8e8;
    --bg-elevated: #ffffff;

    /* Text */
    --text-primary: #1a1a2e;
    --text-secondary: #555555;
    --text-muted: #888888;
    --text-inverted: #ffffff;

    /* Brand — unchanged (work on both backgrounds) */

    /* Status — darker for WCAG AA contrast on white */
    --status-success: #2E7D32;
    --status-warning: #E65100;
    --status-error: #C62828;
    --status-info: #1565C0;

    /* States */
    --state-positive: #2E7D32;
    --state-negative: #C62828;
    --state-neutral: #666666;
    --state-active: #FFB800;
    --state-disabled: #cccccc;
    --state-hover: #e8e8e8;

    /* UI */
    --ui-border: #e0e0e0;
    --ui-border-light: rgba(0, 0, 0, 0.08);
    --ui-border-focus: #FFB800;
    --ui-shadow: rgba(0, 0, 0, 0.08);
    --ui-shadow-heavy: rgba(0, 0, 0, 0.15);
    --ui-shadow-glow: rgba(255, 184, 0, 0.2);
    --ui-overlay: rgba(0, 0, 0, 0.4);
    --ui-focus-ring: rgba(255, 184, 0, 0.3);
    --ui-focus-ring-battery: rgba(0, 212, 170, 0.15);

    /* Highlights */
    --ui-highlight-subtle: rgba(0, 0, 0, 0.03);
    --ui-highlight: rgba(0, 0, 0, 0.06);
    --ui-highlight-strong: rgba(0, 0, 0, 0.12);

    /* Links */
    --link-color: #2563eb;
    --link-color-hover: #1d4ed8;

    /* Shadows — lower opacity for light backgrounds */
    --ui-shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --ui-shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.08);
    --ui-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --ui-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
    --ui-shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.15);

    /* Portal: Role badges (lighter backgrounds) */
    --role-admin-bg: #e8e5ff;
    --role-admin-text: #4338ca;
    --role-installer-bg: #d5f5f6;
    --role-installer-text: #0e7490;
    --role-user-bg: #dbeafe;
    --role-user-text: #1d4ed8;

    /* Portal: Action badges */
    --action-user-bg: #dbeafe;
    --action-user-text: #1d4ed8;
    --action-device-bg: #dcfce7;
    --action-device-text: #166534;
    --action-license-bg: #fef3c7;
    --action-license-text: #92400e;
    --action-command-bg: #e8e5ff;
    --action-command-text: #4338ca;

    /* Scrollbar */
    --scrollbar-track: #f0f0f0;
    --scrollbar-thumb: #cccccc;
    --scrollbar-thumb-hover: #999999;
}

/* ==========================================================================
   UTILITY CLASSES — @layer utilities wins over components
   ========================================================================== */
@layer utilities {

/* Text Colors */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--status-success); }
.text-warning { color: var(--status-warning); }
.text-error { color: var(--status-error); }
.text-info { color: var(--status-info); }

/* Background Colors */
.bg-primary { background-color: var(--bg-primary); }
.bg-secondary { background-color: var(--bg-secondary); }
.bg-card { background-color: var(--bg-card); }

/* Status Backgrounds — color-mix() */
.bg-success {
    background-color: color-mix(in srgb, var(--status-success) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--status-success) 30%, transparent);
}
.bg-warning {
    background-color: color-mix(in srgb, var(--status-warning) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--status-warning) 30%, transparent);
}
.bg-error {
    background-color: color-mix(in srgb, var(--status-error) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--status-error) 30%, transparent);
}
.bg-info {
    background-color: color-mix(in srgb, var(--status-info) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--status-info) 30%, transparent);
}

} /* end @layer utilities */
