/* ============================================================================
   HomeoAI -- Unified Design System v1.0
   Clinical, professional, modern -- teal/indigo color scheme
   Light mode default with dark mode support
   Glassmorphism card style
   ============================================================================ */


/* ============================================================================
   1. DESIGN TOKENS (CSS Custom Properties)
   ============================================================================ */
:root {
    /* -- Canvas / Background -- */
    --bg-canvas: #F0F4F8;
    --bg-page: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-sidebar: #F1F5F9;
    --bg-input: #F8FAFC;
    --bg-hover: #E2E8F0;

    /* -- Glass -- */
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-blur: 16px;
    --glass-border: rgba(255, 255, 255, 0.6);

    /* -- Primary: Teal (clinical, calm) -- */
    --primary: #0D9488;
    --primary-dark: #0F766E;
    --primary-light: #5EEAD4;
    --primary-bg: #F0FDFA;

    /* -- Accent: Indigo (AI elements) -- */
    --accent: #6366F1;
    --accent-dark: #4F46E5;
    --accent-light: #A5B4FC;
    --accent-bg: #EEF2FF;

    /* -- Gradients -- */
    --grad-primary: linear-gradient(135deg, #0D9488 0%, #6366F1 100%);
    --grad-accent: linear-gradient(135deg, #6366F1 0%, #A855F7 100%);

    /* -- Confidence levels -- */
    --confidence-high: #059669;
    --confidence-mid: #D97706;
    --confidence-low: #DC2626;

    /* -- Remedy grades -- */
    --grade-4: #7C3AED;
    --grade-3: #2563EB;
    --grade-2: #0891B2;
    --grade-1: #94A3B8;

    /* -- Semantic -- */
    --success: #059669;
    --success-bg: #ECFDF5;
    --warning: #D97706;
    --warning-bg: #FFFBEB;
    --error: #DC2626;
    --error-bg: #FEF2F2;
    --info: #0284C7;
    --info-bg: #F0F9FF;

    /* -- Text -- */
    --text-primary: #1E293B;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --text-inverse: #FFFFFF;

    /* -- Borders & Shadows -- */
    --border: #E2E8F0;
    --border-focus: var(--primary);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.12);
    --shadow-glow-primary: 0 0 20px rgba(13, 148, 136, 0.15);
    --shadow-glow-accent: 0 0 20px rgba(99, 102, 241, 0.15);

    /* -- Spacing -- */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 20px;
    --sp-6: 24px;
    --sp-8: 32px;
    --sp-10: 40px;
    --sp-12: 48px;
    --sp-16: 64px;

    /* -- Typography -- */
    --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --fs-xs: 0.75rem;
    --fs-sm: 0.875rem;
    --fs-base: 1rem;
    --fs-lg: 1.125rem;
    --fs-xl: 1.25rem;
    --fs-2xl: 1.5rem;
    --fs-3xl: 2rem;
    --fs-4xl: 2.5rem;

    --fw-normal: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;

    /* -- Border radius -- */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-pill: 9999px;

    /* -- Z-Index Layers -- */
    --z-dropdown: 1000;
    --z-sticky: 1100;
    --z-nav: 2000;
    --z-overlay: 2500;
    --z-modal: 3000;
    --z-toast: 4000;
    --z-tooltip: 5000;

    /* -- Transitions -- */
    --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.175, 0.885, 0.32, 1.1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;

    /* -- Sidebar -- */
    --sidebar-width: 220px;
    --sidebar-collapsed: 56px;
}


/* -- Dark Mode -- */
[data-theme="dark"] {
    --bg-canvas: #0B1120;
    --bg-page: #111827;
    --bg-card: #1E293B;
    --bg-sidebar: #0F172A;
    --bg-input: #1E293B;
    --bg-hover: #334155;

    --glass-bg: rgba(15, 23, 42, 0.85);
    --glass-blur: 20px;
    --glass-border: rgba(255, 255, 255, 0.08);

    --text-primary: #F1F5F9;
    --text-secondary: #CBD5E1;
    --text-muted: #64748B;

    --border: #334155;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.6);

    --primary-bg: #042F2E;
    --accent-bg: #1E1B4B;

    --success-bg: rgba(5, 150, 105, 0.12);
    --warning-bg: rgba(217, 119, 6, 0.12);
    --error-bg: rgba(220, 38, 38, 0.12);
    --info-bg: rgba(2, 132, 199, 0.12);
}


/* ============================================================================
   2. BASE RESET
   ============================================================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-canvas);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: var(--fs-base);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

img, svg {
    display: block;
    max-width: 100%;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
    color: var(--primary-dark);
}

ul, ol {
    list-style: none;
}


/* ============================================================================
   3. TYPOGRAPHY
   ============================================================================ */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: var(--fw-semibold);
    line-height: 1.3;
    margin: 0;
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
h5 { font-size: var(--fs-base); }
h6 { font-size: var(--fs-sm); }

p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin: 0;
}

.text-xs { font-size: var(--fs-xs); }
.text-sm { font-size: var(--fs-sm); }
.text-base { font-size: var(--fs-base); }
.text-lg { font-size: var(--fs-lg); }
.text-xl { font-size: var(--fs-xl); }
.text-2xl { font-size: var(--fs-2xl); }
.text-3xl { font-size: var(--fs-3xl); }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-teal { color: var(--primary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }

.fw-normal { font-weight: var(--fw-normal); }
.fw-medium { font-weight: var(--fw-medium); }
.fw-semibold { font-weight: var(--fw-semibold); }
.fw-bold { font-weight: var(--fw-bold); }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.mono { font-family: var(--font-mono); }
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* ============================================================================
   4. LAYOUT UTILITIES
   ============================================================================ */

/* -- Page layout with sidebar -- */
.page-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: var(--sp-8);
    transition: margin-left var(--duration-normal) var(--ease-out);
}

.sidebar-collapsed .page-wrapper {
    margin-left: var(--sidebar-collapsed);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-8);
    flex-wrap: wrap;
    gap: var(--sp-4);
}

.page-header h1 {
    font-size: var(--fs-2xl);
    font-weight: var(--fw-bold);
}

.page-title-sub {
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-weight: var(--fw-normal);
    margin-top: var(--sp-1);
}

/* -- Flex utilities -- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }

.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.justify-start { justify-content: flex-start; }

.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); }
.gap-6 { gap: var(--sp-6); }
.gap-8 { gap: var(--sp-8); }

/* -- Grid utilities -- */
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* -- Spacing -- */
.m-0 { margin: 0; }
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mb-1 { margin-bottom: var(--sp-1); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }

.p-0 { padding: 0; }
.p-2 { padding: var(--sp-2); }
.p-3 { padding: var(--sp-3); }
.p-4 { padding: var(--sp-4); }
.p-5 { padding: var(--sp-5); }
.p-6 { padding: var(--sp-6); }
.p-8 { padding: var(--sp-8); }
.px-4 { padding-left: var(--sp-4); padding-right: var(--sp-4); }
.px-6 { padding-left: var(--sp-6); padding-right: var(--sp-6); }
.py-2 { padding-top: var(--sp-2); padding-bottom: var(--sp-2); }
.py-3 { padding-top: var(--sp-3); padding-bottom: var(--sp-3); }
.py-4 { padding-top: var(--sp-4); padding-bottom: var(--sp-4); }

/* -- Display -- */
.block { display: block; }
.inline-block { display: inline-block; }
.inline-flex { display: inline-flex; }
.hidden { display: none; }

/* -- Width -- */
.w-full { width: 100%; }
.w-auto { width: auto; }
.max-w-sm { max-width: 384px; }
.max-w-md { max-width: 448px; }
.max-w-lg { max-width: 512px; }
.max-w-xl { max-width: 640px; }
.max-w-2xl { max-width: 768px; }
.max-w-4xl { max-width: 1024px; }
.max-w-6xl { max-width: 1152px; }

/* -- Position -- */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; top: 0; }

/* -- Overflow -- */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-y-auto { overflow-y: auto; }

/* -- Cursor -- */
.cursor-pointer { cursor: pointer; }


/* ============================================================================
   5. CARDS (Glassmorphism)
   ============================================================================ */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--sp-6);
    transition: box-shadow var(--duration-normal) var(--ease-out),
                transform var(--duration-normal) var(--ease-out);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-sm {
    padding: var(--sp-4);
    border-radius: var(--radius-md);
}

.card-lg {
    padding: var(--sp-8);
    border-radius: var(--radius-xl);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-5);
    padding-bottom: var(--sp-4);
    border-bottom: 1px solid var(--border);
}

.card-header h2,
.card-header h3 {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
}

.card-body {
    flex: 1;
}

.card-footer {
    margin-top: var(--sp-5);
    padding-top: var(--sp-4);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-3);
}

.card-clickable {
    cursor: pointer;
}

.card-clickable:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Solid card variant (no glass) */
.card-solid {
    background: var(--bg-card);
    backdrop-filter: none;
    border: 1px solid var(--border);
}


/* ============================================================================
   6. BUTTONS
   ============================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    line-height: 1;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    white-space: nowrap;
    text-decoration: none;
    user-select: none;
    outline: none;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Primary */
.btn-primary {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: var(--shadow-glow-primary);
}

/* Secondary */
.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

/* Accent */
.btn-accent {
    background: var(--accent);
    color: var(--text-inverse);
    border-color: var(--accent);
}

.btn-accent:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    box-shadow: var(--shadow-glow-accent);
}

/* Danger */
.btn-danger {
    background: var(--error);
    color: var(--text-inverse);
    border-color: var(--error);
}

.btn-danger:hover {
    background: #B91C1C;
    border-color: #B91C1C;
}

/* Ghost */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Sizes */
.btn-sm {
    padding: 6px 12px;
    font-size: var(--fs-xs);
    border-radius: var(--radius-sm);
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: var(--fs-base);
    border-radius: var(--radius-lg);
}

.btn-icon {
    padding: 8px;
    border-radius: var(--radius-md);
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

/* Button group */
.btn-group {
    display: inline-flex;
    gap: 0;
}

.btn-group .btn {
    border-radius: 0;
}

.btn-group .btn:first-child {
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.btn-group .btn:last-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.btn-group .btn + .btn {
    margin-left: -1px;
}


/* ============================================================================
   7. FORM INPUTS
   ============================================================================ */
.form-group {
    margin-bottom: var(--sp-5);
}

.form-label {
    display: block;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--text-secondary);
    margin-bottom: var(--sp-2);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font);
    font-size: var(--fs-sm);
    line-height: 1.5;
    transition: border-color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-input-sm {
    padding: 6px 10px;
    font-size: var(--fs-xs);
}

.form-hint {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-top: var(--sp-1);
}

.form-error {
    font-size: var(--fs-xs);
    color: var(--error);
    margin-top: var(--sp-1);
}

.form-input.is-error,
.form-select.is-error {
    border-color: var(--error);
}

.form-input.is-error:focus {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

/* Checkbox and Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border);
    border-radius: var(--radius-pill);
    transition: background var(--duration-fast) var(--ease-out);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform var(--duration-fast) var(--ease-out);
    box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}


/* ============================================================================
   8. BADGES
   ============================================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    border-radius: var(--radius-pill);
    white-space: nowrap;
    line-height: 1.4;
}

.badge-primary {
    background: var(--primary-bg);
    color: var(--primary-dark);
}

.badge-accent {
    background: var(--accent-bg);
    color: var(--accent-dark);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-error {
    background: var(--error-bg);
    color: var(--error);
}

.badge-neutral {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}


/* ============================================================================
   9. TABLES
   ============================================================================ */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}

thead {
    background: var(--bg-sidebar);
}

thead th {
    padding: var(--sp-3) var(--sp-4);
    text-align: left;
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: var(--bg-hover);
}

tbody tr.clickable {
    cursor: pointer;
}


/* ============================================================================
   10. MODALS
   ============================================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-normal) var(--ease-out),
                visibility var(--duration-normal) var(--ease-out);
    padding: var(--sp-6);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95) translateY(10px);
    transition: transform var(--duration-normal) var(--ease-bounce);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-5) var(--sp-6);
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--sp-6);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-6);
    border-top: 1px solid var(--border);
}


/* ============================================================================
   11. TOASTS
   ============================================================================ */
.toast-container {
    position: fixed;
    top: var(--sp-6);
    right: var(--sp-6);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 320px;
    max-width: 420px;
    pointer-events: auto;
    animation: toastSlideIn var(--duration-normal) var(--ease-bounce);
    transition: opacity var(--duration-normal) var(--ease-out),
                transform var(--duration-normal) var(--ease-out);
}

.toast.removing {
    opacity: 0;
    transform: translateX(100%);
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
}

.toast-message {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    margin-top: 2px;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    flex-shrink: 0;
}

.toast-close:hover {
    color: var(--text-primary);
}

.toast-success { border-left: 3px solid var(--success); }
.toast-success .toast-icon { color: var(--success); }

.toast-error { border-left: 3px solid var(--error); }
.toast-error .toast-icon { color: var(--error); }

.toast-info { border-left: 3px solid var(--info); }
.toast-info .toast-icon { color: var(--info); }

.toast-warning { border-left: 3px solid var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}


/* ============================================================================
   12. LOADING SPINNERS & SKELETONS
   ============================================================================ */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-hover) 25%,
        var(--border) 37%,
        var(--bg-hover) 63%
    );
    background-size: 200% 100%;
    animation: skeletonPulse 1.5s ease infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 14px;
    margin-bottom: var(--sp-2);
    border-radius: var(--radius-sm);
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-heading {
    height: 24px;
    width: 50%;
    margin-bottom: var(--sp-4);
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-card {
    height: 120px;
    border-radius: var(--radius-lg);
}

.skeleton-row {
    height: 48px;
    margin-bottom: var(--sp-2);
    border-radius: var(--radius-sm);
}

@keyframes skeletonPulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Loading overlay */
.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--sp-4);
    padding: var(--sp-12);
    color: var(--text-muted);
    font-size: var(--fs-sm);
}


/* ============================================================================
   13. DIVIDERS & SEPARATORS
   ============================================================================ */
.divider {
    height: 1px;
    background: var(--border);
    margin: var(--sp-6) 0;
}

.divider-sm {
    margin: var(--sp-3) 0;
}

.divider-vertical {
    width: 1px;
    height: 100%;
    background: var(--border);
}


/* ============================================================================
   14. SCROLLBAR STYLING
   ============================================================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}


/* ============================================================================
   15. TRANSITIONS & ANIMATIONS
   ============================================================================ */
.fade-in {
    animation: fadeIn var(--duration-normal) var(--ease-out);
}

.slide-up {
    animation: slideUp var(--duration-normal) var(--ease-out);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.transition-all {
    transition: all var(--duration-normal) var(--ease-out);
}


/* ============================================================================
   16. RESPONSIVE BREAKPOINTS
   ============================================================================ */
@media (max-width: 1024px) {
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-wrapper {
        padding: var(--sp-5);
    }
}

@media (max-width: 768px) {
    .grid-cols-4,
    .grid-cols-3,
    .grid-cols-2 {
        grid-template-columns: 1fr;
    }

    .page-wrapper {
        margin-left: 0;
        padding: var(--sp-4);
        padding-bottom: 80px;
    }

    .sidebar-collapsed .page-wrapper {
        margin-left: 0;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .hide-mobile {
        display: none !important;
    }

    .modal {
        max-width: 100%;
        margin: var(--sp-4);
    }

    .toast-container {
        left: var(--sp-4);
        right: var(--sp-4);
    }

    .toast {
        min-width: auto;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .btn {
        padding: 8px 14px;
        font-size: var(--fs-xs);
    }

    .card {
        padding: var(--sp-4);
    }

    .page-wrapper {
        padding: var(--sp-3);
    }
}
