/* =====================================================
   Portal styles — admin panel + patient portal
   Builds on the tokens in style.css (teal / sage / gold)
   ===================================================== */
body.portal { background: var(--teal-50); min-height: 100vh; font-size: 15px; }
.portal :focus-visible { outline: 3px solid var(--gold-400); outline-offset: 2px; }
.hidden { display: none !important; }

/* ── Login screen ── */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--gradient-soft); }
.auth-card { width: 100%; max-width: 440px; background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); padding: 36px 32px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-brand .logo-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--gradient-primary); display: grid; place-items: center; font-size: 1.3rem; }
.auth-brand strong { display: block; font-family: var(--font-serif); font-size: 1.15rem; line-height: 1.2; }
.auth-brand span { font-size: .78rem; color: var(--text-light); }
.auth-card h1 { font-family: var(--font-serif); font-size: 1.6rem; margin-bottom: 4px; }
.auth-card .sub { color: var(--text-light); margin-bottom: 22px; font-size: .9rem; }
.auth-tabs { display: flex; background: var(--teal-50); border-radius: var(--radius-full); padding: 4px; margin-bottom: 22px; }
.auth-tabs button { flex: 1; padding: 9px 12px; border-radius: var(--radius-full); font-weight: 600; font-size: .85rem; color: var(--text-medium); }
.auth-tabs button[aria-selected="true"] { background: var(--white); color: var(--teal-700); box-shadow: var(--shadow-sm); }
.auth-card .btn { width: 100%; justify-content: center; margin-top: 6px; }
.auth-hint { margin-top: 16px; font-size: .8rem; color: var(--text-light); background: var(--gold-100); border: 1px solid var(--gold-300); border-radius: var(--radius-sm); padding: 10px 12px; }
.auth-error { color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca; border-radius: var(--radius-sm); padding: 9px 12px; font-size: .85rem; margin-bottom: 12px; }
.auth-back { display: inline-block; margin-top: 18px; font-size: .85rem; color: var(--teal-700); font-weight: 600; }
.pw-wrap { position: relative; }
.pw-wrap .form-control { padding-right: 56px; }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: .75rem; font-weight: 600; color: var(--teal-700); padding: 6px 8px; }

/* ── Admin shell ── */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--teal-900); color: #d7efeb; padding: 22px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.side .auth-brand { padding: 0 8px; margin-bottom: 26px; }
.side .auth-brand strong { color: #fff; font-size: 1rem; }
.side .auth-brand span { color: #8fc7bf; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side nav button { text-align: left; padding: 11px 14px; border-radius: var(--radius-sm); color: #cfe9e5; font-weight: 500; font-size: .92rem; display: flex; align-items: center; gap: 10px; }
.side nav button:hover { background: rgba(255,255,255,.07); }
.side nav button[aria-current="page"] { background: var(--teal-600); color: #fff; font-weight: 600; }
.side nav .count { margin-left: auto; background: var(--gold-400); color: #3b2300; font-size: .72rem; font-weight: 700; border-radius: var(--radius-full); padding: 1px 8px; }
.side .side-foot { border-top: 1px solid rgba(255,255,255,.12); padding-top: 14px; display: grid; gap: 6px; }
.side .side-foot a, .side .side-foot button { color: #cfe9e5; font-size: .85rem; padding: 8px 14px; text-align: left; border-radius: var(--radius-sm); }
.side .side-foot a:hover, .side .side-foot button:hover { background: rgba(255,255,255,.07); }

.main { padding: 28px 32px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-family: var(--font-serif); font-size: 1.8rem; line-height: 1.2; }
.page-head p { color: var(--text-light); font-size: .9rem; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-sm { padding: 8px 16px !important; font-size: .82rem !important; }
.btn-ghost { background: var(--white); border: 1.5px solid var(--teal-200); color: var(--teal-700); }
.btn-ghost:hover { background: var(--teal-50); }
.btn-danger { background: #fef2f2; border: 1.5px solid #fecaca; color: #b91c1c; }
.btn-danger:hover { background: #fee2e2; }

/* ── Cards, stats ── */
.card { background: var(--white); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); border: 1px solid var(--teal-100); padding: 20px 22px; }
.card + .card { margin-top: 18px; }
.card h2 { font-family: var(--font-serif); font-size: 1.15rem; margin-bottom: 12px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--white); border: 1px solid var(--teal-100); border-radius: var(--radius-md); padding: 16px 18px; }
.stat b { display: block; font-size: 1.9rem; font-family: var(--font-serif); color: var(--teal-700); line-height: 1.1; }
.stat span { font-size: .82rem; color: var(--text-light); }
.stat.warn b { color: var(--gold-500); }
.stat.alert b { color: #b91c1c; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.two-col .card + .card { margin-top: 0; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th { text-align: left; font-weight: 600; color: var(--text-light); font-size: .78rem; padding: 10px 12px; border-bottom: 2px solid var(--teal-100); white-space: nowrap; }
table.data td { padding: 12px; border-bottom: 1px solid var(--teal-50); vertical-align: top; }
table.data tr:hover td { background: var(--teal-50); }
table.data .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { text-align: center; padding: 34px 16px; color: var(--text-light); }
.empty b { display: block; color: var(--text-medium); font-size: 1rem; margin-bottom: 4px; }

/* ── Badges ── */
.badge { display: inline-block; padding: 3px 11px; border-radius: var(--radius-full); font-size: .75rem; font-weight: 600; white-space: nowrap; }
.b-green { background: #dcfce7; color: #166534; }
.b-teal { background: var(--teal-100); color: var(--teal-800); }
.b-gold { background: var(--gold-200); color: #854d0e; }
.b-red { background: #fee2e2; color: #991b1b; }
.b-grey { background: #e5e7eb; color: #374151; }
.b-blue { background: #dbeafe; color: #1e40af; }

/* ── Toolbar / filters ── */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .form-control { max-width: 280px; padding: 9px 14px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { padding: 6px 14px; border-radius: var(--radius-full); border: 1.5px solid var(--teal-200); background: var(--white); font-size: .82rem; font-weight: 600; color: var(--text-medium); }
.chip[aria-pressed="true"] { background: var(--teal-600); border-color: var(--teal-600); color: #fff; }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.portal .form-group { margin-bottom: 0; }
.portal textarea.form-control { min-height: 84px; resize: vertical; }
.help { font-size: .78rem; color: var(--text-light); margin-top: 4px; }

/* ── Modal ── */
.modal-back { position: fixed; inset: 0; background: rgba(19,78,74,.55); display: grid; place-items: center; padding: 20px; z-index: 9990; overflow-y: auto; }
.modal { background: var(--white); border-radius: var(--radius-lg); width: 100%; max-width: 640px; padding: 26px 28px; box-shadow: var(--shadow-xl); max-height: 92vh; overflow-y: auto; }
.modal h2 { font-family: var(--font-serif); font-size: 1.4rem; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ── Patient detail / timeline ── */
.profile-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.avatar { width: 64px; height: 64px; border-radius: 50%; background: var(--gradient-primary); color: #fff; display: grid; place-items: center; font-family: var(--font-serif); font-size: 1.6rem; flex: none; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 24px; margin-top: 16px; }
.kv div span { display: block; font-size: .75rem; color: var(--text-light); }
.kv div b { font-weight: 600; word-break: break-word; }
.timeline { position: relative; padding-left: 26px; margin-top: 6px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--teal-200); }
.tl-item { position: relative; padding-bottom: 20px; }
.tl-item::before { content: ''; position: absolute; left: -26px; top: 5px; width: 16px; height: 16px; border-radius: 50%; background: var(--white); border: 3px solid var(--teal-500); }
.tl-item .tl-date { font-size: .78rem; font-weight: 600; color: var(--teal-700); }
.tl-item h3 { font-size: 1rem; margin: 2px 0 4px; }
.tl-item dl { display: grid; grid-template-columns: 110px 1fr; gap: 3px 12px; font-size: .88rem; }
.tl-item dt { color: var(--text-light); }
.tl-item dd { margin: 0; }

/* ── Follow-up list ── */
.fu { display: flex; gap: 14px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--teal-50); flex-wrap: wrap; }
.fu:last-child { border-bottom: 0; }
.fu-date { min-width: 78px; text-align: center; background: var(--teal-50); border-radius: var(--radius-sm); padding: 6px 8px; }
.fu-date b { display: block; font-size: 1.3rem; font-family: var(--font-serif); line-height: 1.1; }
.fu-date span { font-size: .72rem; color: var(--text-light); }
.fu.overdue .fu-date { background: #fee2e2; }
.fu.overdue .fu-date b { color: #b91c1c; }
.fu.soon .fu-date { background: var(--gold-200); }
.fu-body { flex: 1; min-width: 180px; }
.fu-body b { display: block; }
.fu-body span { font-size: .84rem; color: var(--text-light); }

/* ── Banner manager ── */
.banner-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.banner-card { border: 1px solid var(--teal-100); border-radius: var(--radius-md); overflow: hidden; background: var(--white); }
.banner-card img { width: 100%; aspect-ratio: 16 / 7; object-fit: cover; background: var(--teal-100); }
.banner-card .bc-body { padding: 12px 14px; }
.banner-card .bc-body b { display: block; }
.banner-card .bc-body span { font-size: .82rem; color: var(--text-light); }
.banner-card .bc-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.photo-preview { width: 160px; height: 160px; border-radius: 50%; object-fit: cover; border: 4px solid var(--teal-200); background: var(--teal-100); }
.upload-row { display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }

/* ── Patient portal ── */
.pt-top { background: var(--white); border-bottom: 1px solid var(--teal-100); position: sticky; top: 0; z-index: 50; }
.pt-top .inner { max-width: 980px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.pt-top .auth-brand { margin: 0; }
.pt-top .grow { flex: 1; }
.pt-wrap { max-width: 980px; margin: 0 auto; padding: 26px 24px 70px; }
.reminder { display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; border-radius: var(--radius-md); background: var(--gold-200); border: 1px solid var(--gold-300); margin-bottom: 18px; }
.reminder.overdue { background: #fee2e2; border-color: #fecaca; }
.reminder .ico { font-size: 1.5rem; line-height: 1; }
.reminder b { display: block; }
.reminder p { font-size: .88rem; color: var(--text-medium); margin-top: 2px; }
.reminder .btn { margin-top: 10px; }
.status-hero { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.status-hero .badge { font-size: .9rem; padding: 6px 16px; }

/* ── Homepage banner slider (used on index.html) ── */
.hc-banners { background: var(--teal-50); padding: 28px 0 8px; }
.hc-slider { position: relative; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-lg); background: var(--teal-800); }
.hc-slide { display: none; position: relative; }
.hc-slide.active { display: block; }
.hc-slide img { width: 100%; aspect-ratio: 16 / 6; object-fit: cover; }
.hc-slide .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 28px 22px; background: linear-gradient(transparent, rgba(10,45,42,.82)); color: #fff; }
.hc-slide .cap b { display: block; font-family: var(--font-serif); font-size: clamp(1.15rem, 2.6vw, 1.8rem); line-height: 1.25; }
.hc-slide .cap span { font-size: .95rem; opacity: .92; }
.hc-slide .cap .btn { margin-top: 12px; }
.hc-dots { position: absolute; bottom: 12px; right: 18px; display: flex; gap: 7px; z-index: 2; }
.hc-dots button { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.5); padding: 0; }
.hc-dots button[aria-current="true"] { background: #fff; width: 24px; border-radius: 6px; }
.hc-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.85); font-size: 1.1rem; color: var(--teal-800); z-index: 2; }
.hc-nav.prev { left: 12px; } .hc-nav.next { right: 12px; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 14px; }
  .side nav { flex-direction: row; overflow-x: auto; padding-bottom: 6px; }
  .side nav button { white-space: nowrap; }
  .side .side-foot { display: none; }
  .main { padding: 20px 16px 50px; }
  .two-col, .form-grid { grid-template-columns: 1fr; }
  .tl-item dl { grid-template-columns: 1fr; }
  .tl-item dt { margin-top: 4px; }
  .hc-slide img { aspect-ratio: 16 / 9; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print { .side, .page-actions, .toolbar, .chips, .row-actions { display: none !important; } .shell { display: block; } }

/* ── Navbar fit (extra Login button on the public site) ── */
.navbar-links a, .navbar-cta .btn, .logo-name, .logo-tag { white-space: nowrap; }
@media (max-width: 1260px) {
  .navbar-links { gap: 18px; }
  .navbar-cta { gap: 8px; }
  .navbar-cta .btn { padding: 9px 14px !important; }
}
@media (max-width: 1100px) {
  .navbar-links { gap: 14px; }
  .navbar-links a { font-size: .82rem; }
  .logo-tag { display: none; }
}
@media (max-width: 960px) { #nav-whatsapp-btn { display: none; } }
