/* ============================================================
   PathAI - Design System & Global Styles
   ============================================================ */

:root {
    /* Primary - Blue */
    --primary-50: #eff8ff;
    --primary-100: #dbeffe;
    --primary-200: #bfe3fe;
    --primary-300: #93d2fd;
    --primary-400: #60b8fa;
    --primary-500: #3b9cf6;
    --primary-600: #257eeb;
    --primary-700: #1d67d8;
    --primary-800: #1e54af;
    --primary-900: #1e488a;

    /* Secondary - Green */
    --secondary-50: #f0fdf5;
    --secondary-100: #dcfce8;
    --secondary-200: #bbf7d1;
    --secondary-300: #86efad;
    --secondary-400: #4ade80;
    --secondary-500: #22c55e;
    --secondary-600: #16a34a;
    --secondary-700: #15803d;

    /* Accent - Orange */
    --accent-50: #fff8ed;
    --accent-100: #ffeed4;
    --accent-400: #ff9838;
    --accent-500: #fe7a11;
    --accent-600: #ef5f07;

    /* Success */
    --success-50: #f0fdf4;
    --success-100: #dcfce7;
    --success-500: #22c55e;
    --success-600: #16a34a;
    --success-700: #15803d;

    /* Warning */
    --warning-50: #fffbeb;
    --warning-100: #fef3c7;
    --warning-500: #f59e0b;
    --warning-600: #d97706;
    --warning-700: #b45309;

    /* Error */
    --error-50: #fef2f2;
    --error-100: #fee2e2;
    --error-500: #ef4444;
    --error-600: #dc2626;
    --error-700: #b91c1c;

    /* Neutral */
    --neutral-50: #f8fafc;
    --neutral-100: #f1f5f9;
    --neutral-200: #e2e8f0;
    --neutral-300: #cbd5e1;
    --neutral-400: #94a3b8;
    --neutral-500: #64748b;
    --neutral-600: #475569;
    --neutral-700: #334155;
    --neutral-800: #1e293b;
    --neutral-900: #0f172a;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-display: 'Plus Jakarta Sans', 'Inter', sans-serif;

    /* Spacing - 8px system */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;

    /* Border radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    color: var(--neutral-900);
    background: var(--neutral-50);
    line-height: 1.5;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    line-height: 1.2;
    font-weight: 700;
}

a { color: var(--primary-600); text-decoration: none; }
a:hover { color: var(--primary-700); }

img { max-width: 100%; height: auto; display: block; }

::selection { background: var(--primary-100); color: var(--primary-900); }

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

.container-sm { max-width: 640px; margin: 0 auto; padding: 0 var(--space-6); }
.container-md { max-width: 900px; margin: 0 auto; padding: 0 var(--space-6); }

.grid { display: grid; gap: var(--space-6); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

/* ============================================================
   Components - Buttons
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-3) var(--space-6);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-sans);
    border: none;
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    line-height: 1.5;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--primary-600);
    color: white;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--primary-700); box-shadow: var(--shadow-md); color: white; }

.btn-secondary {
    background: white;
    color: var(--neutral-700);
    border: 1px solid var(--neutral-200);
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { border-color: var(--neutral-300); background: var(--neutral-50); color: var(--neutral-800); }

.btn-ghost {
    background: transparent;
    color: var(--neutral-600);
    padding: var(--space-2) var(--space-4);
}
.btn-ghost:hover { background: var(--neutral-100); color: var(--neutral-900); }

.btn-lg { padding: var(--space-4) var(--space-8); font-size: 1rem; }
.btn-sm { padding: var(--space-2) var(--space-4); font-size: 0.8125rem; }
.btn-full { width: 100%; }

.btn svg, .btn .icon { width: 1.25rem; height: 1.25rem; }
.btn svg:first-child { margin-right: var(--space-2); }
.btn svg:last-child { margin-left: var(--space-2); }

/* ============================================================
   Components - Cards
   ============================================================ */
.card {
    background: white;
    border-radius: var(--radius-2xl);
    border: 1px solid var(--neutral-200);
    box-shadow: var(--shadow-sm);
}

.card-hover {
    background: white;
    border-radius: var(--radius-2xl);
    border: 1px solid var(--neutral-200);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-slow);
}
.card-hover:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--neutral-300);
    transform: translateY(-2px);
}

.card-body { padding: var(--space-6); }
.card-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--neutral-100);
}

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

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--neutral-700);
    margin-bottom: var(--space-2);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: 0.9375rem;
    font-family: var(--font-sans);
    color: var(--neutral-900);
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-xl);
    transition: all var(--transition-base);
    outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(37, 126, 235, 0.1);
}

.form-input::placeholder { color: var(--neutral-400); }
.form-textarea { resize: vertical; min-height: 100px; border-radius: var(--radius-lg); }
.form-input-sm { padding: var(--space-2) var(--space-3); font-size: 0.875rem; }

/* ============================================================
   Components - Badges
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-full);
}

.badge-success { background: var(--success-100); color: var(--success-700); }
.badge-warning { background: var(--warning-100); color: var(--warning-700); }
.badge-error { background: var(--error-100); color: var(--error-700); }
.badge-info { background: var(--primary-100); color: var(--primary-700); }
.badge-neutral { background: var(--neutral-100); color: var(--neutral-600); }

/* ============================================================
   Components - Alert / Notice
   ============================================================ */
.alert {
    padding: var(--space-4);
    border-radius: var(--radius-xl);
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

.alert-error { background: var(--error-50); border: 1px solid var(--error-100); color: var(--error-700); }
.alert-success { background: var(--success-50); border: 1px solid var(--success-100); color: var(--success-700); }
.alert-warning { background: var(--warning-50); border: 1px solid var(--warning-100); color: var(--warning-700); }
.alert-info { background: var(--primary-50); border: 1px solid var(--primary-100); color: var(--primary-700); }

/* ============================================================
   Components - Navigation
   ============================================================ */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--neutral-200);
    height: 64px;
}

.navbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-6);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--neutral-900);
    text-decoration: none;
}

.navbar-brand .logo-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 256px;
    background: white;
    border-right: 1px solid var(--neutral-200);
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--neutral-100);
}

.sidebar-nav { flex: 1; padding: var(--space-4) var(--space-3); }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-xl);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--neutral-600);
    text-decoration: none;
    transition: all var(--transition-base);
    margin-bottom: 2px;
}

.sidebar-link:hover { background: var(--neutral-50); color: var(--neutral-900); }
.sidebar-link.active { background: var(--primary-50); color: var(--primary-700); }
.sidebar-link svg { width: 20px; height: 20px; }

.sidebar-footer {
    padding: var(--space-4) var(--space-3);
    border-top: 1px solid var(--neutral-100);
}

/* Mobile nav */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--neutral-200);
    z-index: 100;
    padding: var(--space-2);
}

.mobile-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-around;
}

.mobile-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-lg);
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--neutral-400);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.mobile-nav-link.active { color: var(--primary-600); }
.mobile-nav-link svg { width: 20px; height: 20px; }

/* Main content area with sidebar */
.app-main {
    margin-left: 256px;
    min-height: 100vh;
    padding: var(--space-8);
}

/* ============================================================
   Components - Tables
   ============================================================ */
.table-row {
    display: grid;
    align-items: center;
    padding: var(--space-3) var(--space-6);
    border-bottom: 1px solid var(--neutral-100);
    transition: background var(--transition-fast);
}

.table-row:hover { background: var(--neutral-50); }

.table-header {
    padding: var(--space-3) var(--space-6);
    background: var(--neutral-50);
    border-bottom: 1px solid var(--neutral-200);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--neutral-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============================================================
   Components - Biomarker Bar
   ============================================================ */
.biomarker-bar {
    position: relative;
    height: 8px;
    background: var(--neutral-100);
    border-radius: var(--radius-full);
    overflow: visible;
    margin: var(--space-2) 0;
}

.biomarker-bar-range {
    position: absolute;
    top: 0;
    bottom: 0;
    background: var(--success-200);
    border-radius: var(--radius-full);
}

.biomarker-bar-dot {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: var(--shadow-sm);
}

.biomarker-bar-dot.normal { background: var(--success-500); }
.biomarker-bar-dot.high, .biomarker-bar-dot.critical_high { background: var(--error-500); }
.biomarker-bar-dot.low, .biomarker-bar-dot.critical_low { background: var(--warning-500); }

/* ============================================================
   Page - Landing
   ============================================================ */
.hero {
    padding-top: 8rem;
    padding-bottom: 5rem;
    text-align: center;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    background: var(--primary-50);
    border: 1px solid var(--primary-100);
    color: var(--primary-700);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: var(--space-6);
}

.hero h1 {
    font-size: clamp(2.25rem, 5vw, 3.75rem);
    color: var(--neutral-900);
    margin-bottom: var(--space-6);
}

.hero h1 .gradient-text {
    background: linear-gradient(135deg, var(--primary-600), var(--secondary-600));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero p {
    font-size: 1.125rem;
    color: var(--neutral-600);
    max-width: 640px;
    margin: 0 auto var(--space-8);
    line-height: 1.6;
}

.hero-actions { display: flex; align-items: center; justify-content: center; gap: var(--space-4); flex-wrap: wrap; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-6);
    max-width: 800px;
    margin: 5rem auto 0;
}

.stat-item { text-align: center; }
.stat-value { font-family: var(--font-display); font-size: 1.75rem; font-weight: 700; color: var(--neutral-900); }
.stat-label { font-size: 0.875rem; color: var(--neutral-500); margin-top: var(--space-1); }

/* Section styles */
.section { padding: 5rem 0; }
.section-alt { background: white; border-top: 1px solid var(--neutral-100); border-bottom: 1px solid var(--neutral-100); }
.section-title { font-size: clamp(1.5rem, 3vw, 2.25rem); text-align: center; margin-bottom: var(--space-4); }
.section-subtitle { font-size: 1.125rem; color: var(--neutral-600); text-align: center; max-width: 640px; margin: 0 auto var(--space-12); }

/* CTA */
.cta-card {
    padding: var(--space-16);
    text-align: center;
    background: linear-gradient(135deg, var(--primary-600), var(--primary-800));
    border-radius: var(--radius-2xl);
    border: none;
}

.cta-card h2 { color: white; margin-bottom: var(--space-4); }
.cta-card p { color: rgba(255,255,255,0.8); font-size: 1.125rem; max-width: 540px; margin: 0 auto var(--space-8); }

.btn-white {
    background: white;
    color: var(--primary-700);
    font-weight: 600;
    padding: var(--space-4) var(--space-8);
    border-radius: var(--radius-xl);
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}
.btn-white:hover { background: var(--primary-50); box-shadow: var(--shadow-xl); color: var(--primary-800); }

/* Footer */
.footer {
    padding: var(--space-10) 0;
    border-top: 1px solid var(--neutral-200);
}

/* ============================================================
   Page - Auth
   ============================================================ */
.auth-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
}

.auth-left {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-900));
    padding: var(--space-12);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.auth-left::before {
    content: '';
    position: absolute;
    top: 5rem;
    left: 5rem;
    width: 18rem;
    height: 18rem;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.15);
}

.auth-left::after {
    content: '';
    position: absolute;
    bottom: 10rem;
    right: 2rem;
    width: 24rem;
    height: 24rem;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.1);
}

.auth-right {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-12);
}

.auth-form { width: 100%; max-width: 420px; }
.auth-form h1 { font-size: 1.75rem; margin-bottom: var(--space-2); }
.auth-form .subtitle { color: var(--neutral-600); margin-bottom: var(--space-8); }

/* ============================================================
   Page - Dashboard
   ============================================================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-8);
}

.page-title { font-size: 1.75rem; }
.page-subtitle { color: var(--neutral-500); margin-top: var(--space-1); }

.stats-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); margin-bottom: var(--space-8); }

.stat-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-6);
}

.stat-card .icon-box {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card .stat-number { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; }
.stat-card .stat-text { font-size: 0.875rem; color: var(--neutral-500); }

/* Report list items */
.report-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5);
    border-bottom: 1px solid var(--neutral-100);
    cursor: pointer;
    transition: background var(--transition-fast);
    text-decoration: none;
    color: inherit;
}
.report-item:hover { background: var(--neutral-50); }

/* ============================================================
   Page - Chat
   ============================================================ */
.chat-layout { display: flex; height: calc(100vh - 0px); }

.chat-sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid var(--neutral-200);
    display: flex;
    flex-direction: column;
}

.chat-main { flex: 1; display: flex; flex-direction: column; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6);
}

.chat-message {
    display: flex;
    margin-bottom: var(--space-6);
}
.chat-message.user { justify-content: flex-end; }

.chat-bubble {
    max-width: 80%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-2xl);
    font-size: 0.875rem;
    line-height: 1.6;
}

.chat-bubble.user {
    background: var(--primary-600);
    color: white;
    border-bottom-right-radius: var(--radius-sm);
}

.chat-bubble.assistant {
    background: var(--neutral-100);
    color: var(--neutral-800);
    border-bottom-left-radius: var(--radius-sm);
}

.chat-input-area {
    padding: var(--space-4) var(--space-6);
    border-top: 1px solid var(--neutral-100);
    background: white;
}

.chat-input-form { display: flex; gap: var(--space-3); }

/* ============================================================
   Utility Classes
   ============================================================ */
.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-neutral-400 { color: var(--neutral-400); }
.text-neutral-500 { color: var(--neutral-500); }
.text-neutral-600 { color: var(--neutral-600); }
.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }
.hidden { display: none; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.animate-fade-in { animation: fadeIn 0.5s ease-out; }
.animate-slide-up { animation: slideUp 0.5s ease-out; }
.animate-spin { animation: spin 1s linear infinite; }
.animate-pulse { animation: pulse 1.5s ease-in-out infinite; }

/* Spinner */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--neutral-200);
    border-top-color: var(--primary-600);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
    .sidebar { display: none; }
    .mobile-nav { display: block; }
    .app-main { margin-left: 0; padding-bottom: 5rem; }
    .auth-layout { grid-template-columns: 1fr; }
    .auth-left { display: none; }
    .stats-cards { grid-template-columns: 1fr; }
    .chat-sidebar { display: none; }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .hero h1 { font-size: 2rem; }
    .hero-actions { flex-direction: column; }
    .page-header { flex-direction: column; align-items: flex-start; gap: var(--space-4); }
    .container { padding: 0 var(--space-4); }
    .app-main { padding: var(--space-4); }
}
