/* ============================================
   LabAssist — Professional Medical UI
   Light theme, clean, trustworthy
   ============================================ */

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

:root {
  --navy:       #1a3a5c;
  --teal:       #0e7490;
  --teal-light: #e0f2fe;
  --teal-mid:   #7dd3fc;
  --green:      #059669;
  --green-light:#d1fae5;
  --amber:      #d97706;
  --amber-light:#fef3c7;
  --red:        #dc2626;
  --red-light:  #fee2e2;
  --gray-50:    #f8fafc;
  --gray-100:   #f1f5f9;
  --gray-200:   #e2e8f0;
  --gray-400:   #94a3b8;
  --gray-600:   #475569;
  --gray-800:   #1e293b;
  --white:      #ffffff;
  --radius:     10px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:     0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg:  0 10px 30px rgba(0,0,0,0.10), 0 4px 10px rgba(0,0,0,0.05);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
.wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px 48px;
}

/* ---------- Topbar ---------- */
.topbar {
  background: var(--navy);
  padding: 0 28px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--white);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.01em;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: var(--teal);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.brand-sub {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--teal-mid);
  display: block;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ---------- Hero section (index only) ---------- */
.hero {
  width: 100%;
  max-width: 680px;
  text-align: center;
  margin-bottom: 28px;
}

.hero h1 {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 10px;
  line-height: 1.25;
}

.hero p {
  color: var(--gray-600);
  font-size: 1rem;
  max-width: 480px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--teal-light);
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 14px;
  letter-spacing: 0.03em;
}

/* ---------- Card ---------- */
.card {
  background: var(--white);
  width: 100%;
  max-width: 680px;
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  margin-bottom: 20px;
}

.card-wide {
  max-width: 1100px;
}

.card h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 4px;
}

.card-divider {
  height: 1px;
  background: var(--gray-200);
  margin: 18px 0;
}

/* ---------- Panel header ---------- */
.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-200);
}

.panel-header h2 {
  margin: 0;
  font-size: 1.3rem;
}

.badge {
  display: inline-block;
  background: var(--teal-light);
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 6px;
  letter-spacing: 0.04em;
}

/* ---------- Form Elements ---------- */
.field { position: relative; margin-bottom: 4px; }

.row {
  display: flex;
  gap: 14px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.col { flex: 1; min-width: 130px; }

.label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.input {
  width: 100%;
  padding: 10px 14px;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  color: var(--gray-800);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

.input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14,116,144,0.12);
}

.input::placeholder { color: var(--gray-400); }

select.input {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ---------- Dropdown ---------- */
.dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 280px;
  overflow-y: auto;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 50;
}

.dd-item {
  padding: 11px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-800);
  font-size: 0.93rem;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dd-item:last-child { border-bottom: none; }

.dd-item:hover {
  background: var(--teal-light);
  color: var(--teal);
}

.dd-item .dd-id {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--teal);
  background: var(--teal-light);
  padding: 2px 7px;
  border-radius: 4px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 28px;
  background: var(--teal);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  text-decoration: none;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 6px rgba(14,116,144,0.25);
}

.btn:hover {
  background: #0c6478;
  box-shadow: 0 4px 12px rgba(14,116,144,0.30);
  transform: translateY(-1px);
}

.btn:active { transform: translateY(0); }

.btn-outline {
  background: var(--white);
  color: var(--teal);
  border: 1.5px solid var(--teal);
  box-shadow: none;
}

.btn-outline:hover {
  background: var(--teal-light);
  box-shadow: none;
}

.btn-ghost {
  background: transparent;
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 7px 14px;
  font-size: 0.85rem;
  box-shadow: none;
}

.btn-ghost:hover {
  background: rgba(255,255,255,0.1);
  color: white;
  box-shadow: none;
  transform: none;
}

.btn-interpret {
  background: var(--navy);
  box-shadow: 0 2px 6px rgba(26,58,92,0.25);
}

.btn-interpret:hover {
  background: #142d49;
  box-shadow: 0 4px 12px rgba(26,58,92,0.30);
}

/* ---------- Test Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.test-card {
  background: var(--gray-50);
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  padding: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.test-card:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14,116,144,0.08);
  background: var(--white);
}

.test-title {
  font-weight: 600;
  color: var(--navy);
  font-size: 0.88rem;
  margin-bottom: 2px;
  line-height: 1.3;
}

.test-units {
  color: var(--gray-400);
  font-size: 0.78rem;
  margin-bottom: 8px;
}

.test-card .input {
  background: var(--white);
  font-size: 1rem;
  padding: 8px 12px;
}

.range {
  color: var(--gray-400);
  font-size: 0.78rem;
  margin-top: 7px;
}

.range span { color: var(--gray-600); font-weight: 500; }

/* ---------- Results Grid ---------- */
.results { margin-top: 28px; }

.results h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.grid-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.result-box {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  padding: 14px;
  position: relative;
  overflow: hidden;
}

.result-box::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: 10px 0 0 10px;
}

.result-box.normal::before  { background: var(--green); }
.result-box.low::before     { background: var(--amber); }
.result-box.high::before    { background: var(--red); }
.result-box.normal { background: #f0fdf4; border-color: #bbf7d0; }
.result-box.low    { background: #fffbeb; border-color: #fde68a; }
.result-box.high   { background: #fef2f2; border-color: #fecaca; }

.result-name {
  font-weight: 600;
  color: var(--gray-800);
  font-size: 0.88rem;
  margin-bottom: 6px;
}

.result-val {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
  margin-bottom: 4px;
}

.result-status {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.normal .result-status { background: var(--green-light); color: var(--green); }
.low    .result-status { background: var(--amber-light); color: var(--amber); }
.high   .result-status { background: var(--red-light);   color: var(--red);   }

.result-range {
  color: var(--gray-400);
  font-size: 0.78rem;
  margin-top: 4px;
}

.result-note {
  margin-top: 8px;
  color: var(--gray-600);
  font-size: 0.82rem;
  line-height: 1.4;
  border-top: 1px solid rgba(0,0,0,0.06);
  padding-top: 8px;
}

/* ---------- Clinical Summary ---------- */
.interpretation {
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  border: 1.5px solid #bae6fd;
  border-radius: 12px;
  padding: 18px 20px;
  margin-top: 18px;
}

.interpretation h4 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.interpretation p {
  color: var(--navy);
  font-size: 0.97rem;
  line-height: 1.65;
  font-weight: 500;
}

/* ---------- Disclaimer ---------- */
.disclaimer {
  background: var(--amber-light);
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 16px;
  font-size: 0.82rem;
  color: #92400e;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  line-height: 1.5;
}

/* ---------- Info cards (index page) ---------- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 680px;
  margin-bottom: 20px;
}

.info-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.info-card .icon {
  font-size: 22px;
  margin-bottom: 6px;
}

.info-card .info-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 2px;
}

.info-card .info-desc {
  font-size: 0.75rem;
  color: var(--gray-400);
}

/* ---------- Muted text ---------- */
.muted { color: var(--gray-400); font-size: 0.9rem; }

/* ---------- Alert ---------- */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  margin-top: 12px;
  font-size: 0.88rem;
}

.alert.error {
  background: var(--red-light);
  color: var(--red);
  border: 1px solid #fecaca;
}

/* ---------- Footer ---------- */
.footer {
  color: var(--gray-400);
  font-size: 0.8rem;
  text-align: center;
  margin-top: 20px;
  padding: 0 16px;
}

.footer a { color: var(--teal); text-decoration: none; }

/* ---------- Form actions ---------- */
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 22px;
  flex-wrap: wrap;
}

/* ---------- Section label ---------- */
.section-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .topbar { padding: 0 16px; }
  .card { padding: 20px 16px; }
  .row { flex-direction: column; gap: 10px; }
  .grid { grid-template-columns: 1fr 1fr; }
  .grid-results { grid-template-columns: 1fr 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.5rem; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .btn { text-align: center; }
}

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