/* Olive Psychiatry Patient Portal */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w:  220px;
  --olive:      #4a6741;
  --olive-mid:  #5c7a52;
  --olive-light:#eef2ec;
  --blue:       #2563eb;
  --blue-light: #eff6ff;
  --text:       #1a1a2e;
  --muted:      #6b7280;
  --border:     #e5e7eb;
  --bg:         #f3f4f6;
  --white:      #ffffff;
  --radius:     12px;
  --radius-sm:  8px;
  --paid:       #166534;
  --paid-bg:    #dcfce7;
  --partial:    #92400e;
  --partial-bg: #fef3c7;
  --unpaid:     #9a3412;
  --unpaid-bg:  #fff7ed;
  --shadow:     0 1px 4px rgba(0,0,0,.07);
  --shadow-md:  0 4px 16px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand img { height: 32px; display: block; }

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.sidebar-nav a:hover {
  color: var(--olive);
  background: var(--olive-light);
  border-left-color: var(--olive-light);
}
.sidebar-nav a.active {
  color: var(--olive);
  background: var(--olive-light);
  border-left-color: var(--olive);
}
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-nav .nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 20px;
}

.sidebar-bottom {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

/* ── Main content ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 36px 40px;
  max-width: calc(1100px + var(--sidebar-w));
}

.page-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 24px;
}

/* ── Cards ── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.card-count {
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}
.card-body { padding: 0; }

/* ── Dashboard grid ── */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  margin-bottom: 20px;
}

.dash-full { grid-column: 1 / -1; }

/* ── Medication list ── */
.med-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.med-item:last-child { border-bottom: none; }

.med-icon {
  width: 36px; height: 36px;
  background: var(--olive-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.med-icon svg { width: 16px; height: 16px; color: var(--olive); }

.med-info { flex: 1; min-width: 0; }
.med-name { font-size: 14px; font-weight: 600; color: var(--text); }
.med-sub  { font-size: 12px; color: var(--muted); margin-top: 2px; }

.med-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--unpaid-bg);
  color: var(--unpaid);
  white-space: nowrap;
}
.med-badge.controlled {
  background: #fef3c7;
  color: #92400e;
}

/* ── Next appointment card ── */
.appt-card-body { padding: 20px; }
.appt-date {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 4px;
}
.appt-time {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.appt-time svg { width: 14px; height: 14px; }
.appt-empty {
  padding: 20px;
  color: var(--muted);
  font-size: 14px;
}

/* ── Balance banner ── */
.balance-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--unpaid-bg);
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.balance-banner-label { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.balance-banner-amount { font-size: 20px; font-weight: 700; color: var(--unpaid); }
.balance-banner.clear {
  background: var(--paid-bg);
  border-color: #a5d6a7;
}
.balance-banner.clear .balance-banner-amount { color: var(--paid); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: var(--olive);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover { background: #3a5432; }
.btn-outline {
  background: var(--white);
  color: var(--olive);
  border: 1px solid var(--olive);
}
.btn-outline:hover { background: var(--olive-light); }
.btn-blue { background: var(--blue); }
.btn-blue:hover { background: #1d4ed8; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-link {
  background: none;
  color: var(--blue);
  border: none;
  padding: 0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.btn-link:hover { text-decoration: underline; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  font-size: 14px;
}
th {
  background: var(--olive-light);
  color: var(--olive);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 16px;
  text-align: left;
}
th.num { text-align: right; }
td { padding: 13px 16px; border-top: 1px solid var(--border); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.bal-owed { color: var(--unpaid); font-weight: 600; }
tr:hover td { background: #fafafa; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
}
.badge.paid    { background: var(--paid-bg);    color: var(--paid); }
.badge.partial { background: var(--partial-bg); color: var(--partial); }
.badge.unpaid  { background: var(--unpaid-bg);  color: var(--unpaid); }

.btn-small {
  font-size: 12px;
  padding: 4px 10px;
  background: var(--olive);
  color: var(--white);
  border-radius: var(--radius-sm);
  text-decoration: none;
  white-space: nowrap;
}
.btn-small:hover { background: #3a5432; }
.btn-small-outline {
  background: var(--white);
  color: var(--olive);
  border: 1px solid var(--olive);
}
.btn-small-outline:hover { background: var(--olive-light); }

/* ── Appointments page ── */
.appt-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.appt {
  padding: 14px 18px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: var(--shadow);
}
.appt.upcoming { border-left: 3px solid var(--olive); }
.appt.past { color: var(--muted); }

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 28px 0 12px;
}
.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.section-count { font-size: 12px; color: var(--muted); }

.empty { color: var(--muted); font-size: 14px; padding: 12px 0; }

/* ── Booking page ── */
.book-options { display: flex; gap: 16px; margin-top: 8px; }
.book-card {
  flex: 1;
  padding: 28px 22px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  box-shadow: var(--shadow);
}
.book-card:hover { border-color: var(--olive); box-shadow: var(--shadow-md); }
.book-duration { font-size: 40px; font-weight: 700; color: var(--olive); }
.book-label { font-size: 15px; margin: 6px 0 18px; color: var(--muted); }
.book-action { font-size: 13px; color: var(--olive); font-weight: 600; }

/* ── Login page ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.login-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}
.login-logo { height: 36px; margin-bottom: 28px; display: block; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: 14px; margin-bottom: 28px; }

label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; margin-top: 16px; color: var(--text); }
input[type="email"] {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px; outline: none;
  transition: border-color .15s;
}
input[type="email"]:focus { border-color: var(--olive); }
button[type="submit"] {
  display: inline-flex; align-items: center;
  margin-top: 20px; padding: 11px 22px;
  background: var(--olive); color: var(--white);
  border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 500; cursor: pointer;
}
button[type="submit"]:hover { background: #3a5432; }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 14px; }
.alert.success { background: var(--paid-bg); color: var(--paid); }
.alert.error   { background: var(--unpaid-bg); color: var(--unpaid); }

/* ── Spinner / loading ── */
.loading {
  display: flex; align-items: center; gap: 10px;
  padding: 20px; color: var(--muted); font-size: 14px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--olive);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Admin pages ── */
.admin-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:1.5rem; }
.badge-day10 { background:#e8f4fd; color:#1a73e8; padding:3px 8px; border-radius:12px; font-size:12px; font-weight:600; }
.badge-day30 { background:#fef3e2; color:#e37400; padding:3px 8px; border-radius:12px; font-size:12px; font-weight:600; }
.fee-note { color:#b00020; font-size:12px; margin-top:3px; }
.preview-box { background:#f9fbf9; border:1px solid #d8e8d8; border-radius:8px; padding:14px 16px; font-size:13px; line-height:1.6; color:#333; max-width:560px; white-space:pre-wrap; }
.send-bar { display:flex; gap:12px; align-items:center; margin-top:2rem; padding-top:1.5rem; border-top:2px solid var(--border); }
.btn-send { background:#2e7d32; color:#fff; border:none; padding:12px 28px; border-radius:6px; font-size:15px; font-weight:600; cursor:pointer; }
.btn-send:hover { background:#1b5e20; }
.btn-skip { background:#f4f6f4; color:#555; border:1px solid #d0d8d0; padding:12px 20px; border-radius:6px; font-size:15px; cursor:pointer; text-decoration:none; }
.btn-skip:hover { background:#e8ede8; }
.sent-banner { background:#e8f5e9; border:1px solid #a5d6a7; border-radius:8px; padding:14px 18px; color:#2e7d32; font-weight:600; margin-bottom:1.5rem; }
.reminder-table { width:100%; border-collapse:collapse; font-size:14px; }
.reminder-table th { text-align:left; padding:10px 12px; background:#f4f6f4; border-bottom:2px solid #d0d8d0; color:#555; font-weight:600; }
.reminder-table td { padding:10px 12px; border-bottom:1px solid #e8ede8; vertical-align:top; }
.reminder-table tr:last-child td { border-bottom:none; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 20px 16px; }
  .dash-grid { grid-template-columns: 1fr; }
  .book-options { flex-direction: column; }
}
