/* ===== FPH Clinical Suite — Brand Stylesheet ===== */
/* Colors: Navy #0B1120, Surface #131B2E, Teal #00D4AA, Cyan #38BDF8, Amber #F59E0B */
/* Fonts: Inter (body), JetBrains Mono (data) */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: #1a1a1a; display: flex; min-height: 100vh; }

/* ===== Login Page ===== */
body.login-page { display: flex; align-items: center; justify-content: center; background: #0B1120; }
.login-card { background: #131B2E; padding: 44px; border-radius: 16px; box-shadow: 0 8px 40px rgba(0,0,0,.4); width: 380px; border: 1px solid rgba(255,255,255,.06); }
.login-card h1 { font-size: 24px; margin-bottom: 4px; color: #F1F5F9; font-weight: 700; letter-spacing: -0.02em; }
.login-card .subtitle { color: #94A3B8; margin-bottom: 28px; font-size: 14px; }
.login-card label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; margin-top: 16px; color: #94A3B8; text-transform: uppercase; letter-spacing: 0.05em; }
.login-card input { width: 100%; padding: 10px 14px; border: 1px solid rgba(255,255,255,.1); border-radius: 8px; font-size: 14px; background: #0B1120; color: #F1F5F9; transition: border-color .2s; }
.login-card input:focus { outline: none; border-color: #00D4AA; box-shadow: 0 0 0 3px rgba(0,212,170,.15); }
.login-card button { width: 100%; margin-top: 24px; padding: 12px; background: #00D4AA; color: #0B1120; border: none; border-radius: 8px; font-size: 14px; font-weight: 700; cursor: pointer; transition: background .2s, transform .1s; }
.login-card button:hover { background: #00e6b8; }
.login-card button:active { transform: scale(.98); }
.error-banner { background: rgba(239,83,80,.1); border: 1px solid rgba(239,83,80,.3); padding: 10px 14px; border-radius: 8px; color: #ef5350; margin-bottom: 14px; font-size: 13px; }

/* ===== Navigation Sidebar ===== */
.sidebar { width: 210px; background: #0B1120; color: white; padding: 20px 0; flex-shrink: 0; display: flex; flex-direction: column; border-right: 1px solid rgba(255,255,255,.06); }
.sidebar .logo { padding: 4px 20px 20px; font-weight: 700; font-size: 15px; color: #00D4AA; border-bottom: 1px solid rgba(255,255,255,.06); letter-spacing: -0.01em; }
.sidebar a { display: block; padding: 10px 20px; color: #94A3B8; text-decoration: none; font-size: 13px; font-weight: 500; transition: all .15s; border-left: 3px solid transparent; }
.sidebar a:hover { background: rgba(255,255,255,.04); color: #F1F5F9; border-left-color: rgba(0,212,170,.3); }
.sidebar a.active { background: rgba(0,212,170,.08); color: #00D4AA; border-left-color: #00D4AA; }
.sidebar .logout { color: #ef5350; }
.sidebar .user-info { padding: 14px 20px; font-size: 12px; color: #64748B; border-top: 1px solid rgba(255,255,255,.06); margin-top: auto; }

/* ===== Main Content ===== */
.content { flex: 1; padding: 28px 32px; overflow-y: auto; background: #f8fafc; }
.page-header { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.page-header h1 { flex: 1; font-size: 24px; font-weight: 700; color: #0B1120; letter-spacing: -0.02em; }

/* ===== Buttons ===== */
.btn-primary { background: #00D4AA; color: #0B1120; padding: 8px 18px; border-radius: 8px; text-decoration: none; font-size: 13px; font-weight: 700; border: none; cursor: pointer; transition: background .15s, transform .1s; }
.btn-primary:hover { background: #00e6b8; }
.btn-primary:active { transform: scale(.97); }
.btn-danger { background: #ef5350; color: white; padding: 8px 18px; border-radius: 8px; text-decoration: none; font-size: 13px; font-weight: 600; border: none; cursor: pointer; }
.btn-secondary { background: #e2e8f0; color: #334155; padding: 8px 18px; border-radius: 8px; text-decoration: none; font-size: 13px; font-weight: 600; border: none; cursor: pointer; transition: background .15s; }
.btn-secondary:hover { background: #cbd5e1; }

/* ===== Tables ===== */
table { width: 100%; border-collapse: collapse; background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06); }
th { background: #f1f5f9; padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 700; color: #64748B; border-bottom: 1px solid #e2e8f0; text-transform: uppercase; letter-spacing: 0.05em; }
td { padding: 10px 16px; border-bottom: 1px solid #f1f5f9; }
tr:last-child td { border-bottom: none; }
tr:hover { background: #fafbfc; }
td a { color: #00D4AA; text-decoration: none; font-weight: 600; }
td a:hover { color: #00b894; }

/* ===== Badges ===== */
.mrn-badge { background: rgba(0,212,170,.1); color: #00D4AA; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.status-badge { padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.status-draft { background: rgba(245,158,11,.1); color: #d97706; }
.status-complete { background: rgba(0,212,170,.1); color: #00D4AA; }

/* ===== Forms ===== */
.form-card { background: white; padding: 28px; border-radius: 12px; max-width: 500px; box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06); }
.form-card label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; margin-top: 16px; color: #475569; }
.form-card input, .form-card select, .form-card textarea { width: 100%; padding: 10px 14px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 14px; transition: border-color .2s; }
.form-card input:focus, .form-card select:focus, .form-card textarea:focus { outline: none; border-color: #00D4AA; box-shadow: 0 0 0 3px rgba(0,212,170,.1); }
.form-card textarea { min-height: 80px; resize: vertical; }
.form-card .btn-primary { margin-top: 20px; }
.form-card a { display: inline-block; margin-left: 10px; color: #94A3B8; text-decoration: none; font-size: 13px; }
.search-form { display: flex; gap: 8px; margin-bottom: 16px; }
.search-form input { padding: 10px 14px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 14px; flex: 1; max-width: 400px; }
.search-form input:focus { outline: none; border-color: #00D4AA; box-shadow: 0 0 0 3px rgba(0,212,170,.1); }

/* ===== Stats Cards ===== */
.stats { display: flex; gap: 16px; margin-bottom: 24px; }
.stat-card { background: white; padding: 22px 26px; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06); }
.stat-number { font-size: 32px; font-weight: 700; color: #00D4AA; font-family: 'JetBrains Mono', monospace; letter-spacing: -0.02em; }
.stat-label { font-size: 12px; color: #64748B; margin-top: 4px; font-weight: 500; }
h2 { font-size: 18px; margin-bottom: 14px; color: #0B1120; font-weight: 700; letter-spacing: -0.01em; }

/* ===== Visit Form ===== */
.visit-date-badge { background: rgba(56,189,248,.1); color: #38BDF8; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 700; }
.record-panel { background: white; border-radius: 12px; padding: 20px 24px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06); }
.record-panel-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.record-panel h2 { font-size: 15px; font-weight: 700; }
.record-timer { font-size: 14px; color: #ef5350; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.record-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.record-status { font-size: 13px; color: #64748B; }
.record-status.recording { color: #ef5350; font-weight: 600; }
.transcript-box textarea { width: 100%; min-height: 100px; padding: 12px 14px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 13px; resize: vertical; transition: border-color .2s; }
.transcript-box textarea:focus { outline: none; border-color: #00D4AA; box-shadow: 0 0 0 3px rgba(0,212,170,.1); }
.form-section { background: white; border-radius: 12px; padding: 20px 24px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06); }
.section-title { font-size: 13px; font-weight: 700; color: #00D4AA; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 2px solid rgba(0,212,170,.15); text-transform: uppercase; letter-spacing: 0.06em; }
.field-group { margin-bottom: 14px; }
.field-group label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; color: #334155; }
.field-hint { font-weight: 400; color: #94A3B8; font-style: italic; }
.required-star { color: #ef5350; }
.field-group input[type="text"], .field-group input[type="date"], .field-group input[type="number"], .field-group textarea { width: 100%; padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 13px; background: white; transition: border-color .2s; }
.field-group textarea { min-height: 80px; resize: vertical; font-family: inherit; }
.field-group input:focus, .field-group textarea:focus { outline: none; border-color: #00D4AA; box-shadow: 0 0 0 3px rgba(0,212,170,.1); }
.soap-section { border: 2px solid #0B1120; }
.soap-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 2px solid rgba(0,212,170,.15); }
.soap-textarea { width: 100%; min-height: 220px; padding: 14px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 13px; font-family: inherit; resize: vertical; }
.soap-textarea:focus { outline: none; border-color: #00D4AA; box-shadow: 0 0 0 3px rgba(0,212,170,.1); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 0 24px; }
.ai-filled { background: rgba(0,212,170,.06) !important; transition: background 2s; }
.autosave-indicator { font-size: 12px; color: #94A3B8; font-style: italic; }
.autosave-indicator.saving { color: #F59E0B; }
.autosave-indicator.saved { color: #00D4AA; }
.autosave-indicator.error { color: #ef5350; }

/* ===== Two-Column Visit Layout ===== */
.visit-layout { display: flex; gap: 20px; align-items: flex-start; }
.visit-main { flex: 1; min-width: 0; }
.visit-sidebar { width: 420px; flex-shrink: 0; position: sticky; top: 20px; max-height: calc(100vh - 60px); display: flex; flex-direction: column; background: white; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06); overflow: hidden; }
.visit-sidebar.collapsed { display: none; }
.visit-layout.tools-hidden .visit-main { flex: 1; }
.tools-toggle { font-size: 12px; padding: 5px 12px; }

/* ===== Tools Tabs ===== */
.tools-tabs { display: flex; border-bottom: 2px solid #e2e8f0; flex-shrink: 0; background: #f8fafc; }
.tools-tab { flex: 1; padding: 10px 4px; border: none; background: transparent; cursor: pointer; font-size: 11px; font-weight: 600; color: #94A3B8; transition: all .15s; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tools-tab.active { color: #00D4AA; border-bottom-color: #00D4AA; background: white; }
.tools-tab:hover { color: #0B1120; }

/* ===== Tools Content ===== */
.tools-content { display: flex; flex-direction: column; flex: 1; overflow: hidden; padding: 0; }
#tab-chat { display: flex; }
#tab-research { padding: 14px; overflow-y: auto; }

/* ===== Expert Chat ===== */
.chat-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; min-height: 300px; max-height: calc(100vh - 240px); }
.chat-msg { border-radius: 10px; padding: 10px 14px; font-size: 13px; line-height: 1.55; }
.chat-user { background: rgba(56,189,248,.08); align-self: flex-end; max-width: 90%; border: 1px solid rgba(56,189,248,.15); }
.chat-assistant { background: rgba(0,212,170,.06); align-self: flex-start; max-width: 95%; border: 1px solid rgba(0,212,170,.12); }
.chat-system { background: #f8fafc; align-self: center; text-align: center; color: #94A3B8; font-size: 12px; font-style: italic; max-width: 95%; }
.chat-msg-label { font-size: 10px; font-weight: 700; text-transform: uppercase; color: #94A3B8; margin-bottom: 3px; letter-spacing: 0.05em; }
.chat-user .chat-msg-label { color: #38BDF8; }
.chat-assistant .chat-msg-label { color: #00D4AA; }
.chat-msg-text { word-wrap: break-word; }
.chat-input-area { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid #e2e8f0; flex-shrink: 0; align-items: flex-end; }
.chat-input-area textarea { flex: 1; padding: 10px 12px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 13px; font-family: inherit; resize: none; max-height: 80px; }
.chat-input-area textarea:focus { outline: none; border-color: #00D4AA; }
.chat-input-area button { padding: 10px 16px; flex-shrink: 0; }

/* ===== Research Panel ===== */
.research-subtabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.research-subtab { padding: 6px 12px; border: 1px solid #e2e8f0; border-radius: 6px; background: white; cursor: pointer; font-size: 11px; font-weight: 600; color: #64748B; transition: all .15s; }
.research-subtab.active { background: #0B1120; color: #00D4AA; border-color: #0B1120; }
.research-subtab:hover { border-color: #00D4AA; }
.research-input-row { display: flex; gap: 8px; margin-bottom: 10px; }
.research-input-row input { flex: 1; padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 13px; }
.research-input-row input:focus { outline: none; border-color: #00D4AA; }
.research-results { margin-top: 8px; max-height: calc(100vh - 360px); overflow-y: auto; }
.research-loading { text-align: center; color: #94A3B8; font-size: 12px; padding: 20px; }
.research-empty { text-align: center; color: #94A3B8; font-size: 12px; padding: 20px; }
.research-error { color: #ef5350; font-size: 12px; padding: 8px; }
#tab-research textarea { width: 100%; padding: 8px 12px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 13px; font-family: inherit; resize: vertical; }

/* ===== PubMed ===== */
.pubmed-article { border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; margin-bottom: 8px; background: white; transition: box-shadow .15s; }
.pubmed-article:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.pubmed-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.pubmed-title a { color: #0B1120; text-decoration: none; }
.pubmed-title a:hover { color: #00D4AA; }
.pubmed-meta { font-size: 11px; color: #94A3B8; margin-bottom: 6px; }
.pubmed-abstract { font-size: 12px; color: #475569; line-height: 1.55; }

/* ===== Lab / Marker Cards ===== */
.lab-interpretation { font-size: 13px; line-height: 1.6; color: #334155; }
.marker-card { border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; margin-bottom: 8px; background: white; }
.marker-name { font-weight: 700; font-size: 14px; color: #0B1120; }
.marker-unit { font-size: 11px; color: #94A3B8; margin-bottom: 4px; font-family: 'JetBrains Mono', monospace; }
.marker-range { font-size: 12px; margin-bottom: 2px; }
.marker-range .range-label { font-weight: 600; color: #475569; }
.marker-range.optimal { color: #00D4AA; font-weight: 600; }
.marker-notes { font-size: 12px; color: #475569; line-height: 1.55; margin-top: 6px; border-top: 1px solid #f1f5f9; padding-top: 6px; }

/* ===== Sub-tabs (all modules) ===== */
.gimap-subtab, .supp-subtab, .billing-subtab, .guide-subtab, .nutri-subtab, .labs-subtab, .meal-subtab { padding: 6px 12px; border: 1px solid #e2e8f0; border-radius: 6px; background: white; cursor: pointer; font-size: 11px; font-weight: 600; color: #64748B; transition: all .15s; }
.gimap-subtab.active, .supp-subtab.active, .billing-subtab.active, .guide-subtab.active, .nutri-subtab.active, .labs-subtab.active, .meal-subtab.active { background: #0B1120; color: #00D4AA; border-color: #0B1120; }
.gimap-subtab:hover, .supp-subtab:hover, .guide-subtab:hover, .nutri-subtab:hover, .labs-subtab:hover, .meal-subtab:hover { border-color: #00D4AA; }
.gimap-subcontent, .supp-subcontent, .billing-subcontent, .guide-subcontent, .nutri-subcontent, .labs-subcontent, .meal-subcontent { margin-top: 8px; }
#tab-gimap, #tab-supplements, #tab-mealplan, #tab-billing, #tab-guide, #tab-nutrigenomics, #tab-labs { padding: 14px; overflow-y: auto; }

/* ===== Medication Cards ===== */
.med-card { border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; margin-bottom: 8px; background: white; transition: box-shadow .15s; }
.med-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.med-name { font-weight: 700; font-size: 13px; color: #0B1120; }
.med-category-peptide { background: rgba(0,212,170,.1); color: #00D4AA; padding: 2px 10px; border-radius: 12px; font-size: 10px; font-weight: 700; letter-spacing: 0.03em; }
.med-category-prescription { background: rgba(56,189,248,.1); color: #38BDF8; padding: 2px 10px; border-radius: 12px; font-size: 10px; font-weight: 700; letter-spacing: 0.03em; }
.med-category-other { background: #f1f5f9; color: #64748B; padding: 2px 10px; border-radius: 12px; font-size: 10px; font-weight: 700; }

/* ===== Lab Status Badges ===== */
.lab-status { padding: 2px 10px; border-radius: 12px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.lab-status-ordered { background: rgba(56,189,248,.1); color: #38BDF8; }
.lab-status-collected { background: rgba(245,158,11,.1); color: #F59E0B; }
.lab-status-results_received { background: rgba(168,85,247,.1); color: #a855f7; }
.lab-status-reviewed { background: rgba(0,212,170,.1); color: #00D4AA; }

/* ===== Responsive ===== */
@media (max-width: 1200px) {
  .visit-sidebar { width: 380px; }
  .tools-tab { font-size: 10px; padding: 8px 2px; }
}
@media (max-width: 1100px) {
  .visit-sidebar { width: 340px; }
}
@media (max-width: 900px) {
  .visit-layout { flex-direction: column; }
  .visit-sidebar { width: 100%; position: static; max-height: none; }
  .chat-messages { max-height: 400px; }
  .tools-tab { font-size: 11px; padding: 8px 6px; }
}
