/**
 * Design Tokens - Sistema Prenotazioni RSA
 * Centralized Design System with Best Practices
 * v2.0 - Enhanced Architecture
 */

:root {
    /* ==========================================================================
       TYPOGRAPHY
       ========================================================================== */
    /* Font Families */
    --font-display: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-body: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'Consolas', 'Monaco', 'Courier New', monospace;

    /* Font Sizes - Refined Scale */
    --font-size-xs: 0.8125rem;  /* 13px - Improved from 12px per leggibilità */
    --font-size-sm: 0.9375rem;  /* 15px - Body secondario */
    --font-size-base: 1rem;     /* 16px - Body primario */
    --font-size-lg: 1.125rem;   /* 18px - Lead text */
    --font-size-xl: 1.375rem;   /* 22px - H3 */
    --font-size-2xl: 1.75rem;   /* 28px - H2 */
    --font-size-3xl: 2.25rem;   /* 36px - H1 */
    --font-size-4xl: 3rem;      /* 48px - Display/KPI */
    --font-size-5xl: 4rem;      /* 64px - Hero numbers */

    /* Font Weights */
    --font-weight-light: 300;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --font-weight-black: 900;

    /* Line Heights - Optimized for readability */
    --line-height-tight: 1.15;
    --line-height-snug: 1.375;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.625;
    --line-height-loose: 1.75;

    /* Letter Spacing */
    --letter-spacing-tighter: -0.04em;
    --letter-spacing-tight: -0.02em;
    --letter-spacing-normal: 0;
    --letter-spacing-wide: 0.025em;
    --letter-spacing-wider: 0.05em;
    --letter-spacing-widest: 0.1em;

    /* ==========================================================================
       SPACING - Enhanced Breathing Room (8px base scale)
       ========================================================================== */
    --spacing-0: 0;
    --spacing-0-5: 0.125rem;  /* 2px */
    --spacing-1: 0.25rem;     /* 4px */
    --spacing-1-5: 0.375rem;  /* 6px */
    --spacing-2: 0.5rem;      /* 8px */
    --spacing-3: 0.75rem;     /* 12px */
    --spacing-4: 1rem;        /* 16px */
    --spacing-5: 1.25rem;     /* 20px */
    --spacing-6: 1.5rem;      /* 24px */
    --spacing-8: 2rem;        /* 32px */
    --spacing-10: 2.5rem;     /* 40px */
    --spacing-12: 3rem;       /* 48px */
    --spacing-16: 4rem;       /* 64px */
    --spacing-20: 5rem;       /* 80px */
    --spacing-24: 6rem;       /* 96px */

    /* ==========================================================================
       COLORS - Primary Palette
       ========================================================================== */
    /* Primary - Facebook Blue */
    --color-primary: #3b5998;           /* Main brand */
    --color-primary-dark: #2d4373;      /* Hover states */
    --color-primary-light: #5875b4;     /* Subtle backgrounds */
    --color-primary-50: rgba(59, 89, 152, 0.05);
    --color-primary-100: rgba(59, 89, 152, 0.1);
    --color-primary-200: rgba(59, 89, 152, 0.2);

    /* Secondary */
    --color-secondary: #42b983;         /* Accent color */
    --color-secondary-dark: #359268;    /* Active state */
    --color-secondary-light: #5ec999;

    /* Semantic Colors - Medical Context */
    --color-success: #0d9488;           /* Teal - cool, harmonizes with navy */
    --color-success-light: #14b8a6;
    --color-success-dark: #0f766e;

    --color-warning: #d97706;           /* Amber deep - white text, no patch */
    --color-warning-light: #fbbf24;
    --color-warning-dark: #b45309;

    --color-danger: #dc2626;            /* Red clean - critical */
    --color-danger-light: #f87171;
    --color-danger-dark: #b91c1c;

    --color-info: #7c3aed;              /* Violet - distinct from primary blue */
    --color-info-light: #a78bfa;
    --color-info-dark: #6d28d9;

    /* Neutral Palette - Enhanced Contrast */
    --color-text-primary: #0f1419;      /* Near-black - Body text */
    --color-text-secondary: #3d4852;    /* Dark gray - Secondary text */
    --color-text-tertiary: #6b7280;     /* Medium gray - Tertiary text */
    --color-text-muted: #9ca3af;        /* Light gray - Subtle text */
    --color-text-disabled: #d1d5db;     /* Very light - Disabled state */
    --color-text-inverse: #ffffff;      /* White - Dark backgrounds */

    /* Background Colors - Layered Depth */
    --color-bg-primary: #ffffff;        /* White - Base layer */
    --color-bg-secondary: #f9fafb;      /* Off-white - Cards */
    --color-bg-tertiary: #f3f4f6;       /* Light gray - Panels */
    --color-bg-quaternary: #e5e7eb;     /* Medium gray - Borders/Dividers */
    --color-bg-overlay: rgba(0, 0, 0, 0.5);  /* Modals */

    /* Surface Colors - Elevated Components */
    --color-surface-raised: #ffffff;
    --color-surface-hover: rgba(59, 89, 152, 0.04);
    --color-surface-active: rgba(59, 89, 152, 0.08);
    --color-surface-selected: rgba(59, 89, 152, 0.12);

    /* Border Colors - Refined Hierarchy */
    --color-border-light: rgba(0, 0, 0, 0.05);      /* Subtle dividers */
    --color-border-medium: rgba(0, 0, 0, 0.1);      /* Default borders */
    --color-border-strong: rgba(0, 0, 0, 0.15);     /* Emphasized borders */
    --color-border-inverse: rgba(255, 255, 255, 0.15);

    /* ==========================================================================
       BADGE COLORS (Appointment States)
       ========================================================================== */
    --badge-pending: var(--color-primary);      /* PENDING - Scheduled */
    --badge-in-progress: var(--color-info);     /* IN_PROGRESS - Active */
    --badge-completed: var(--color-success);    /* COMPLETED - Success */
    --badge-no-show: var(--color-warning);      /* NO_SHOW - Warning */
    --badge-late-cancel: var(--color-danger);   /* LATE_CANCEL - Critical */
    --badge-cancelled: #64748b;                 /* CANCELLED - Slate (cool gray) */
    --badge-expired: #94a3b8;                   /* EXPIRED - Slate muted */

    /* Semantic Badge Aliases (used by badge.css components) */
    --badge-info: var(--color-info);            /* badge--info → violet */
    --badge-success: var(--color-success);      /* badge--success → teal */
    --badge-warning: var(--color-warning);      /* badge--warning → amber */
    --badge-danger: var(--color-danger);        /* badge--danger → red */
    --badge-neutral: #64748b;                   /* badge--neutral → slate */

    /* Badge Background Tints (10% opacity) */
    --badge-pending-bg: rgba(59, 89, 152, 0.1);
    --badge-in-progress-bg: rgba(124, 58, 237, 0.1);
    --badge-completed-bg: rgba(13, 148, 136, 0.1);
    --badge-no-show-bg: rgba(217, 119, 6, 0.1);
    --badge-late-cancel-bg: rgba(220, 38, 38, 0.1);
    --badge-cancelled-bg: rgba(100, 116, 139, 0.1);

    /* ==========================================================================
       SHADOWS - Subtle Medical Depth
       ========================================================================== */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.12);
    --shadow-2xl: 0 24px 64px rgba(0, 0, 0, 0.15);

    /* Colored Shadows - Brand Integration */
    --shadow-primary: 0 4px 16px rgba(59, 89, 152, 0.2);
    --shadow-primary-hover: 0 8px 24px rgba(59, 89, 152, 0.3);
    --shadow-success: 0 4px 12px rgba(15, 153, 96, 0.2);
    --shadow-danger: 0 4px 12px rgba(230, 57, 70, 0.2);

    /* Inner Shadows - Input Fields */
    --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-inner-strong: inset 0 2px 6px rgba(0, 0, 0, 0.1);

    /* ==========================================================================
       BORDER RADIUS
       ========================================================================== */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 9999px;

    /* ==========================================================================
       TRANSITIONS
       ========================================================================== */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
    --transition-smooth: 250ms cubic-bezier(0.4, 0, 0.2, 1);

    /* ==========================================================================
       Z-INDEX LAYERS
       ========================================================================== */
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-toast: 9999;

    /* ==========================================================================
       BREAKPOINTS (per reference in JS)
       ========================================================================== */
    --breakpoint-sm: 576px;
    --breakpoint-md: 768px;
    --breakpoint-lg: 992px;
    --breakpoint-xl: 1200px;
    --breakpoint-xxl: 1400px;

    /* ==========================================================================
       CALENDAR SPECIFIC
       ========================================================================== */
    --calendar-height-mobile: 400px;
    --calendar-height-tablet: 500px;
    --calendar-height-desktop: 650px;
    --calendar-slot-height: 3rem;

    /* Calendar Event Colors - Medical States */
    --calendar-pending: var(--badge-pending);              /* Teal - Scheduled */
    --calendar-completed: var(--color-success);            /* Forest Green - Success */
    --calendar-no-show: var(--color-warning);              /* Amber - Warning */
    --calendar-cancelled: #6b7280;                         /* Gray - Neutral */
    --calendar-late-cancel: var(--color-danger);           /* Red - Critical */
    --calendar-expired: #9ca3af;                           /* Light Gray - Expired */

    /* ==========================================================================
       CARD SPECIFIC
       ========================================================================== */
    --card-padding: var(--spacing-6);
    --card-padding-sm: var(--spacing-4);
    --card-border-width: 1px;
    --card-border-color: var(--color-border-light);

    /* ==========================================================================
       KPI SPECIFIC - Enhanced Hierarchy
       ========================================================================== */
    --kpi-primary-height: 200px;          /* Hero KPI */
    --kpi-secondary-height: 160px;        /* Standard KPI */
    --kpi-compact-height: 120px;          /* Sidebar KPI */

    --kpi-value-primary: var(--font-size-5xl);    /* 64px - Hero numbers */
    --kpi-value-secondary: var(--font-size-4xl);  /* 48px - Standard */
    --kpi-value-compact: var(--font-size-3xl);    /* 36px - Compact */

    --kpi-label-size: var(--font-size-xs);        /* 13px - Uppercase labels */
    --kpi-trend-size: var(--font-size-sm);        /* 15px - Trend indicators */
}

/* ==========================================================================
   DARK MODE
   ========================================================================== */
[data-theme="dark"] {
    /* Primary Colors - Adjusted for Dark */
    --color-primary: #5875b4;               /* Brighter blue for contrast */
    --color-primary-dark: #3b5998;
    --color-primary-light: #7c94c4;

    /* Semantic Colors - Enhanced Contrast for Dark */
    --color-success: #2dd4bf;           /* Teal bright */
    --color-warning: #fbbf24;           /* Amber bright */
    --color-danger: #f87171;            /* Red bright */
    --color-info: #a78bfa;              /* Violet bright */

    /* Text Colors - Inverted */
    --color-text-primary: #f9fafb;          /* Near-white */
    --color-text-secondary: #d1d5db;        /* Light gray */
    --color-text-tertiary: #9ca3af;         /* Medium gray */
    --color-text-muted: #6b7280;            /* Dark gray */
    --color-text-disabled: #4b5563;
    --color-text-inverse: #0f1419;

    /* Background Colors - Dark Layers */
    --color-bg-primary: #0f1419;            /* Near-black base */
    --color-bg-secondary: #1a1f26;          /* Dark gray - Cards */
    --color-bg-tertiary: #252b33;           /* Medium dark - Panels */
    --color-bg-quaternary: #2f3640;         /* Lighter dark - Borders */
    --color-bg-overlay: rgba(0, 0, 0, 0.8);

    /* Surface Colors */
    --color-surface-raised: #1a1f26;
    --color-surface-hover: rgba(88, 117, 180, 0.08);
    --color-surface-active: rgba(88, 117, 180, 0.12);
    --color-surface-selected: rgba(88, 117, 180, 0.16);

    /* Border Colors */
    --color-border-light: rgba(255, 255, 255, 0.08);
    --color-border-medium: rgba(255, 255, 255, 0.12);
    --color-border-strong: rgba(255, 255, 255, 0.16);

    /* Shadows - Enhanced for Dark */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.7);

    --shadow-primary: 0 4px 16px rgba(88, 117, 180, 0.3);
    --shadow-primary-hover: 0 8px 24px rgba(88, 117, 180, 0.4);
}

/* ==========================================================================
   UTILITY CLASSES - Spacing
   ========================================================================== */

.p-token-1 { padding: var(--spacing-1) !important; }
.p-token-2 { padding: var(--spacing-2) !important; }
.p-token-3 { padding: var(--spacing-3) !important; }
.p-token-4 { padding: var(--spacing-4) !important; }
.p-token-6 { padding: var(--spacing-6) !important; }

.m-token-1 { margin: var(--spacing-1) !important; }
.m-token-2 { margin: var(--spacing-2) !important; }
.m-token-3 { margin: var(--spacing-3) !important; }
.m-token-4 { margin: var(--spacing-4) !important; }
.m-token-6 { margin: var(--spacing-6) !important; }

/* Gap utilities */
.gap-token-1 { gap: var(--spacing-1) !important; }
.gap-token-2 { gap: var(--spacing-2) !important; }
.gap-token-3 { gap: var(--spacing-3) !important; }
.gap-token-4 { gap: var(--spacing-4) !important; }

/* ==========================================================================
   UTILITY CLASSES - Typography
   ========================================================================== */

.text-xs { font-size: var(--font-size-xs) !important; }
.text-sm { font-size: var(--font-size-sm) !important; }
.text-base { font-size: var(--font-size-base) !important; }
.text-lg { font-size: var(--font-size-lg) !important; }
.text-xl { font-size: var(--font-size-xl) !important; }

.font-medium { font-weight: var(--font-weight-medium) !important; }
.font-semibold { font-weight: var(--font-weight-semibold) !important; }
.font-bold { font-weight: var(--font-weight-bold) !important; }

/* ==========================================================================
   UTILITY CLASSES - Shadows
   ========================================================================== */

.shadow-token-sm { box-shadow: var(--shadow-sm) !important; }
.shadow-token-md { box-shadow: var(--shadow-md) !important; }
.shadow-token-lg { box-shadow: var(--shadow-lg) !important; }

/* ==========================================================================
   UTILITY CLASSES - Border Radius
   ========================================================================== */

.rounded-token-md { border-radius: var(--radius-md) !important; }
.rounded-token-lg { border-radius: var(--radius-lg) !important; }
.rounded-token-xl { border-radius: var(--radius-xl) !important; }

/* ==========================================================================
   TYPOGRAPHY APPLICATION - Global Styles
   ========================================================================== */

/* Body Text - Medical-Grade Legibility */
body {
    font-family: var(--font-body);
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    color: var(--color-text-primary);
    background-color: var(--color-bg-primary);
    font-weight: var(--font-weight-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Headings - Distinctive Serif Hierarchy */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--font-display);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    letter-spacing: var(--letter-spacing-tight);
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-4);
}

h1, .h1 {
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-black);
    letter-spacing: var(--letter-spacing-tighter);
}

h2, .h2 {
    font-size: var(--font-size-2xl);
}

h3, .h3 {
    font-size: var(--font-size-xl);
}

h4, .h4 {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
}

h5, .h5 {
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
}

h6, .h6 {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wider);
}

/* Dashboard Titles - Special Treatment */
.dashboard-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: var(--font-weight-black);
    letter-spacing: var(--letter-spacing-tighter);
    line-height: var(--line-height-tight);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* KPI Values - Tabular Numerals */
.kpi-value,
.kpi-value-enterprise,
.kpi-value-primary {
    font-family: var(--font-display);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

/* Monospace - Data Display */
.font-mono,
code,
pre {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* Link Styles - Medical Context */
a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

a:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 4px;
    border-radius: var(--radius-sm);
}
