/* ClinicFlow — shared stylesheet for all pages */

:root {
  --ink: #111111;
  --ink-soft: #374151;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f9fafb;
  --primary: #111111;
  --primary-contrast: #ffffff;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #16a34a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }

/* ---------- Accessibility: skip link + visible keyboard focus ---------- */
.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  background: #111;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: .9rem;
  text-decoration: none;
  z-index: 2000;
  transition: top .15s ease;
}
.skip-link:focus {
  top: 12px;
}

/* Consistent, visible keyboard-focus ring on every interactive element —
   applied only for keyboard navigation (:focus-visible), so mouse/touch
   clicks don't show a ring they didn't ask for. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
  border-radius: 4px;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.5;
}

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

a { color: inherit; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }

/* ---------- Header ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 8px;
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header .logo { font-weight: 800; text-decoration: none; font-size: 1.1rem; flex: 0 0 auto; }
.app-header nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 18px;
}
.app-header nav a {
  margin-left: 0;
  text-decoration: none;
  font-weight: 500;
  color: var(--ink-soft);
  white-space: nowrap;
}
.app-header nav a:hover { color: var(--ink); }

@media (max-width: 480px) {
  .app-header { padding: 14px 16px; }
  .app-header .logo { font-size: 1rem; }
  .app-header nav { gap: 4px 14px; font-size: .92rem; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  /* Fallback used whenever no hero video is present (or before it loads) —
     a richer, deliberate teal/indigo gradient rather than a flat black
     panel, so the section still looks intentional with zero video. */
  background: linear-gradient(135deg, #0f172a 0%, #164e63 45%, #0f172a 100%);
  color: #fff;
  padding: 80px 20px 60px;
  text-align: center;
}
.hero-media {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.hero-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hero-video.hidden { display: none; }
.hero-overlay {
  position: absolute;
  inset: 0;
  /* Lighter at the top, darker toward the bottom — lets the gradient/video
     underneath actually read as a gradient/video instead of flattening
     into a solid dark block, while still guaranteeing enough contrast for
     the headline and buttons lower down. */
  background: linear-gradient(180deg, rgba(15,23,42,.35) 0%, rgba(15,23,42,.55) 55%, rgba(15,23,42,.75) 100%);
}
.hero > .container { position: relative; z-index: 1; }
.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  max-width: 780px;
  margin: 0 auto .5em;
  text-shadow: 0 2px 16px rgba(0,0,0,.45);
}
.hero > .container > p {
  max-width: 640px;
  margin: 0 auto 28px;
  color: #e5e7eb;
  font-size: 1.05rem;
  text-shadow: 0 1px 10px rgba(0,0,0,.35);
}
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 56px; }
/* The primary CTA needs to pop against a dark/video hero — a plain black
   pill barely separates from the dark overlay, so invert it to white here. */
.hero-actions .btn-primary { background: #fff; color: #111111; }
.hero-actions .btn-primary:hover { opacity: .9; }
.hero-actions .btn-outline {
  background: rgba(255,255,255,.08);
  color: #fff;
  border-color: rgba(255,255,255,.5);
}
.hero-actions .btn-outline:hover { background: rgba(255,255,255,.16); }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  text-align: left;
}
.feature-card-dark {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  padding: 20px;
}
.feature-card-dark h2 { margin-bottom: 8px; }
.feature-card-dark p { color: #d1d5db; font-size: .92rem; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: .95rem;
  transition: transform .05s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { opacity: .92; }
.btn-outline { background: #fff; color: var(--ink); border-color: var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-block { display: block; width: 100%; text-align: center; }

/* ---------- Generic sections ---------- */
.section-plain { padding: 64px 20px; text-align: center; background: var(--bg); }
.section-plain h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
.section-plain .lead { color: var(--muted); margin-bottom: 40px; }

.steps-grid, .pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  max-width: 960px;
  margin: 0 auto;
  text-align: left;
}
.step-card, .pricing-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.step-num {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  margin-bottom: 12px;
}
.text-muted { color: var(--muted); }
.mt-8 { margin-top: 8px; }

.pricing-card.featured { border-color: var(--ink); box-shadow: 0 4px 24px rgba(0,0,0,.12); }
.pricing-card .price { font-size: 2rem; font-weight: 800; margin: 8px 0 16px; }
.pricing-card ul { padding-left: 18px; margin: 0 0 20px; color: var(--ink-soft); font-size: .92rem; }
.pricing-card li { margin-bottom: 6px; }

/* ---------- Footer ---------- */
.app-footer { text-align: center; padding: 32px 20px; color: var(--muted); font-size: .85rem; }

/* ---------- Auth pages ---------- */
.auth-wrap {
  min-height: calc(100vh - 65px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card { width: 100%; max-width: 440px; padding: 36px 32px; }
.auth-card h1 { font-size: 1.5rem; }
.auth-sub { color: var(--muted); margin: 0 0 24px; font-size: .92rem; }
.auth-links { text-align: center; font-size: .9rem; color: var(--muted); margin: 14px 0 0; }
.auth-links a { font-weight: 600; text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

label {
  display: block;
  font-weight: 600;
  font-size: .88rem;
  margin-bottom: 6px;
  color: var(--ink-soft);
}
.required-mark { color: var(--danger); margin-left: 2px; }
.field-hint { color: var(--muted); font-size: .78rem; margin-top: 4px; }

input, textarea, select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(17,17,17,.08);
}
input[aria-invalid="true"], textarea[aria-invalid="true"], input.invalid, textarea.invalid {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.field-error {
  display: block;
  color: var(--danger);
  font-size: .8rem;
  margin-top: 5px;
}

.otp-input-group { display: flex; gap: 8px; justify-content: center; margin: 8px 0 4px; }
.otp-input-group input {
  width: 44px; height: 52px;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  padding: 0;
}

/* ---------- Alerts ---------- */
.alert { border-radius: 8px; padding: 12px 14px; font-size: .88rem; margin-bottom: 18px; }
.alert-error { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #eff6ff; color: #1e3a8a; border: 1px solid #bfdbfe; }
.alert-actions { margin-top: 10px; display: flex; gap: 10px; flex-wrap: wrap; }
.alert-actions .btn { padding: 6px 14px; font-size: .85rem; }
.hidden { display: none !important; }

/* ---------- Cookie notice ---------- */
#cf-cookie-notice {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  max-width: 640px;
  margin: 0 auto;
  background: #111;
  color: #fff;
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  z-index: 900;
  font-size: .88rem;
}
#cf-cookie-notice p { margin: 0; flex: 1 1 260px; color: #e5e7eb; }
#cf-cookie-notice a { color: #fff; text-decoration: underline; }
#cf-cookie-notice button {
  background: #fff;
  color: #111;
  border: none;
  padding: 9px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: .85rem;
  cursor: pointer;
  flex: 0 0 auto;
}
#cf-cookie-notice button:hover { opacity: .9; }

/* ---------- Toasts ---------- */
.cf-toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  width: min(360px, calc(100vw - 32px));
}
.cf-toast {
  background: #111;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: .88rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
  box-shadow: var(--shadow);
}
.cf-toast-visible { opacity: 1; transform: translateY(0); }
.cf-toast-error { background: var(--danger); }
.cf-toast-success { background: var(--success); }

/* ---------- Legal / long-form prose pages ---------- */
.legal-doc { padding: 48px 0 80px; }
.legal-doc .container { max-width: 760px; }
.legal-doc h1 { font-size: clamp(1.7rem, 4vw, 2.2rem); }
.legal-doc h2 { font-size: 1.2rem; margin-top: 2em; margin-bottom: .6em; }
.legal-doc p { color: var(--ink-soft); line-height: 1.7; margin: 0 0 1em; }
.legal-doc ul { color: var(--ink-soft); line-height: 1.7; padding-left: 1.4em; margin: 0 0 1em; }
.legal-doc li { margin-bottom: .5em; }
.legal-doc a { color: var(--ink); text-decoration: underline; }
.legal-doc code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: .9em;
}

/* ---------- Simple app shell (dashboard placeholders) ---------- */
.app-shell { max-width: 720px; margin: 40px auto; padding: 0 20px; }

/* ---------- Dashboard two-column layout (today's schedule / recent invoices) ---------- */
.dashboard-cols {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 20px;
  margin-top: 28px;
  align-items: start;
}
.dashboard-cols > section { min-width: 0; }
.dashboard-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
@media (max-width: 680px) {
  .dashboard-cols { grid-template-columns: 1fr; }
}
.empty-state {
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}

/* ---------- Small buttons ---------- */
.btn-sm { padding: 7px 14px; font-size: .82rem; border-radius: 999px; }

/* ---------- Status badges ---------- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.badge-scheduled { background: #eff6ff; color: #1d4ed8; }
.badge-completed { background: #f0fdf4; color: #15803d; }
.badge-cancelled { background: var(--danger-bg); color: #991b1b; }
.badge-paid { background: #f0fdf4; color: #15803d; }
.badge-unpaid { background: #fffbeb; color: #b45309; }

/* ---------- Patient autocomplete suggestions ---------- */
.suggestion-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 4px;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow-y: auto;
}
.suggestion-list li[role="option"] {
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .9rem;
}
.suggestion-list li[role="option"]:hover,
.suggestion-list li[role="option"]:focus {
  background: var(--bg);
}
.suggestion-list li[role="option"]:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}

/* ---------- Appointment cards ---------- */
.appt-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.appt-card-main { flex: 1 1 260px; min-width: 0; }
.appt-card-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  flex: 0 0 auto;
  max-width: 100%;
}
.appt-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; max-width: 100%; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17,17,17,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  padding: 28px 26px;
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  border-radius: 6px;
}
.modal-close:hover { background: var(--bg); color: var(--ink); }

/* ---------- Dashboard stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.stat-card { padding: 18px 20px; }
.stat-label { color: var(--muted); font-size: .82rem; font-weight: 600; margin-bottom: 6px; }
.stat-value { font-size: 1.7rem; font-weight: 800; }
.stat-sub { color: var(--muted); font-size: .78rem; margin-top: 4px; min-height: 1em; }

/* ---------- Invoices summary bar (paid/unpaid/total) ---------- */
.summary-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.summary-item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.summary-label { display: block; color: var(--muted); font-size: .78rem; font-weight: 600; margin-bottom: 4px; }
.summary-value { display: block; font-size: 1.3rem; font-weight: 800; }

/* ---------- Dashboard mini list rows (today's schedule, recent invoices) ---------- */
.mini-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: .92rem;
}
.mini-row:last-child { border-bottom: none; }

/* ---------- Data tables (admin) ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table tr:last-child td { border-bottom: none; }

/* ---------- Patient history list ---------- */
.history-list { list-style: none; margin: 12px 0 0; padding: 0; }
.history-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.history-list li:last-child { border-bottom: none; }
