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

:root {
    --primary: #0d9488;
    --primary-dark: #0f766e;
    --primary-light: #ccfbf1;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --success: #16a34a;
    --success-light: #f0fdf4;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --bg: #f8fafc;
    --sidebar-w: 240px;
    --topbar-h: 56px;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.6; }

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

/* ===================== EMERGENCY STRIP ===================== */
.emergency-strip {
    background: var(--danger);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    flex-wrap: wrap;
}
.emergency-strip a { color: #fff; border: 1px solid rgba(255,255,255,0.6); border-radius: 4px; padding: 0.1rem 0.5rem; font-size: 0.75rem; text-decoration: none; }
.emergency-strip a:hover { background: rgba(255,255,255,0.15); }

/* ===================== APP LAYOUT ===================== */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: #0f172a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s ease;
}
.sidebar-logo { padding: 1.25rem 1rem; display: flex; align-items: center; gap: 0.75rem; border-bottom: 1px solid rgba(255,255,255,0.08); }
.logo-icon { font-size: 1.5rem; color: var(--primary); }
.logo-text { font-size: 1rem; font-weight: 700; color: #fff; }
.logo-sub { font-size: 0.7rem; color: #94a3b8; }

.sidebar-nav { flex: 1; padding: 0.75rem 0; }
.nav-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 1rem; color: #94a3b8; font-size: 0.875rem; transition: all 0.15s; text-decoration: none; border-radius: 0; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.06); text-decoration: none; }
.nav-item.active { color: #fff; background: rgba(13,148,136,0.2); border-left: 3px solid var(--primary); }
.nav-item i { width: 16px; text-align: center; }
.assistant-nav { border-top: 1px solid rgba(255,255,255,0.08); margin-top: 0.5rem; padding-top: 0.75rem; }

.sidebar-footer { padding: 0.75rem 0; border-top: 1px solid rgba(255,255,255,0.08); }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; }

/* Main content */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* Topbar */
.topbar { height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 1.5rem; gap: 1rem; position: sticky; top: 0; z-index: 50; }
.menu-toggle { display: none; background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text); }
.topbar-title { flex: 1; font-weight: 600; font-size: 1rem; }
.btn-assistant-quick { background: var(--primary); color: #fff; padding: 0.4rem 0.75rem; border-radius: 6px; font-size: 0.85rem; text-decoration: none; }

.page-content { padding: 1.5rem; }

/* ===================== BUTTONS ===================== */
.btn-primary { background: var(--primary); color: #fff; padding: 0.6rem 1.25rem; border-radius: 8px; border: none; cursor: pointer; font-size: 0.9rem; font-weight: 600; display: inline-block; text-decoration: none; transition: background 0.15s; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-outline { border: 2px solid var(--primary); color: var(--primary); background: transparent; padding: 0.55rem 1.25rem; border-radius: 8px; font-size: 0.9rem; font-weight: 600; display: inline-block; cursor: pointer; text-decoration: none; }
.btn-outline:hover { background: var(--primary-light); text-decoration: none; }
.btn-emergency { background: var(--danger); color: #fff; padding: 0.6rem 1.25rem; border-radius: 8px; font-weight: 700; display: inline-block; text-decoration: none; font-size: 0.95rem; }
.btn-emergency:hover { background: #b91c1c; color: #fff; text-decoration: none; }
.btn-111 { background: #ea580c; color: #fff; padding: 0.6rem 1.25rem; border-radius: 8px; font-weight: 700; display: inline-block; text-decoration: none; }
.btn-sm { background: var(--primary-light); color: var(--primary-dark); padding: 0.3rem 0.75rem; border-radius: 6px; font-size: 0.8rem; font-weight: 600; text-decoration: none; border: none; cursor: pointer; }
.btn-full { width: 100%; text-align: center; }
.btn-lg { padding: 0.75rem 1.75rem; font-size: 1rem; }
.btn-link { color: var(--text-muted); font-size: 0.875rem; display: block; text-align: center; margin-top: 0.75rem; }

/* ===================== FORMS ===================== */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.35rem; color: var(--text); }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 0.6rem 0.85rem; border: 1px solid var(--border); border-radius: 8px; font-size: 0.9rem; color: var(--text); background: #fff; transition: border-color 0.15s; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.disclaimer-accept { display: flex; gap: 0.5rem; margin-bottom: 1rem; font-size: 0.85rem; align-items: flex-start; }
.disclaimer-accept input { width: auto; margin-top: 3px; }

/* ===================== ALERTS ===================== */
.alert { padding: 0.85rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error { background: var(--danger-light); color: #7f1d1d; border: 1px solid #fca5a5; }
.alert-success { background: var(--success-light); color: #14532d; border: 1px solid #86efac; }
.alert-lg { padding: 1.25rem 1.5rem; }
.alert-lg h3 { margin-bottom: 0.75rem; color: var(--danger); }
.alert-lg ul { padding-left: 1.25rem; margin-top: 0.5rem; }

/* ===================== AUTH ===================== */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #f0fdf4 0%, #e0f2fe 100%); }
.auth-card { background: #fff; border-radius: 16px; padding: 2rem; width: 100%; max-width: 420px; box-shadow: 0 4px 24px rgba(0,0,0,0.08); }
.auth-logo { display: flex; align-items: center; gap: 0.6rem; font-size: 1.2rem; font-weight: 700; color: var(--primary-dark); margin-bottom: 1.5rem; }
.auth-logo i { font-size: 1.4rem; }
.auth-card h2 { margin-bottom: 1.25rem; font-size: 1.3rem; }
.auth-link { text-align: center; margin-top: 1rem; font-size: 0.875rem; color: var(--text-muted); }

/* ===================== LANDING ===================== */
.landing-body { background: #fff; }
.landing-nav { display: flex; align-items: center; justify-content: space-between; padding: 1rem 2rem; border-bottom: 1px solid var(--border); }
.landing-logo { display: flex; align-items: center; gap: 0.6rem; font-size: 1.2rem; font-weight: 700; color: var(--primary-dark); text-decoration: none; }
.landing-logo i { color: var(--primary); }
.landing-nav-links { display: flex; align-items: center; gap: 1rem; }
.hero { padding: 5rem 2rem; text-align: center; background: linear-gradient(135deg, #f0fdf4 0%, #e0f2fe 100%); }
.hero h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: 1rem; color: #0f172a; }
.hero p { font-size: 1.1rem; color: var(--text-muted); max-width: 560px; margin: 0 auto 2rem; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1rem; }
.hero-disclaimer { font-size: 0.8rem; color: var(--text-muted); }
.features { padding: 4rem 2rem; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem; max-width: 1100px; margin: 0 auto; }
.feature-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; }
.feature-icon { font-size: 1.5rem; color: var(--primary); margin-bottom: 0.75rem; }
.feature-card h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.feature-card p { font-size: 0.875rem; color: var(--text-muted); }
.landing-disclaimer-box { background: #fef3c7; border: 1px solid #fcd34d; padding: 1.25rem 2rem; display: flex; gap: 1rem; align-items: flex-start; max-width: 900px; margin: 0 auto 2rem; border-radius: 10px; font-size: 0.9rem; }
.landing-disclaimer-box i { color: #d97706; font-size: 1.2rem; margin-top: 2px; }
.landing-footer { text-align: center; padding: 2rem; border-top: 1px solid var(--border); font-size: 0.85rem; color: var(--text-muted); }

/* ===================== DASHBOARD ===================== */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1.25rem; }
.dash-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; }
.dash-card-wide { grid-column: span 2; }
.dash-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.dash-card-header h3 { font-size: 0.95rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.dash-card-header h3 i { color: var(--primary); }
.dash-card-link { display: block; text-align: center; margin-top: 1rem; font-size: 0.8rem; color: var(--primary); }
.empty-state { font-size: 0.875rem; color: var(--text-muted); padding: 0.5rem 0; }

.list-item { display: flex; gap: 0.75rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border); align-items: center; }
.list-item:last-child { border-bottom: none; }
.list-item-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; flex-shrink: 0; }
.appt-icon { background: #ede9fe; color: #7c3aed; }
.med-icon { background: #fef3c7; color: #d97706; }
.wait-icon { background: #e0f2fe; color: #0284c7; }
.warn-icon { background: var(--danger-light); color: var(--danger); }
.list-item-title { font-size: 0.875rem; font-weight: 600; }
.list-item-sub { font-size: 0.775rem; color: var(--text-muted); }

.vitals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 0.75rem; }
.vital-chip { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem; text-align: center; }
.vital-label { font-size: 0.7rem; color: var(--text-muted); text-transform: capitalize; margin-bottom: 0.25rem; }
.vital-value { font-size: 1rem; font-weight: 700; color: var(--primary-dark); }
.vital-unit { font-size: 0.7rem; font-weight: 400; color: var(--text-muted); }
.vital-date { font-size: 0.65rem; color: var(--text-muted); }

.vitals-dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.65rem; }
.vital-dash-chip { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 0.75rem; text-align: center; }
.vital-dash-icon { font-size: 1.25rem; margin-bottom: 0.3rem; }
.vital-dash-label { font-size: 0.68rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 0.25rem; }
.vital-dash-value { font-size: 1.05rem; font-weight: 800; color: var(--text); line-height: 1.2; }
.vital-dash-unit { font-size: 0.65rem; font-weight: 400; color: var(--text-muted); }
.vital-dash-date { font-size: 0.65rem; color: var(--text-muted); margin-top: 0.25rem; }
.trend-up { color: #dc2626; font-size: 0.75rem; }
.trend-down { color: #16a34a; font-size: 0.75rem; }
.range-badge { display: inline-block; font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-radius: 4px; padding: 1px 5px; margin-top: 0.2rem; }
.range-normal { background: #f0fdf4; color: #16a34a; }
.range-high { background: #fef2f2; color: #dc2626; }
.range-elevated { background: #fffbeb; color: #b45309; }
.range-low { background: #eff6ff; color: #1d4ed8; }

.records-list { display: flex; flex-direction: column; gap: 0.5rem; }
.record-item { display: flex; gap: 0.75rem; padding: 0.75rem; background: var(--bg); border-radius: 8px; text-decoration: none; color: var(--text); transition: background 0.15s; }
.record-item:hover { background: var(--primary-light); text-decoration: none; }
.record-icon { color: var(--primary); font-size: 1.2rem; padding-top: 2px; }
.record-title { font-size: 0.875rem; font-weight: 600; }
.record-summary { font-size: 0.775rem; color: var(--text-muted); margin-top: 0.2rem; }
.record-date { font-size: 0.75rem; color: var(--text-muted); }

.assistant-cta { text-align: center; background: linear-gradient(135deg, #f0fdf4, #e0f2fe); border-color: var(--primary); }
.assistant-cta i { font-size: 2rem; color: var(--primary); margin-bottom: 0.75rem; display: block; }
.assistant-cta h3 { margin-bottom: 0.5rem; }
.assistant-cta p { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 1rem; }
.cta-disclaimer { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.75rem; }

/* ===================== BADGES ===================== */
.badge { background: var(--primary-light); color: var(--primary-dark); padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.badge-warn { background: var(--danger-light); color: var(--danger); }

/* ===================== HEALTH ASSISTANT ===================== */
.assistant-page { max-width: 700px; margin: 0 auto; }
.red-flags-box { background: var(--danger-light); border: 2px solid var(--danger); border-radius: 12px; padding: 1.5rem; margin-bottom: 1.5rem; }
.red-flags-box h2 { color: var(--danger); font-size: 1.1rem; margin-bottom: 0.75rem; }
.red-flags-box ul { padding-left: 1.25rem; color: #7f1d1d; margin-bottom: 1rem; }
.red-flags-box ul li { margin-bottom: 0.35rem; font-size: 0.9rem; }
.red-flags-box p { color: #7f1d1d; font-weight: 600; margin-bottom: 1rem; }
.red-flags-actions { display: flex; gap: 1rem; flex-wrap: wrap; }

.disclaimer-gate { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 1rem; }
.disclaimer-gate-card { background: #fff; border-radius: 16px; padding: 2rem; max-width: 480px; width: 100%; }
.disclaimer-gate-card h2 { margin-bottom: 1rem; }
.disclaimer-text { background: var(--bg); border-radius: 8px; padding: 1rem; margin-bottom: 1.25rem; font-size: 0.875rem; }
.disclaimer-text ul { padding-left: 1.25rem; margin: 0.5rem 0; }
.disclaimer-text li { margin-bottom: 0.4rem; }

.assistant-chat { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.chat-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); background: #0f172a; }
.chat-header h2 { color: #fff; font-size: 1rem; }
.emergency-btns { display: flex; gap: 0.5rem; }
.btn-emergency-sm { background: var(--danger); color: #fff; padding: 0.3rem 0.75rem; border-radius: 6px; font-size: 0.8rem; font-weight: 700; text-decoration: none; }
.btn-111-sm { background: #ea580c; color: #fff; padding: 0.3rem 0.75rem; border-radius: 6px; font-size: 0.8rem; font-weight: 700; text-decoration: none; }

.chat-messages { padding: 1rem; min-height: 300px; max-height: 450px; overflow-y: auto; display: flex; flex-direction: column; gap: 0.75rem; }
.chat-msg { padding: 0.75rem 1rem; border-radius: 10px; font-size: 0.9rem; max-width: 90%; line-height: 1.5; }
.user-msg { background: var(--primary); color: #fff; align-self: flex-end; border-radius: 10px 10px 2px 10px; }
.assistant-msg { background: var(--bg); border: 1px solid var(--border); align-self: flex-start; }
.msg-disclaimer { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.5rem; border-top: 1px solid var(--border); padding-top: 0.5rem; }
.outcome-999 { border-color: var(--danger); background: var(--danger-light); }
.outcome-111 { border-color: #fdba74; background: #fff7ed; }
.outcome-gp { border-color: #93c5fd; background: #eff6ff; }

.chat-input-area { padding: 1rem; border-top: 1px solid var(--border); display: flex; gap: 0.75rem; align-items: flex-end; }
.chat-input-area textarea { flex: 1; resize: none; border: 1px solid var(--border); border-radius: 8px; padding: 0.6rem 0.85rem; font-size: 0.9rem; font-family: inherit; }
.chat-input-area textarea:focus { outline: none; border-color: var(--primary); }

.chat-emergency-strip { background: #0f172a; display: flex; gap: 0; border-top: 1px solid rgba(255,255,255,0.08); }
.chat-emergency-strip a { flex: 1; text-align: center; color: #94a3b8; padding: 0.6rem; font-size: 0.8rem; font-weight: 600; text-decoration: none; display: flex; align-items: center; justify-content: center; gap: 0.4rem; border-right: 1px solid rgba(255,255,255,0.08); }
.chat-emergency-strip a:first-child { color: #fca5a5; }
.chat-emergency-strip a:nth-child(2) { color: #fdba74; }
.chat-emergency-strip a:hover { background: rgba(255,255,255,0.05); text-decoration: none; }

/* ===================== STATIC PAGES ===================== */
.static-body { background: var(--bg); }
.static-container { max-width: 800px; margin: 0 auto; padding: 3rem 1.5rem 5rem; }
.static-container h1 { font-size: 1.75rem; font-weight: 800; margin-bottom: 0.5rem; }
.static-subtitle { color: var(--text-muted); margin-bottom: 0.5rem; }
.static-updated { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 2rem; }
.static-section { margin-bottom: 2rem; }
.static-section h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.75rem; padding-bottom: 0.5rem; border-bottom: 2px solid var(--border); }
.static-section p { font-size: 0.9rem; margin-bottom: 0.75rem; }
.static-section ul { padding-left: 1.25rem; font-size: 0.9rem; }
.static-section ul li { margin-bottom: 0.4rem; }
.callout { padding: 1rem 1.25rem; border-radius: 8px; font-size: 0.9rem; margin: 1rem 0; }
.callout-green { background: var(--success-light); border-left: 4px solid var(--success); color: #14532d; }
.emergency-contact-row { display: flex; gap: 1rem; margin-top: 2rem; flex-wrap: wrap; }

/* ===================== PROFILE SWITCHER ===================== */
.profile-switcher { padding: 0.5rem 1rem 0.75rem; border-top: 1px solid rgba(255,255,255,0.08); }
.switcher-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: .06em; color: rgba(255,255,255,0.4); margin-bottom: 0.4rem; font-weight: 600; }
.switcher-btn { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.75rem; font-weight: 600; color: rgba(255,255,255,0.6); background: rgba(255,255,255,0.07); border-radius: 20px; padding: 0.3rem 0.7rem; margin-right: 0.3rem; margin-bottom: 0.3rem; text-decoration: none; transition: background 0.15s, color 0.15s; }
.switcher-btn:hover { background: rgba(255,255,255,0.15); color: #fff; text-decoration: none; }
.switcher-active { background: rgba(255,255,255,0.2) !important; color: #fff !important; }
.viewing-banner { background: linear-gradient(90deg,#7c3aed,#6d28d9); color: #fff; padding: 0.6rem 1.5rem; font-size: 0.85rem; display: flex; align-items: center; gap: 0.6rem; }
.viewing-banner i { opacity: 0.8; }
.viewing-back { margin-left: auto; color: rgba(255,255,255,0.85); font-size: 0.8rem; text-decoration: none; display: flex; align-items: center; gap: 0.35rem; }
.viewing-back:hover { color: #fff; text-decoration: none; }

/* ===================== ERROR PAGE ===================== */
.error-page { text-align: center; padding: 5rem 1rem; }
.error-icon { font-size: 3rem; color: var(--text-muted); margin-bottom: 1rem; }
.error-page h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.error-page p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay { display: block; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
    .sidebar-overlay.open { opacity: 1; pointer-events: auto; }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .dash-card-wide { grid-column: span 1; }
    .form-row { grid-template-columns: 1fr; }
    .hero h1 { font-size: 1.75rem; }
    .features-grid { grid-template-columns: 1fr; }
}
