/* Palette matching the desktop app */
:root {
  --bg:       #F0F2F5;
  --card:     #FFFFFF;
  --hdr:      #1A237E;
  --primary:  #1565C0;
  --success:  #2E7D32;
  --danger:   #C62828;
  --warning:  #E65100;
  --text1:    #212121;
  --text2:    #616161;
  --border:   #DDE1E7;
  --input-bg: #F8FAFC;
  --ff:       "Segoe UI", Arial, sans-serif;
}

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

body {
  font-family: var(--ff);
  background: var(--bg);
  color: var(--text1);
  min-height: 100vh;
  direction: rtl;
}

/* ── Topbar ────────────────────────────────── */
.topbar {
  background: var(--hdr);
  color: #fff;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-title { font-size: 15px; font-weight: 700; }
.topbar-logout {
  color: rgba(255,255,255,.8);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 12px;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 4px;
}
.topbar-logout:hover { background: rgba(255,255,255,.1); }

/* ── Page layout ───────────────────────────── */
.page-content {
  max-width: 860px;
  margin: 32px auto;
  padding: 0 16px;
}

/* ── Card ──────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: 10px;
  padding: 28px 32px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  margin-bottom: 20px;
}
.card-narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
.card-title { font-size: 20px; font-weight: 700; color: var(--hdr); margin-bottom: 6px; }
.card-subtitle { color: var(--text2); font-size: 14px; margin-bottom: 20px; }
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.center-content { text-align: center; }

/* ── Alerts ────────────────────────────────── */
.alert {
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 14px;
}
.alert-error   { background: #FFEBEE; color: var(--danger); }
.alert-success { background: #E8F5E9; color: var(--success); }
.alert-warning { background: #FFF3E0; color: var(--warning); }

/* ── Buttons ───────────────────────────────── */
.btn {
  display: inline-block;
  padding: 9px 20px;
  border-radius: 6px;
  font-family: var(--ff);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:not(:disabled):hover { opacity: .88; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-secondary { background: var(--input-bg); color: var(--text1); border: 1px solid var(--border); }
.btn-ghost   { background: transparent; color: var(--text2); }
.btn-full    { width: 100%; text-align: center; margin-top: 8px; }
.btn-sm      { padding: 5px 12px; font-size: 13px; }
.btn-row     { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* ── Form fields ───────────────────────────── */
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 5px;
  margin-top: 14px;
}
.field-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  font-family: var(--ff);
  font-size: 14px;
  color: var(--text1);
  direction: rtl;
}
.field-input:focus { outline: none; border-color: var(--primary); }
.field-input-sm { width: auto; min-width: 120px; }
.field-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--input-bg);
  font-family: var(--ff);
  font-size: 14px;
  color: var(--text1);
  direction: rtl;
  resize: vertical;
}
.field-textarea:focus { outline: none; border-color: var(--primary); }

/* ── Inline form ───────────────────────────── */
.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 0;
  flex-wrap: wrap;
}

/* ── Patient search ────────────────────────── */
.search-bar { margin: 12px 0 4px; }
.search-bar .field-input { max-width: 320px; }

/* ── Patients table ────────────────────────── */
.patients-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 8px;
}
.patients-table th,
.patients-table td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.patients-table th { color: var(--text2); font-weight: 600; font-size: 12px; }
.patients-table tr:hover td { background: #F5F7FA; }
.code-cell { font-family: monospace; color: var(--text2); }
.actions-cell { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; }
.empty-msg { color: var(--text2); text-align: center; padding: 24px 0; }

/* ── Recording ─────────────────────────────── */
.volume-bar-wrap {
  height: 18px;
  background: var(--input-bg);
  border-radius: 9px;
  overflow: hidden;
  margin: 12px 0 8px;
  border: 1px solid var(--border);
}
.volume-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #2E7D32, #66BB6A, #AED581);
  transition: width .08s;
  border-radius: 9px;
}
.rec-indicator {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: #E53935;
  margin-bottom: 10px;
}
.rec-dot {
  width: 12px;
  height: 12px;
  background: #E53935;
  border-radius: 50%;
  animation: rec-blink 1s ease-in-out infinite;
}
@keyframes rec-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.15; }
}
.timer-display {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--hdr);
  text-align: center;
  margin: 10px 0;
  font-variant-numeric: tabular-nums;
}
.status-msg { text-align: center; color: var(--text2); font-size: 14px; margin: 8px 0; }
.hint-text  { color: var(--text2); font-size: 13px; margin-top: 8px; }

/* ── Spinner ───────────────────────────────── */
.spinner {
  width: 36px; height: 36px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 20px auto;
}
.spinner-large { width: 56px; height: 56px; border-width: 5px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Summary & chat ────────────────────────── */
.summary-box {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.7;
  min-height: 120px;
  margin-bottom: 20px;
}
.chat-section { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 20px; }
.section-title { font-size: 16px; font-weight: 700; color: var(--hdr); margin-bottom: 12px; }
.chat-history { max-height: 280px; overflow-y: auto; margin-bottom: 12px; }
.chat-msg {
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.chat-msg-user      { background: #E3F2FD; }
.chat-msg-assistant { background: #F3E5F5; }
.chat-role { font-weight: 700; margin-left: 6px; }
.chat-input-row { display: flex; gap: 10px; align-items: flex-end; }
.chat-input { flex: 1; }

/* ── Save form ─────────────────────────────── */
.save-form { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 20px; }
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text1);
  margin-bottom: 10px;
  cursor: pointer;
}

/* ── Recommendations panel ─────────────────── */
.recs-panel {
  background: #FFF8E1;
  border: 1px solid #FFE082;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text1);
}

/* ── Recovery code display ─────────────────── */
.recovery-code-display {
  font-family: monospace;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 4px;
  text-align: center;
  background: var(--input-bg);
  border: 2px dashed var(--warning);
  border-radius: 8px;
  padding: 18px 12px;
  margin: 16px 0;
  user-select: all;
  color: var(--text1);
}

/* ── Utility ───────────────────────────────── */
.panel-hidden { display: none !important; }

/* ── Progress bar (transcribing / summarizing) ─────────────────────────── */
.progress-track {
  width: 100%;
  height: 16px;
  background: #E3E7ED;
  border-radius: 8px;
  overflow: hidden;
  margin: 20px 0 8px;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--primary);
  border-radius: 8px;
  transition: width 0.6s ease;
}
.progress-pct {
  font-size: 1.15em;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 4px;
}

/* ── Recording source picker modal ─────────── */
.source-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.source-modal {
  position: relative;
  background: var(--card);
  border-radius: 14px;
  padding: 26px 26px 22px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  text-align: center;
}
.source-modal-close {
  position: absolute;
  top: 10px;
  left: 12px;
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text2);
  cursor: pointer;
}
.source-modal-title { font-size: 1.2em; margin-bottom: 4px; }
.source-modal-subtitle { color: var(--text2); font-size: .95em; margin-bottom: 16px; }
.source-option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  font-family: var(--ff);
  text-align: right;
  transition: border-color .15s, background .15s;
}
.source-option:hover {
  border-color: var(--primary);
  background: #EEF4FB;
}
.source-option-icon { font-size: 24px; flex-shrink: 0; }
.source-option-text { display: flex; flex-direction: column; gap: 2px; }
.source-option-text b { font-size: 1em; color: var(--text1); }
.source-option-text small { color: var(--text2); font-size: .85em; line-height: 1.4; }

/* Session-summary emphasis (<b>/<u>/<mark>) — rendered wherever a summary shows */
mark { background: #FFF3A3; color: inherit; padding: 0 1px; border-radius: 2px; }
.summary-box u, .session-text u { text-decoration: underline; }

/* Bold / underline / highlight toolbar above the summary editor */
.fmt-toolbar { display: flex; gap: 6px; margin-bottom: 8px; }
.fmt-btn {
  min-width: 34px; padding: 4px 9px; border: 1px solid var(--border);
  background: #fff; border-radius: 6px; cursor: pointer;
  font-family: var(--ff); font-size: 15px; line-height: 1; color: var(--text1);
}
.fmt-btn:hover { background: #EEF4FB; border-color: var(--primary); }
