/* ── RxVoice — Refined Medical UI ─────────────────────────────── */
:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface2: #f9f8f5;
  --border: #e2dfd8;
  --text: #1a1714;
  --text-2: #5a5650;
  --text-3: #9a9690;

  --primary: #1a5276;
  --primary-light: #d6e8f5;
  --primary-dark: #0f3352;

  --doctor: #1a4d3e;
  --doctor-light: #d4ede5;

  --success: #1a5c2e;
  --success-light: #d4edda;
  --warning: #7a4b00;
  --warning-light: #fff3cd;
  --error: #7a1a1a;
  --error-light: #fde8e8;
  --info: #1a3a7a;
  --info-light: #d4e3fa;

  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.05);
  --shadow-lg: 0 4px 24px rgba(0,0,0,.10);

  --font-serif: 'DM Serif Display', Georgia, serif;
  --font-sans: 'DM Sans', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Navbar ─────────────────────────────────────────────────────── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(0,0,0,.06);
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.brand-icon { font-size: 1.5rem; }
.brand-name {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  color: var(--primary);
  letter-spacing: -.5px;
}
.role-doctor .brand-name { color: var(--doctor); }

.nav-links { display: flex; align-items: center; gap: 8px; }
.nav-links a {
  text-decoration: none;
  color: var(--text-2);
  font-size: .9rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.nav-links a:hover { background: var(--bg); color: var(--text); }
.btn-logout {
  background: var(--bg) !important;
  border: 1px solid var(--border);
  color: var(--error) !important;
}

/* ── Main Content ────────────────────────────────────────────────── */
.main-content { flex: 1; }

.page-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.page-header h2 {
  font-family: var(--font-serif);
  font-size: 1.9rem;
  color: var(--text);
  line-height: 1.2;
}
.page-sub { color: var(--text-2); font-size: .9rem; margin-top: 4px; }

/* ── Auth ────────────────────────────────────────────────────────── */
.auth-wrap {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: linear-gradient(135deg, #e8f0f7 0%, #f5f4f0 50%, #e8f4ee 100%);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 440px;
}
.auth-brand {
  text-align: center;
  margin-bottom: 32px;
}
.auth-icon { font-size: 2.5rem; display: block; margin-bottom: 8px; }
.auth-brand h1 {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  color: var(--primary);
  margin-bottom: 4px;
}
.auth-brand p { color: var(--text-2); font-size: .9rem; }
.auth-footer { text-align: center; margin-top: 20px; font-size: .9rem; color: var(--text-2); }
.auth-footer a { color: var(--primary); font-weight: 600; }

.demo-box {
  margin-top: 24px;
  padding: 14px 16px;
  background: var(--primary-light);
  border: 1px solid #c2d8ec;
  border-radius: 8px;
  font-size: .85rem;
}
.demo-box strong { display: block; margin-bottom: 8px; color: var(--primary); }
.demo-creds { display: flex; flex-direction: column; gap: 4px; color: var(--primary-dark); font-family: monospace; }

/* ── Forms ───────────────────────────────────────────────────────── */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: .95rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.field textarea { resize: vertical; }
.field-hint { font-size: .8rem; color: var(--text-3); margin-left: 8px; font-weight: 400; text-transform: none; }
.field-opt { font-size: .8rem; color: var(--text-3); font-weight: 400; text-transform: none; }
.req { color: var(--error); }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 20px; }
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow);
}
.form-actions { display: flex; gap: 12px; margin-top: 24px; }

.otp-input { font-size: 1.5rem; letter-spacing: .3em; text-align: center; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1.5px solid transparent;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: var(--surface2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #144d26; }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-full { width: 100%; justify-content: center; padding: 12px; }
.btn-sm { padding: 6px 12px; font-size: .82rem; }

.btn-voice {
  background: linear-gradient(135deg, #c0392b, #e74c3c);
  color: #fff;
  border-color: #c0392b;
  padding: 12px 24px;
  font-size: 1rem;
  border-radius: 50px;
  box-shadow: 0 4px 12px rgba(192,57,43,.3);
}
.btn-voice:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(192,57,43,.4); }
.btn-voice-stop {
  background: linear-gradient(135deg, #555, #333);
  color: #fff;
  border-color: #333;
  border-radius: 50px;
  padding: 12px 24px;
}

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: .9rem;
  border-left: 4px solid;
}
.alert-error   { background: var(--error-light); color: var(--error); border-color: var(--error); }
.alert-success { background: var(--success-light); color: var(--success); border-color: var(--success); }
.alert-warning { background: var(--warning-light); color: var(--warning); border-color: var(--warning); }
.alert-info    { background: var(--info-light); color: var(--info); border-color: var(--info); }

/* ── Stats ───────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--primary);
}
.stat-card-doctor { border-top-color: var(--doctor); }
.stat-num { font-family: var(--font-serif); font-size: 2.2rem; color: var(--primary); line-height: 1; }
.stat-card-doctor .stat-num { color: var(--doctor); }
.stat-label { color: var(--text-2); font-size: .85rem; margin-top: 4px; }

/* ── Tables ──────────────────────────────────────────────────────── */
.section-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow);
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  background: var(--surface2);
  padding: 12px 16px;
  text-align: left;
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 14px 16px; border-bottom: 1px solid var(--bg); font-size: .9rem; vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }

/* ── Badges ──────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-pending    { background: var(--warning-light); color: var(--warning); }
.badge-reviewed   { background: var(--info-light); color: var(--info); }
.badge-prescribed { background: var(--success-light); color: var(--success); }
.badge-draft      { background: var(--bg); color: var(--text-2); }
.badge-approved   { background: var(--success-light); color: var(--success); }

/* ── Doctor Appointments Grid ────────────────────────────────────── */
.appointments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}
.appt-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: box-shadow .2s;
}
.appt-card:hover { box-shadow: var(--shadow-lg); }
.appt-card-prescribed { border-left: 3px solid var(--success); }
.appt-card-pending { border-left: 3px solid var(--warning); }

.appt-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.patient-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.appt-card-header > div:nth-child(2) { flex: 1; }
.appt-meta { font-size: .8rem; color: var(--text-3); }
.appt-problem { font-size: .88rem; color: var(--text-2); margin-bottom: 10px; line-height: 1.5; }
.appt-date { font-size: .8rem; color: var(--text-3); margin-bottom: 14px; }
.appt-actions { display: flex; gap: 8px; }

/* ── Appointment Detail ──────────────────────────────────────────── */
.appt-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1.8fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) { .appt-detail-grid { grid-template-columns: 1fr; } }

.info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.info-card-title {
  padding: 12px 18px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: .85rem;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.info-card-body { padding: 18px; }

.problem-img {
  max-width: 100%;
  border-radius: 6px;
  cursor: pointer;
  transition: all .2s;
}
.problem-img.zoomed { max-width: none; width: 100%; }

/* ── Voice Controls ──────────────────────────────────────────────── */
.voice-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.voice-status { font-size: .85rem; color: var(--text-2); }

.voice-indicator {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 24px;
}
.voice-indicator span {
  display: block;
  width: 4px;
  background: #e74c3c;
  border-radius: 2px;
  animation: wave 1s ease-in-out infinite;
}
.voice-indicator span:nth-child(1) { height: 8px; animation-delay: 0s; }
.voice-indicator span:nth-child(2) { height: 16px; animation-delay: .15s; }
.voice-indicator span:nth-child(3) { height: 22px; animation-delay: .3s; }
.voice-indicator span:nth-child(4) { height: 12px; animation-delay: .45s; }
@keyframes wave {
  0%,100% { transform: scaleY(1); }
  50% { transform: scaleY(0.3); }
}

.voice-textarea {
  font-family: var(--font-sans) !important;
  background: #fffdf5 !important;
  border-color: #d4c97a !important;
}
.ai-parse-wrap { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.ai-hint { font-size: .8rem; color: var(--text-3); }
.rx-form-actions { display: flex; gap: 12px; margin-top: 20px; }

.approved-badge {
  background: var(--success-light);
  color: var(--success);
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 700;
  margin-bottom: 16px;
}
.rx-readonly {}
.rx-ro-label { font-size: .75rem; font-weight: 700; color: var(--text-3); text-transform: uppercase; margin-top: 12px; margin-bottom: 4px; }
.rx-ro-val { color: var(--text); font-size: .9rem; }

/* ── Upload Zone ─────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  position: relative;
  cursor: pointer;
  transition: border-color .15s;
}
.upload-zone:hover { border-color: var(--primary); }
.file-input {
  position: absolute; inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100% !important;
  height: 100%;
}
.upload-icon { font-size: 2rem; display: block; margin-bottom: 8px; }
.upload-label p { font-size: .9rem; color: var(--text-2); }
.upload-label small { color: var(--text-3); font-size: .8rem; }
.image-preview img { max-width: 100%; max-height: 240px; border-radius: 6px; }
.hidden { display: none !important; }
.text-muted { color: var(--text-3); font-size: .85rem; }

/* ── Empty State ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-2);
}
.empty-icon { font-size: 3rem; margin-bottom: 16px; }

/* ── Footer ──────────────────────────────────────────────────────── */
.footer {
  padding: 20px 24px;
  text-align: center;
  font-size: .82rem;
  color: var(--text-3);
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: auto;
}

/* ── PRESCRIPTION DOCUMENT ───────────────────────────────────────── */
.toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
}
.toolbar-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.rx-document {
  max-width: 860px;
  margin: 32px auto;
  background: #fff;
  border: 1px solid #d4cfc8;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
  padding: 48px 56px;
  font-family: var(--font-sans);
}

.rx-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 20px;
}
.rx-clinic-name {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--primary);
  margin-bottom: 4px;
}
.rx-clinic p { font-size: .85rem; color: var(--text-2); line-height: 1.8; }
.rx-doctor-info { text-align: right; }
.rx-doctor-info h2 { font-family: var(--font-serif); font-size: 1.2rem; color: var(--text); margin-bottom: 4px; }
.rx-doctor-info p { font-size: .82rem; color: var(--text-2); line-height: 1.8; }

.rx-divider { height: 2px; background: linear-gradient(to right, var(--primary), var(--doctor)); margin: 16px 0; }

.rx-patient-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 24px;
}
.rx-patient-field {
  flex: 1;
  min-width: 120px;
  padding: 10px 14px;
  border-right: 1px solid var(--border);
}
.rx-patient-field:last-child { border-right: none; }
.rx-patient-field label {
  display: block;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-3);
  margin-bottom: 2px;
}
.rx-patient-field span { font-size: .9rem; font-weight: 600; color: var(--text); }

.rx-section { margin-bottom: 20px; }
.rx-section-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 4px 10px;
  display: inline-block;
  border-radius: 4px;
  margin-bottom: 8px;
  background: var(--surface2);
  color: var(--text-2);
}
.rx-label-diag   { background: #edf3fb; color: #1a3a7a; }
.rx-label-med     { background: #f0faf4; color: #1a5c2e; }
.rx-label-test    { background: #fdf5e8; color: #7a4b00; }
.rx-label-advice  { background: #f5f0fb; color: #5a1a7a; }

.rx-section-body { font-size: .9rem; line-height: 1.8; color: var(--text); padding-left: 2px; }

.rx-medicines { display: flex; flex-direction: column; gap: 6px; }
.rx-med-row { display: flex; gap: 10px; align-items: baseline; }
.rx-med-num {
  min-width: 22px;
  height: 22px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: .7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rx-followup {
  background: #fef9e7;
  border: 1px solid #f9d876;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: .9rem;
  margin-bottom: 20px;
  color: #7a5800;
}

.rx-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.rx-sig-line {
  width: 180px;
  height: 1px;
  background: var(--text);
  margin-bottom: 6px;
}
.rx-signature p { font-weight: 600; font-size: .9rem; }
.rx-signature small { color: var(--text-3); font-size: .8rem; }
.stamp-circle {
  width: 72px;
  height: 72px;
  border: 3px solid var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  opacity: .3;
}
.rx-meta {
  text-align: center;
  margin-top: 24px;
  color: var(--text-3);
  font-size: .75rem;
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-inner { padding: 0 16px; }
  .page-wrap { padding: 20px 16px; }
  .page-header { flex-direction: column; }
  .auth-card { padding: 28px 20px; }
  .form-card { padding: 20px; }
  .rx-document { padding: 24px 20px; margin: 16px; }
  .rx-header { flex-direction: column; }
  .rx-doctor-info { text-align: left; }
  .appointments-grid { grid-template-columns: 1fr; }
  .nav-links a { padding: 6px 8px; font-size: .82rem; }
}
