/* =============================================
   VitaTrack Design System
   Premium Health Dashboard UI
   ============================================= */

/* === Google Fonts === */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* === CSS Variables — Design Tokens === */
:root {
    /* Primary Colors — Medical Mint */
    --primary-50: hsl(165, 80%, 95%);
    --primary-100: hsl(165, 75%, 85%);
    --primary-200: hsl(165, 70%, 70%);
    --primary-300: hsl(165, 70%, 55%);
    --primary-400: hsl(165, 75%, 42%);
    --primary-500: hsl(165, 80%, 35%);
    --primary-600: hsl(165, 85%, 28%);

    /* Secondary Colors — Trust Blue */
    --secondary-50: hsl(220, 70%, 95%);
    --secondary-100: hsl(220, 65%, 85%);
    --secondary-200: hsl(220, 60%, 70%);
    --secondary-300: hsl(220, 65%, 55%);
    --secondary-400: hsl(220, 70%, 45%);
    --secondary-500: hsl(220, 75%, 38%);

    /* Accent — Warm Gold */
    --accent-400: hsl(40, 95%, 55%);
    --accent-500: hsl(40, 95%, 48%);

    /* Semantic Colors */
    --success: hsl(150, 70%, 42%);
    --success-bg: hsl(150, 60%, 95%);
    --warning: hsl(38, 92%, 50%);
    --warning-bg: hsl(38, 80%, 95%);
    --danger: hsl(0, 72%, 55%);
    --danger-bg: hsl(0, 60%, 95%);
    --info: hsl(210, 70%, 55%);
    --info-bg: hsl(210, 60%, 95%);

    /* Dark Theme — Background Layers */
    --bg-base: hsl(220, 25%, 7%);
    --bg-surface: hsl(220, 22%, 11%);
    --bg-elevated: hsl(220, 20%, 15%);
    --bg-card: hsl(220, 18%, 13%);
    --bg-hover: hsl(220, 18%, 18%);

    /* Glass Effect */
    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-hover: rgba(255, 255, 255, 0.08);

    /* Text Colors */
    --text-primary: hsl(0, 0%, 95%);
    --text-secondary: hsl(220, 15%, 65%);
    --text-muted: hsl(220, 12%, 45%);
    --text-inverse: hsl(220, 25%, 7%);

    /* Border & Shadow */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.15);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(52, 211, 153, 0.15);

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

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

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Typography Scale */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;
}

/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === Typography === */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }

a {
    color: var(--primary-300);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-200);
}

/* === Utility Classes === */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.hidden { display: none !important; }

/* === Glass Card Component === */
.card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition: all var(--transition-base);
}

.card:hover {
    background: var(--glass-hover);
    border-color: var(--border-default);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.card-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
}

/* === Button Component === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: 'Inter', sans-serif;
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    outline: none;
    text-decoration: none;
    line-height: 1;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-400), var(--primary-500));
    color: white;
    box-shadow: 0 4px 15px rgba(52, 211, 153, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-300), var(--primary-400));
    box-shadow: 0 6px 20px rgba(52, 211, 153, 0.35);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--glass-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}

.btn-secondary:hover {
    background: var(--glass-hover);
    border-color: var(--border-strong);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), hsl(0, 72%, 45%));
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--glass-bg);
    color: var(--text-primary);
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: var(--text-base);
    border-radius: var(--radius-lg);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: var(--text-xs);
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* === Form Components === */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.form-input,
.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: var(--text-base);
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.15);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-select option {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* Radio & Checkbox Groups */
.radio-group,
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.radio-option,
.checkbox-option {
    position: relative;
}

.radio-option input[type="radio"],
.checkbox-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-option label,
.checkbox-option label {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.radio-option input[type="radio"]:checked + label,
.checkbox-option input[type="checkbox"]:checked + label {
    background: rgba(52, 211, 153, 0.1);
    border-color: var(--primary-400);
    color: var(--primary-300);
}

.radio-option label:hover,
.checkbox-option label:hover {
    border-color: var(--border-default);
    background: var(--glass-bg);
}

/* === Toggle Switch === */
.toggle-container {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.toggle-switch {
    position: relative;
    width: 200px;
    height: 44px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    cursor: pointer;
    overflow: hidden;
}

.toggle-switch .toggle-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(50% - 4px);
    height: calc(100% - 6px);
    background: linear-gradient(135deg, var(--primary-400), var(--primary-500));
    border-radius: var(--radius-full);
    transition: transform var(--transition-base);
    z-index: 1;
}

.toggle-switch.active .toggle-slider {
    transform: translateX(calc(100% + 2px));
}

.toggle-switch .toggle-labels {
    display: flex;
    height: 100%;
    position: relative;
    z-index: 2;
}

.toggle-switch .toggle-label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-muted);
    transition: color var(--transition-base);
}

.toggle-switch .toggle-label.active {
    color: white;
}

/* === Badge / Tag Component === */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

/* === KPI Card === */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-lg);
}

.kpi-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    backdrop-filter: blur(16px);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-400), var(--secondary-300));
}

.kpi-card .kpi-icon {
    font-size: var(--text-2xl);
    margin-bottom: var(--space-sm);
}

.kpi-card .kpi-value {
    font-size: var(--text-3xl);
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-300), var(--secondary-300));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
}

.kpi-card .kpi-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

/* === Health Score Ring === */
.health-score-ring {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 0 auto;
}

.health-score-ring svg {
    transform: rotate(-90deg);
}

.health-score-ring .score-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.health-score-ring .score-number {
    font-size: var(--text-4xl);
    font-weight: 800;
    line-height: 1;
}

.health-score-ring .score-label {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-top: 4px;
}

/* === Alert/Warning Component === */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-lg);
    border-radius: var(--radius-md);
    border-left: 4px solid;
    margin-bottom: var(--space-md);
}

.alert-success {
    background: var(--success-bg);
    border-color: var(--success);
    color: var(--success);
}

.alert-warning {
    background: var(--warning-bg);
    border-color: var(--warning);
    color: hsl(38, 60%, 30%);
}

.alert-danger {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: hsl(0, 50%, 30%);
}

.alert-info {
    background: var(--info-bg);
    border-color: var(--info);
    color: hsl(210, 50%, 30%);
}

.alert-icon {
    font-size: var(--text-xl);
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    font-size: var(--text-sm);
    margin-bottom: 2px;
}

.alert-message {
    font-size: var(--text-sm);
    opacity: 0.9;
}

/* === Skeleton Loading === */
.skeleton {
    background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* === Toast Notification (Top-Center Screen Position) === */
.toast-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
    width: auto;
    max-width: 90vw;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 15px rgba(245, 158, 11, 0.15);
    min-width: 320px;
    max-width: 520px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
    animation: toastSlideDown 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast .toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast .toast-message {
    flex-grow: 1;
}

.toast.toast-exit {
    animation: toastSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toastSlideDown {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toastSlideUp {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(-30px); opacity: 0; }
}

/* === Upload Zone === */
.upload-zone {
    border: 2px dashed var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-3xl);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary-400);
    background: rgba(52, 211, 153, 0.05);
}

.upload-zone .upload-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.6;
}

.upload-zone .upload-text {
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.upload-zone .upload-text strong {
    color: var(--primary-300);
}

/* === Progress Bar === */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar .progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--primary-400), var(--secondary-300));
    transition: width var(--transition-slow);
}

/* === Table === */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
    font-size: var(--text-sm);
}

.table th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table tr:hover td {
    background: var(--glass-bg);
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* === Page Transition === */
.page-enter {
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === Responsive === */
@media (max-width: 768px) {
    :root {
        --text-4xl: 1.75rem;
        --text-3xl: 1.5rem;
        --text-2xl: 1.25rem;
    }

    .container {
        padding: 0 var(--space-md);
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .card {
        padding: var(--space-lg);
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}
