/* =========================================================
   AfterSurg – Surgeon Admin
   styles.css  ·  clean clinical design system
   ========================================================= */

:root {
  /* Palette — calm clinical teal */
  --bg-1:        #eef6f4;
  --bg-2:        #e3f0ef;
  --ink:         #1f3434;
  --ink-soft:    #5a7270;
  --ink-faint:   #8aa0a0;

  --primary:     #0ca6a6;   /* teal */
  --primary-700: #088383;
  --accent:      #18c096;   /* emerald */
  --danger:      #d8463c;
  --danger-soft: #fbeceb;

  --surface:     #ffffff;
  --surface-2:   #f6faf9;
  --line:        #e3ecea;
  --line-soft:   #eef4f3;

  --radius:      16px;
  --radius-sm:   10px;
  --radius-xs:   8px;

  --shadow-sm:   0 1px 2px rgba(16, 50, 48, .06);
  --shadow:      0 10px 30px -12px rgba(16, 50, 48, .22);
  --shadow-lg:   0 24px 60px -20px rgba(16, 50, 48, .28);

  --ease:        .18s cubic-bezier(.4, 0, .2, 1);
  --font:        'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

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

html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1100px 600px at 15% -10%, #f3faf8 0%, transparent 55%),
    radial-gradient(900px 700px at 110% 10%, #e8f4f2 0%, transparent 50%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px 96px;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ── Card shell ─────────────────────────────────────────── */
.card {
  display: none;
  flex-direction: column;
  gap: 18px;
  width: 580px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 30px 28px;
  animation: rise .28s ease both;
}

.card.is-active { display: flex; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Scrollable long forms */
.card--scrollable {
  padding: 0;
  gap: 0;
  max-height: min(88vh, 920px);
  overflow: hidden;
}
.card--scrollable .card__header {
  padding: 28px 30px 6px;
  flex-shrink: 0;
}
.card--scrollable .card__body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 30px 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.card--scrollable .card__body::-webkit-scrollbar { width: 8px; }
.card--scrollable .card__body::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 99px;
}
.card--scrollable .card__footer {
  flex-shrink: 0;
  padding: 14px 30px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--line-soft);
}

/* ── Headings ───────────────────────────────────────────── */
.card__title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--ink);
}
.card__subtitle {
  margin: -8px 0 2px;
  font-size: .9rem;
  color: var(--ink-soft);
}
.eyebrow {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--primary);
  margin: 0 0 2px;
}

/* ── Form sections (the consistent style across all pages) ─ */
.form-section {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.form-section__title {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label,
.file-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.hint {
  font-size: .8rem;
  color: var(--ink-faint);
  margin: 0;
}

/* ── Inputs ─────────────────────────────────────────────── */
input, select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: .94rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 11px 12px;
  transition: border-color var(--ease), box-shadow var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(12, 166, 166, .14);
}
textarea { min-height: 84px; resize: vertical; }
input[type="file"] {
  padding: 8px 10px;
  font-size: .82rem;
  background: var(--surface-2);
  cursor: pointer;
}
input[type="file"]::file-selector-button {
  margin-right: 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 6px 12px;
  font: inherit;
  font-size: .82rem;
  cursor: pointer;
  transition: var(--ease);
}
input[type="file"]::file-selector-button:hover { background: var(--surface-2); }

/* ── Buttons ────────────────────────────────────────────── */
button {
  font-family: inherit;
  font-size: .94rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-xs);
  padding: 11px 18px;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform var(--ease), background var(--ease),
              box-shadow var(--ease), border-color var(--ease), color var(--ease);
}
button:active { transform: translateY(1px); }

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { box-shadow: 0 8px 20px -8px rgba(12,166,166,.6); }

.btn-ghost {
  color: var(--ink-soft);
  background: var(--surface);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger {
  color: var(--danger);
  background: var(--surface);
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-soft); }

.btn-block { width: 100%; }

/* ── Layout helpers ─────────────────────────────────────── */
.row  { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row--3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

@media (max-width: 520px) {
  .row, .row--3 { grid-template-columns: 1fr; }
  .card { padding: 24px 18px 20px; }
}

/* ── Hub tiles (Add / Modify / Stats and sub-options) ───── */
.tile-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.tile {
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  padding: 18px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: transform var(--ease), border-color var(--ease),
              box-shadow var(--ease), background var(--ease);
}
.tile:hover {
  transform: translateY(-2px);
  border-color: rgba(12,166,166,.4);
  box-shadow: var(--shadow);
  background: var(--surface);
}
.tile__icon {
  flex-shrink: 0;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(24,192,150,.16), rgba(12,166,166,.16));
  color: var(--primary-700);
}
.tile__icon svg { width: 24px; height: 24px; }
.tile__text { display: flex; flex-direction: column; gap: 2px; }
.tile__text strong { font-size: 1rem; font-weight: 700; color: var(--ink); }
.tile__text span { font-size: .82rem; color: var(--ink-soft); }
.tile__chev { margin-left: auto; color: var(--ink-faint); transition: var(--ease); }
.tile:hover .tile__chev { color: var(--primary); transform: translateX(2px); }

/* ── Login ──────────────────────────────────────────────── */
.login__logo { width: 150px; margin: 4px auto 6px; display: block; }
.login__brand { text-align: center; }
.login__brand h1 { margin: 0; font-size: 1.45rem; letter-spacing: -.01em; }
.login__brand p  { margin: 4px 0 0; color: var(--ink-soft); font-size: .9rem; }
#googleSignIn img { width: 22px; height: 22px; flex-shrink: 0; }

/* ── Toggles ────────────────────────────────────────────── */
.toggleRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--surface);
}
.toggleRow span {
  font-size: .9rem;
  color: var(--ink);
  line-height: 1.35;
}

/* iOS-style switch */
.switch { position: relative; flex-shrink: 0; width: 44px; height: 26px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0;
  background: #cfdedc; border-radius: 99px;
  transition: var(--ease);
}
.switch .track::before {
  content: ""; position: absolute;
  top: 3px; left: 3px; width: 20px; height: 20px;
  background: #fff; border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: var(--ease);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::before { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px rgba(12,166,166,.25); }

/* ── Stats boxes ────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 14px;
}
.stat {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat .label {
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.stat .value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--ink);
  line-height: 1;
}
.stat--accent { background: linear-gradient(135deg, rgba(24,192,150,.12), rgba(12,166,166,.1)); border-color: rgba(12,166,166,.2); }
.stat--accent .value { color: var(--primary-700); }

/* ── Wide card (stats dashboard) ────────────────────────── */
.card--wide { width: 760px; }

/* ── Charts ─────────────────────────────────────────────── */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 260px;
}
.chart-wrap--sm { height: 230px; }

/* ── Charts stacked one atop the other ──────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.chart-grid .form-section { margin: 0; }
.chart-grid .chart-wrap { height: 260px; }

/* ── Info button (table rows + charts) ──────────────────── */
.info-btn {
  width: 28px; height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-style: italic;
  font-weight: 700;
  font-family: Georgia, 'Times New Roman', serif;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.info-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.table td.cell-actions { text-align: right; width: 44px; }

/* ── Bulk export (Analysis) ─────────────────────────────── */
.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.bulk-bar .hint { margin: 0; }
.bulk-bar #anDownloadBtn { margin-left: auto; }
.btn-sm { padding: 8px 16px; font-size: .85rem; }
.btn-primary:disabled {
  background: var(--surface-2);
  color: var(--ink-faint);
  border: 1px solid var(--line);
  opacity: 1;
  box-shadow: none;
  cursor: not-allowed;
}

.cell-check { width: 46px; text-align: center; }
.cell-check input[type="checkbox"] {
  width: 20px; height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
  vertical-align: middle;
  margin: 0;
}
.cell-check input[type="checkbox"]:disabled { cursor: not-allowed; opacity: .3; }

/* ── Patient info modal ─────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 40, 38, .42);
  backdrop-filter: blur(2px);
  animation: fade .15s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative;
  width: 420px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 26px 26px 24px;
  animation: rise .2s ease both;
}
.modal__title { margin: 0 0 16px; font-size: 1.2rem; font-weight: 700; color: var(--ink); }
.modal__close {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px; padding: 0;
  border-radius: 50%; border: none;
  background: var(--surface-2); color: var(--ink-soft);
  font-size: 20px; line-height: 1;
}
.modal__close:hover { background: var(--danger-soft); color: var(--danger); }

.info-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 18px;
  margin: 0;
}
.info-grid dt {
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-faint);
  align-self: center;
}
.info-grid dd {
  margin: 0;
  font-size: .95rem;
  color: var(--ink);
  font-weight: 500;
  word-break: break-word;
}

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 340px;
}
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  text-align: left;
  font-weight: 700;
  font-size: .74rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table a {
  color: var(--primary-700);
  font-weight: 600;
  text-decoration: none;
}
.table a:hover { text-decoration: underline; }
.table .muted { color: var(--ink-faint); }
.table-empty { text-align: center; color: var(--ink-faint); padding: 22px 12px; }

/* ── Group chips ────────────────────────────────────────── */
.chip-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 20px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: .84rem;
  color: var(--ink);
}
.chip button {
  border: none; background: transparent;
  color: var(--ink-faint);
  width: 20px; height: 20px;
  border-radius: 50%;
  padding: 0; font-size: 15px; line-height: 1;
}
.chip button:hover { background: var(--danger-soft); color: var(--danger); }
.chip-empty { color: var(--ink-faint); font-size: .84rem; }

/* ── Error text ─────────────────────────────────────────── */
.error-text { color: var(--danger); font-size: .85rem; min-height: 18px; margin: 0; }
.usage-note { font-size: .82rem; color: var(--ink-soft); margin: 0; }

/* ── Footer ─────────────────────────────────────────────── */
#footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  text-align: center;
  padding: 12px 0;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #fff;
  font-size: .8rem;
  letter-spacing: .03em;
  z-index: 10;
}

/* ── Loading dots ───────────────────────────────────────── */
.loading { display: inline-flex; gap: 5px; align-items: center; color: var(--ink-faint); font-size: .85rem; }
.loading::before {
  content: ""; width: 14px; height: 14px;
  border: 2px solid var(--line); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }
