/* Mobile-first. Dark is the default; [data-theme="light"] switches the tokens. */
:root {
  --bg-solid: #0b1220;
  --bg-image: url('/media/bg_dark.png');
  --bg-overlay: linear-gradient(180deg, rgba(7, 13, 24, 0.80), rgba(7, 13, 24, 0.94));
  --surface: rgba(18, 28, 44, 0.80);
  --surface-strong: #152136;
  --text: #e8eef8;
  --muted: #a4b1c4;
  --accent: #4fc3f7;
  --accent-2: #2dd4bf;
  --accent-text: #05202c;
  --border: rgba(130, 170, 215, 0.24);
  --grey-card: rgba(128, 136, 150, 0.26);
  --grey-text: #c3c9d3;
  --done: #34d399;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.14);
  --error: #ff8a80;
  --error-bg: rgba(255, 99, 99, 0.16);
  --notice-bg: rgba(79, 195, 247, 0.12);
  --radius: 14px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg-solid: #eef4fa;
  --bg-image: url('/media/bg_light.png');
  --bg-overlay: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(236, 244, 252, 0.92));
  --surface: rgba(255, 255, 255, 0.84);
  --surface-strong: #ffffff;
  --text: #13202e;
  --muted: #5a6878;
  --accent: #1f6fd1;
  --accent-2: #0f9d8a;
  --accent-text: #ffffff;
  --border: rgba(40, 80, 120, 0.20);
  --grey-card: rgba(100, 110, 124, 0.20);
  --grey-text: #4b5563;
  --done: #15803d;
  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.08);
  --error: #b3261e;
  --error-bg: #fdecea;
  --notice-bg: rgba(31, 111, 209, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  background: var(--bg-overlay), var(--bg-image) center / cover no-repeat fixed, var(--bg-solid);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1 { font-size: 1.5rem; margin: 0.75rem 0; }
h2 { font-size: 1.1rem; margin: 0.25rem 0 0.5rem; }

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

.container {
  padding: 0 16px 32px;
  max-width: 640px;
  margin: 0 auto;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  backdrop-filter: blur(12px) saturate(130%);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  border-bottom: 1px solid var(--border);
}
.topbar-left, .topbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.doctor-name {
  font-weight: 600;
  color: var(--muted);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inline { display: inline; margin: 0; }

.top-btn,
.back-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.top-btn:hover, .back-btn:hover, .icon-btn:hover { text-decoration: none; border-color: var(--accent); }
.top-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.icon-btn { width: 44px; padding: 0; }

.back-btn {
  padding: 10px 18px;
  margin-bottom: 4px;
  font-size: 1rem;
  color: var(--accent);
}

.ico {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
/* theme icon: moon in dark mode, sun in light mode */
.icon-sun { display: none; }
:root[data-theme="light"] .icon-sun { display: block; }
:root[data-theme="light"] .icon-moon { display: none; }

/* ---------- cards and content ---------- */
.card {
  background: var(--surface);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}
.narrow { max-width: 420px; margin: 48px auto; }

.notice {
  background: var(--notice-bg);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.95rem;
}

.flash {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--notice-bg);
  border: 1px solid var(--border);
}
.error { background: var(--error-bg); color: var(--error); border-color: transparent; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hint { font-weight: 600; color: var(--accent-2); margin: 0 0 8px; }
.pre { white-space: pre-wrap; }
.req { color: var(--error); }

/* grey feedback block at the bottom of every page */
.feedback-grey {
  background: var(--grey-card);
  color: var(--grey-text);
  margin-top: 28px;
}
.feedback-grey summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.feedback-grey form { margin-top: 8px; }

.danger-zone { border-color: var(--danger); }
.danger-zone h2 { color: var(--danger); }

/* ---------- forms ---------- */
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { font-weight: 600; margin-top: 4px; }

input, textarea, select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 10px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(1.06); }
.btn:disabled { opacity: 0.7; cursor: progress; filter: none; }
.btn-block { width: 100%; }
.btn-secondary { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-grey { background: var(--grey-card); color: var(--grey-text); border-color: var(--border); }

/* row that holds the button and the call indicator side by side */
.ai-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

/* the AI indicator: OpenAI logo + model name while the request runs */
.call-indicator {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
}
.logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}
.openai-mark {
  width: 22px;
  height: 22px;
  color: var(--text);
}

/* undo after a delete, on the main page */
.undo-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-color: var(--accent);
}

.note-input { font-size: 1rem; }
.notes-list { margin-bottom: 12px; }
.notes-list summary { cursor: pointer; font-weight: 600; min-height: 36px; display: flex; align-items: center; }
.notes-list ul { margin: 6px 0 0; padding-inline-start: 1.25rem; }

.lang-btn { font-weight: 700; }

/* ---------- lists ---------- */
.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  min-height: 44px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.list-item:hover { text-decoration: none; border-color: var(--accent); }
.ai-row-block { display: flex; flex-direction: column; gap: 6px; }
.row-title { font-weight: 600; word-break: break-word; }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li {
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}
.checklist li:last-child { border-bottom: none; }
.checklist li.done .q-text { color: var(--muted); text-decoration: line-through; }
.check-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin: 0;
}
.q-text { flex: 1; }
.chip {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
.done .chip { background: var(--done); border-color: var(--done); color: #fff; }

.steps { padding-left: 1.25rem; }
.steps li { margin-bottom: 6px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (min-width: 720px) {
  h1 { font-size: 1.75rem; }
}

/* Persian: Vazirmatn font and right-to-left layout */
html[dir="rtl"] body {
  font-family: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
}
html[dir="rtl"] .stack label { text-align: right; }
html[dir="rtl"] .list-item { text-align: right; }
html[dir="rtl"] .steps { padding-left: 0; padding-right: 1.25rem; }
html[dir="rtl"] input, html[dir="rtl"] textarea { direction: rtl; text-align: right; }



/* ---------- case header: name on one side, delete on the other ---------- */
.case-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.case-head h1 { margin: 0.75rem 0; }

.delete-box { position: relative; }
.delete-box > summary {
  list-style: none;
  cursor: pointer;
}
.delete-box > summary::-webkit-details-marker { display: none; }
.delete-box[open] > summary { opacity: 0.85; }
.delete-hint {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  z-index: 6;
  width: min(300px, 80vw);
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-strong);
  border: 1px solid var(--danger);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}
.delete-hint p { margin: 0 0 10px; font-size: 0.92rem; }

/* ---------- report an issue: one expandable box ---------- */
.report-box > summary {
  list-style: none;
  cursor: pointer;
  min-height: 48px;
  display: flex;
  align-items: center;
}
.report-box > summary::-webkit-details-marker { display: none; }
.report-box > summary::after {
  content: "＋";
  margin-inline-start: auto;
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: 700;
}
.report-box[open] > summary::after { content: "−"; }
.report-section { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.report-section h3 { font-size: 1rem; margin: 0 0 8px; }

/* ---------- language choice on the login page ---------- */
.lang-choice { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 8px; }
.chip-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
}
.chip-link.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip-link:hover { text-decoration: none; border-color: var(--accent); }

/* ---------- visit summary: pop-open box under Available history ---------- */
.visit-box > summary {
  list-style: none;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.visit-box > summary::-webkit-details-marker { display: none; }
.visit-box > summary::after {
  content: "＋";
  margin-inline-start: auto;
  color: var(--accent);
  font-size: 1.3rem;
  font-weight: 700;
}
.visit-box[open] > summary::after { content: "−"; }
.visit-body { margin-top: 12px; }
.visit-text { margin: 0 0 8px; padding: 10px 12px; border-radius: 10px; background: var(--surface-strong); border: 1px solid var(--border); }

/* ---------- examinations: name, then a Done chip ---------- */
.exam-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.exam-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.exam-item > .list-item { flex: 1; min-width: 180px; }
.exam-item.done > .list-item { opacity: 0.7; }
.exam-item.done .row-title { text-decoration: line-through; }
.exam-done { margin: 0; }
.exam-item.done .chip { background: var(--done); border-color: var(--done); color: #fff; }

/* ---------- footer bar, fixed to the bottom edge ---------- */
body { padding-bottom: 64px; }

.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 10px 18px calc(10px + env(safe-area-inset-bottom));
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--surface);
  backdrop-filter: blur(12px) saturate(130%);
  -webkit-backdrop-filter: blur(12px) saturate(130%);
  border-top: 2px solid transparent;
  border-image: linear-gradient(90deg, var(--accent), var(--accent-2), #ff6b9a) 1;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.25);
}
.site-footer .made { font-weight: 600; letter-spacing: 0.2px; }
.site-footer .copy { opacity: 0.85; white-space: nowrap; }
.site-footer .sep { opacity: 0.5; }
.site-footer .heart {
  display: inline-block;
  color: #ff5c8a;
  animation: heartbeat 1.6s ease-in-out infinite;
  text-shadow: 0 0 10px rgba(255, 92, 138, 0.7);
}
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.25); }
  30% { transform: scale(1); }
  45% { transform: scale(1.15); }
}
@media (prefers-reduced-motion: reduce) {
  .site-footer .heart { animation: none; }
}

/* ---------- access log ---------- */
.access-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.access-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; font-size: 0.88rem; }
.access-main { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.access-time { font-weight: 600; }
.access-who { color: var(--accent-2); }
.access-status { margin-inline-start: auto; font-weight: 700; }
.access-status.status-2 { color: var(--done); }
.access-status.status-3 { color: var(--muted); }
.access-status.status-4, .access-status.status-5 { color: var(--danger); }
.access-line { word-break: break-all; }
.access-line code { font-size: 0.85rem; }
.event { font-weight: 700; color: var(--accent); margin-inline-start: 6px; }
.access-details summary { cursor: pointer; color: var(--accent); min-height: 32px; display: flex; align-items: center; }
.access-details dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 10px; margin: 8px 0 0; font-size: 0.8rem; }
.access-details dt { color: var(--muted); }
.access-details dd { margin: 0; word-break: break-all; }

/* ---------- OpenAI logo: slow turn with pauses ---------- */
@keyframes logo-turn {
  0% { transform: rotate(0deg); }
  11.67% { transform: rotate(60deg); }
  16.67% { transform: rotate(60deg); }
  28.33% { transform: rotate(120deg); }
  33.33% { transform: rotate(120deg); }
  45.00% { transform: rotate(180deg); }
  50.00% { transform: rotate(180deg); }
  61.67% { transform: rotate(240deg); }
  66.67% { transform: rotate(240deg); }
  78.33% { transform: rotate(300deg); }
  83.33% { transform: rotate(300deg); }
  95.00% { transform: rotate(360deg); }
  100.00% { transform: rotate(360deg); }
  100% { transform: rotate(360deg); }
}

.openai-img {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
  animation: logo-turn 8s linear infinite;
  transform-origin: 50% 50%;
}
/* the logo is black on white: invert it so it reads on the dark theme */
:root[data-theme="dark"] .openai-img { filter: invert(1); }
@media (prefers-reduced-motion: reduce) {
  .openai-img { animation: none; }
}


/* ---------- full visit logs ---------- */
.log-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.log-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.log-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; justify-content: space-between; }
.log-time { font-weight: 600; font-variant-numeric: tabular-nums; }
.log-kind { color: var(--accent); font-weight: 600; }
.log-detail { margin: 6px 0; }
