/* ═══════════════════════════════════════════════════════════════════
   Wajir Rehabilitation Centre: Shared Portal Stylesheet
   Used by: dashboard.html, referral.html
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Variables ──────────────────────────────────────────────────── */
:root {
  --brand:          #00a5e3;
  --brand-dark:     #0082b5;
  --brand-light:    #e8f7fd;
  --sidebar-bg:     #111827;
  --sidebar-border: rgba(255,255,255,0.07);
  --sidebar-text:   #9ca3af;
  --sidebar-active: rgba(0,165,227,0.15);
  --sidebar-hover:  rgba(255,255,255,0.06);
  --sidebar-width:  260px;
  --main-bg:        #f0f4f8;
  --card-bg:        #ffffff;
  --card-shadow:    0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.06);
  --border:         #e5e7eb;
  --text-primary:   #111827;
  --text-secondary: #6b7280;
  --text-muted:     #9ca3af;
  --success:        #059669;
  --success-bg:     #ecfdf5;
  --warning:        #d97706;
  --warning-bg:     #fffbeb;
  --danger:         #dc2626;
  --danger-bg:      #fef2f2;
  --info:           #2563eb;
  --info-bg:        #eff6ff;
  --radius:         10px;
  --radius-sm:      6px;
  --tr:             0.18s ease;
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  width: 100%; margin: 0; padding: 0; overflow-x: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--main-bg); color: var(--text-primary);
  font-size: 15px; line-height: 1.5;
}

/* ── Auth Overlay ───────────────────────────────────────────────── */
#auth-overlay {
  position: fixed; inset: 0; background: #fff; z-index: 9999;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
}
#auth-overlay p { color: var(--text-secondary); font-size: 15px; margin: 0; }
.auth-spinner {
  width: 50px; height: 50px;
  border: 4px solid #e5e7eb;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: wrc-spin 0.75s linear infinite;
}
@keyframes wrc-spin { to { transform: rotate(360deg); } }

/* ── Branded loader (logo + spinning ring), used on initial app load ─────── */
.brand-loader { position: relative; width: 68px; height: 68px; }
.brand-loader img {
  position: relative; z-index: 1;
  width: 100%; height: 100%;
  border-radius: 50%;
  display: block;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
}
.brand-loader::before {
  content: ""; position: absolute; z-index: 0; inset: -7px;
  border: 4px solid #e5e7eb;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: wrc-spin 0.85s linear infinite;
}

/* ── Portal Layout ──────────────────────────────────────────────── */
#portal-content { display: flex; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────────────── */
.portal-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 1000;
  display: flex; flex-direction: column;
  transition: transform var(--tr);
  overflow-y: auto; overflow-x: hidden;
  border-right: 1px solid var(--sidebar-border);
}
.portal-sidebar::-webkit-scrollbar { width: 4px; }
.portal-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

.sidebar-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.sidebar-brand {
  color: #fff; font-size: 14px; font-weight: 700;
  text-decoration: none; letter-spacing: 0.2px; line-height: 1.45;
}
.sidebar-brand .brand-accent { color: var(--brand); }
.sidebar-close {
  display: none; background: none; border: none;
  color: var(--sidebar-text); font-size: 22px; cursor: pointer;
  padding: 2px; line-height: 1; flex-shrink: 0;
}

.sidebar-user {
  padding: 16px 18px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: 11px; flex-shrink: 0;
}
.user-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px; font-weight: 700; flex-shrink: 0;
  letter-spacing: -0.5px;
}
.user-info { min-width: 0; }
.user-info .user-name {
  color: #fff; font-size: 13.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block; margin-bottom: 3px;
}
.role-pill {
  display: inline-block;
  background: rgba(0,165,227,0.2); color: #60c5f1;
  font-size: 10px; font-weight: 700; letter-spacing: 0.8px;
  padding: 2px 8px; border-radius: 20px; text-transform: uppercase;
}

.sidebar-nav { flex: 1; padding: 10px 0; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 18px;
  color: var(--sidebar-text); font-size: 13.5px; font-weight: 500;
  text-decoration: none; cursor: pointer; user-select: none;
  border-left: 3px solid transparent;
  transition: all var(--tr); position: relative;
  border-radius: 0;
}
.nav-item:hover { background: var(--sidebar-hover); color: #e5e7eb; text-decoration: none; }
.nav-item.active {
  background: var(--sidebar-active); color: #fff;
  border-left-color: var(--brand);
}
.nav-item .nav-icon { font-size: 15px; flex-shrink: 0; width: 20px; text-align: center; }
.nav-label { flex: 1; }

.unread-dot {
  display: none; position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; min-width: 18px; height: 18px;
  border-radius: 9px; padding: 0 5px;
  align-items: center; justify-content: center;
}
.unread-dot.visible { display: flex; }

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

.sidebar-footer {
  padding: 14px 18px; border-top: 1px solid var(--sidebar-border); flex-shrink: 0;
}
.btn-signout {
  width: 100%; padding: 9px 16px;
  background: rgba(255,255,255,0.06); color: var(--sidebar-text);
  border: 1px solid rgba(255,255,255,0.1); border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: all var(--tr); text-align: center;
}
.btn-signout:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* ── Sidebar Overlay (mobile) ───────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.55); z-index: 999;
  animation: fadeIn 0.2s ease;
}
.sidebar-overlay.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Main Content ───────────────────────────────────────────────── */
.portal-main {
  flex: 1; margin-left: var(--sidebar-width);
  display: flex; flex-direction: column; min-height: 100vh;
}

/* ── Top Bar (mobile only) ──────────────────────────────────────── */
.portal-topbar {
  display: none;
  background: var(--sidebar-bg);
  padding: 13px 16px;
  align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid var(--sidebar-border);
}
.hamburger {
  background: none; border: none; color: #e5e7eb;
  font-size: 20px; cursor: pointer; padding: 4px; line-height: 1;
}
.topbar-title { color: #fff; font-size: 15px; font-weight: 600; }
.topbar-signout {
  background: rgba(255,255,255,0.1); color: #e5e7eb;
  border: none; padding: 6px 12px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit;
}

/* ── Page Header ────────────────────────────────────────────────── */
.page-header {
  background: var(--card-bg); padding: 22px 28px 18px;
  border-bottom: 1px solid var(--border);
}
.page-header h2 {
  margin: 0 0 4px; font-size: 21px; font-weight: 700; color: var(--text-primary);
}
.page-header p { margin: 0; color: var(--text-secondary); font-size: 13.5px; }

/* ── Page Body ──────────────────────────────────────────────────── */
.page-body { padding: 24px 28px; flex: 1; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--card-shadow); padding: 20px 22px; margin-bottom: 18px;
}
.card-title {
  font-size: 11.5px; font-weight: 700;
  color: var(--brand); text-transform: uppercase; letter-spacing: 0.8px;
  margin: 0 0 16px; padding-bottom: 12px;
  border-bottom: 2px solid var(--brand-light);
  display: flex; align-items: center; gap: 8px;
}
.card-title-actions { margin-left: auto; display: flex; gap: 8px; }

/* ── Stats Row ──────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.stat-card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--card-shadow); padding: 16px 18px;
  border-top: 3px solid var(--brand); transition: transform var(--tr);
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card.green  { border-color: var(--success); }
.stat-card.orange { border-color: var(--warning); }
.stat-card.red    { border-color: var(--danger); }
.stat-label {
  font-size: 11px; color: var(--text-secondary);
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
  margin: 0 0 8px;
}
.stat-value { font-size: 30px; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
}
.badge-confirmed  { background: #dbeafe; color: #1d4ed8; }
.badge-completed  { background: var(--success-bg); color: var(--success); }
.badge-cancelled  { background: var(--danger-bg); color: var(--danger); }
.badge-pending    { background: var(--warning-bg); color: var(--warning); }
.badge-reviewed   { background: var(--info-bg); color: var(--info); }
.badge-accepted   { background: var(--success-bg); color: var(--success); }
.badge-declined   { background: var(--danger-bg); color: var(--danger); }
.badge-routine    { background: var(--success-bg); color: var(--success); }
.badge-urgent     { background: var(--warning-bg); color: var(--warning); }
.badge-critical   { background: var(--danger-bg); color: var(--danger); }

/* ── Tables ─────────────────────────────────────────────────────── */
.portal-table { width: 100%; border-collapse: collapse; }
.portal-table th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; font-weight: 700; color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.5px;
  background: #f9fafb; border-bottom: 2px solid var(--border);
}
.portal-table td {
  padding: 12px 14px; font-size: 14px;
  color: var(--text-primary); border-bottom: 1px solid var(--border);
}
.portal-table tr:last-child td { border-bottom: none; }
.portal-table tbody tr:hover td { background: #f9fafb; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; font-family: inherit;
  border: none; cursor: pointer; transition: all var(--tr);
  text-decoration: none; line-height: 1.4; white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-ghost   { background: transparent; color: var(--text-secondary); border: 1.5px solid var(--border); }
.btn-ghost:hover   { border-color: var(--brand); color: var(--brand); }
.btn-sm { padding: 6px 13px; font-size: 12px; }
.btn-xs { padding: 4px 10px; font-size: 11px; }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
  border-radius: 50%; animation: wrc-spin 0.6s linear infinite;
  flex-shrink: 0;
}

/* ── Alerts ─────────────────────────────────────────────────────── */
.alert {
  padding: 11px 15px; border-radius: var(--radius-sm);
  font-size: 13.5px; margin: 10px 0; display: none;
}
.alert.show { display: block; }
.alert-error   { background: var(--danger-bg);  color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: var(--success-bg); color: #065f46; border: 1px solid #6ee7b7; }
.alert-info    { background: var(--info-bg);    color: #1e40af; border: 1px solid #93c5fd; }
.alert-warning { background: var(--warning-bg); color: #92400e; border: 1px solid #fcd34d; }

/* ── Toast Notifications ────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 9998; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: #1f2937; color: #f9fafb;
  padding: 12px 18px; border-radius: 8px;
  font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  display: flex; align-items: center; gap: 10px;
  animation: slideUp 0.3s ease; max-width: 340px;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.info    { border-left: 4px solid var(--brand); }
.toast.warning { border-left: 4px solid var(--warning); }
@keyframes slideUp { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }

/* ── Available Slots ────────────────────────────────────────────── */
.slots-filter {
  display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap;
}
.slot-filter-btn {
  padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--border); background: #fff; color: var(--text-secondary);
  cursor: pointer; font-family: inherit; transition: all var(--tr);
}
.slot-filter-btn.active { border-color: var(--brand); background: var(--brand); color: #fff; }
.slot-filter-btn:hover:not(.active) { border-color: var(--brand); color: var(--brand); }

/* ── Date Strip (Book a Slot date picker) ───────────────────────── */
.date-strip {
  display: flex; gap: 8px; overflow-x: auto;
  padding-bottom: 8px; margin-bottom: 18px;
}
.date-strip::-webkit-scrollbar { height: 5px; }
.date-strip::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
.date-pill {
  flex-shrink: 0; min-width: 64px; padding: 10px 6px;
  border: 2px solid var(--border); border-radius: var(--radius);
  background: var(--card-bg); text-align: center; cursor: pointer;
  transition: all var(--tr);
}
.date-pill:hover { border-color: var(--brand); }
.date-pill.active { border-color: var(--brand); background: var(--brand); }
.date-pill.active .dp-weekday,
.date-pill.active .dp-month { color: rgba(255,255,255,0.85); }
.date-pill.active .dp-day { color: #fff; }
.dp-weekday { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-secondary); }
.dp-day { font-size: 19px; font-weight: 700; color: var(--text-primary); margin: 2px 0; line-height: 1; }
.dp-month { font-size: 10.5px; color: var(--text-muted); }

/* ── Time Chips (times for the selected date) ───────────────────── */
.time-chips-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
}
.time-chip {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 8px; background: var(--card-bg); cursor: pointer;
  transition: all var(--tr); min-height: 52px;
}
.time-chip:hover { border-color: var(--brand); background: var(--brand-light); transform: translateY(-1px); }
.time-chip.full { opacity: 0.45; cursor: not-allowed; }
.time-chip.full:hover { transform: none; background: var(--card-bg); border-color: var(--border); }
.tc-time { font-size: 13.5px; font-weight: 700; color: var(--text-primary); }
.time-chip.full .tc-time { text-decoration: line-through; }
.tc-tag {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
  color: var(--brand);
}
.tc-tag.tc-full { color: var(--danger); }

/* ── Appointment Items ──────────────────────────────────────────── */
.appt-list { display: flex; flex-direction: column; gap: 0; }
.appt-item {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 0; border-bottom: 1px solid var(--border);
}
.appt-item:last-child { border-bottom: none; }
.appt-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--brand-light); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.appt-info { flex: 1; min-width: 0; }
.appt-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin: 0 0 3px; }
.appt-meta { font-size: 12px; color: var(--text-secondary); margin: 0; }
.appt-actions { display: flex; gap: 7px; align-items: center; }

/* ── Booking Confirm Modal ──────────────────────────────────────── */
#book-modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(3px);
  z-index: 8000; align-items: center; justify-content: center;
}
#book-modal-overlay.active { display: flex; }
#book-modal {
  background: var(--card-bg); border-radius: 14px;
  width: 90%; max-width: 440px; padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: modalIn 0.25s ease;
}
@keyframes modalIn { from { opacity:0; transform:scale(0.94); } to { opacity:1; transform:scale(1); } }
#book-modal h3 { margin: 0 0 8px; font-size: 18px; font-weight: 700; }
#book-modal p  { color: var(--text-secondary); font-size: 14px; margin: 0 0 18px; }
.book-slot-detail {
  background: var(--brand-light); border-radius: 8px;
  padding: 14px 16px; margin-bottom: 20px;
}
.book-slot-detail .detail-row {
  display: flex; gap: 8px; align-items: baseline; margin-bottom: 6px;
}
.book-slot-detail .detail-row:last-child { margin-bottom: 0; }
.book-slot-detail .detail-label { font-size: 11px; font-weight: 700; color: var(--brand); text-transform: uppercase; width: 70px; flex-shrink: 0; }
.book-slot-detail .detail-val { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.book-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Messages ───────────────────────────────────────────────────── */
.messages-wrap {
  display: flex; flex-direction: column;
  height: 500px; border: 1.5px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  background: var(--card-bg);
}
.messages-header {
  padding: 12px 16px; background: #f9fafb;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.messages-header .care-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, #00a5e3, #0082b5);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.messages-header .care-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.messages-header .care-status { font-size: 12px; color: var(--success); }
.messages-body {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  background: #f9fafb;
}
.messages-body::-webkit-scrollbar { width: 4px; }
.messages-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }
.msg-row { display: flex; flex-direction: column; }
.msg-row.mine { align-items: flex-end; }
.msg-row.theirs { align-items: flex-start; }
.msg-sender { font-size: 11px; color: var(--text-muted); margin-bottom: 3px; font-weight: 600; }
.msg-bubble {
  max-width: 72%; padding: 10px 14px;
  border-radius: 14px; font-size: 14px; line-height: 1.5;
}
.msg-bubble.mine {
  background: var(--brand); color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-bubble.theirs {
  background: var(--card-bg); color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg-time {
  font-size: 10.5px; color: var(--text-muted);
  margin-top: 4px; padding: 0 4px;
}
.messages-footer {
  padding: 12px 14px; background: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; align-items: flex-end;
}
.msg-input {
  flex: 1; border: 1.5px solid var(--border); border-radius: 8px;
  padding: 9px 13px; font-size: 14px; font-family: inherit;
  resize: none; max-height: 120px; min-height: 41px; line-height: 1.4;
  transition: border-color var(--tr);
}
.msg-input:focus { outline: none; border-color: var(--brand); }
.msg-send-btn {
  width: 41px; height: 41px; border-radius: 8px;
  background: var(--brand); color: #fff; border: none;
  cursor: pointer; font-size: 17px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--tr);
}
.msg-send-btn:hover { background: var(--brand-dark); }

/* ── Message actions (edit / delete) ─────────────────────────────── */
.msg-bubble-wrap { display: flex; align-items: flex-end; gap: 6px; max-width: 100%; }
.msg-row.mine .msg-bubble-wrap { flex-direction: row-reverse; }
.msg-actions {
  display: flex; gap: 2px; flex-shrink: 0; padding-bottom: 6px;
  opacity: 0; transition: opacity var(--tr);
}
.msg-row:hover .msg-actions { opacity: 1; }
.msg-action-btn {
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--text-muted); padding: 4px 6px; border-radius: 5px;
  line-height: 1;
}
.msg-action-btn:hover { background: var(--brand-light); color: var(--brand); }
.msg-action-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.msg-edited-tag { font-size: 10.5px; opacity: 0.75; font-style: italic; margin-left: 6px; }
.msg-deleted { font-style: italic; opacity: 0.7; }
.msg-edit-area { display: flex; flex-direction: column; gap: 6px; width: 260px; max-width: 100%; }
.msg-edit-area textarea {
  width: 100%; border: 1.5px solid var(--brand); border-radius: 10px;
  padding: 8px 12px; font-size: 14px; font-family: inherit; resize: vertical; min-height: 44px;
  box-sizing: border-box;
}
.msg-edit-actions { display: flex; gap: 8px; justify-content: flex-end; }
.msg-edit-actions button {
  font-size: 12px; padding: 5px 12px; border-radius: 6px; cursor: pointer; border: none; font-weight: 600;
}
.msg-edit-save { background: var(--brand); color: #fff; }
.msg-edit-save:hover { background: var(--brand-dark); }
.msg-edit-cancel { background: #f3f4f6; color: var(--text-secondary); }
.msg-edit-cancel:hover { background: #e5e7eb; }

/* ── Conversation list rows (assigned / inbox views) ─────────────── */
.conv-list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background var(--tr);
  border: 1px solid transparent;
}
.conv-list-row:hover { background: #f9fafb; }
.conv-list-row.active { background: var(--brand-light); border-color: var(--brand); }
.conv-list-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
.conv-list-info { flex: 1; min-width: 0; }
.conv-list-name { font-size: 13.5px; font-weight: 700; color: var(--text-primary); margin: 0 0 2px; }
.conv-list-preview {
  font-size: 12px; color: var(--text-secondary); margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-list-time { font-size: 10.5px; color: var(--text-muted); flex-shrink: 0; white-space: nowrap; }

/* ── Treatment Plan ─────────────────────────────────────────────── */
.tp-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.tp-meta { font-size: 12px; color: var(--text-muted); }
.tp-section { margin-bottom: 22px; }
.tp-section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-secondary);
  margin: 0 0 10px;
}
.tp-diagnosis-box {
  background: var(--brand-light); border-radius: 8px;
  padding: 14px 16px; border-left: 4px solid var(--brand);
  font-size: 14px; color: var(--text-primary); line-height: 1.6;
}
.tp-goal-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.tp-goal-item:last-child { border-bottom: none; }
.tp-goal-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand); margin-top: 6px; flex-shrink: 0;
}
.tp-goal-text { font-size: 14px; color: var(--text-primary); line-height: 1.5; }
.tp-med-item {
  display: flex; align-items: center; gap: 12px;
  background: #f9fafb; border-radius: 8px;
  padding: 10px 14px; margin-bottom: 8px;
  border: 1px solid var(--border);
}
.tp-med-icon { font-size: 20px; flex-shrink: 0; }
.tp-med-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.tp-med-note { font-size: 12px; color: var(--text-secondary); }
.tp-review-box {
  display: flex; align-items: center; gap: 14px;
  background: var(--warning-bg); border-radius: 8px;
  padding: 12px 16px; border: 1px solid #fcd34d;
}
.tp-review-icon { font-size: 22px; flex-shrink: 0; }
.tp-review-date { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.tp-review-label { font-size: 12px; color: var(--text-secondary); }

/* ── Profile ────────────────────────────────────────────────────── */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.profile-field { }
.profile-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-secondary); margin: 0 0 4px;
}
.profile-value {
  font-size: 14px; color: var(--text-primary);
  padding: 9px 12px; background: #f9fafb;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  min-height: 38px; word-break: break-word;
}

/* ── Referral Items ─────────────────────────────────────────────── */
.referral-item {
  border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px; background: var(--card-bg);
  cursor: pointer; transition: all var(--tr);
}
.referral-item:hover { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,165,227,0.08); }
.referral-item.selected { border-color: var(--brand); background: var(--brand-light); }
.referral-patient { font-size: 15px; font-weight: 700; color: var(--text-primary); margin: 0 0 5px; }
.referral-meta { font-size: 12px; color: var(--text-secondary); margin: 0 0 8px; }
.referral-badges { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Referral Detail Panel ──────────────────────────────────────── */
.rdp { border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.rdp-header {
  background: var(--brand); color: #fff; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
}
.rdp-header h4 { margin: 0; font-size: 15px; font-weight: 700; }
.rdp-close {
  background: rgba(255,255,255,0.2); border: none; color: #fff;
  width: 28px; height: 28px; border-radius: 6px;
  cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.rdp-body { padding: 18px; }
.rdp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.rdp-field label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); display: block; margin-bottom: 3px; }
.rdp-field p { font-size: 14px; color: var(--text-primary); margin: 0; }
.rdp-notes { background: #f9fafb; border-radius: 6px; padding: 10px 12px; font-size: 14px; color: var(--text-primary); line-height: 1.6; border: 1px solid var(--border); }

/* Status timeline */
.status-timeline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.st-step { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-muted); }
.st-step.done { color: var(--success); }
.st-step.current { color: var(--brand); font-weight: 700; }
.st-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.st-step.done .st-dot { background: var(--success); }
.st-step.current .st-dot { background: var(--brand); }
.st-line { width: 24px; height: 2px; background: var(--border); }
.st-line.done { background: var(--success); }

/* ── Document Items ─────────────────────────────────────────────── */
.doc-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.doc-item:last-child { border-bottom: none; }
.doc-type-icon { font-size: 28px; flex-shrink: 0; line-height: 1; }
.doc-info { flex: 1; min-width: 0; }
.doc-name {
  font-size: 14px; font-weight: 600; color: var(--text-primary);
  margin: 0 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.doc-meta { font-size: 12px; color: var(--text-secondary); margin: 0; }
.doc-actions { display: flex; gap: 7px; }

/* ── Upload Area ────────────────────────────────────────────────── */
.upload-area {
  border: 2px dashed #d1d5db; border-radius: var(--radius);
  padding: 28px 20px; text-align: center; cursor: pointer;
  background: #f9fafb; transition: all var(--tr);
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--brand); background: var(--brand-light);
}
.upload-icon { font-size: 36px; margin-bottom: 10px; }
.upload-area p { margin: 0 0 4px; font-size: 14px; color: var(--text-secondary); }
.upload-area strong { color: var(--brand); }
.upload-area small { font-size: 12px; color: var(--text-muted); }
#file-input { display: none; }
.upload-progress { margin-top: 14px; display: none; }
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-fill {
  height: 100%; background: var(--brand); border-radius: 3px;
  width: 0; transition: width 0.25s ease;
}
.progress-label { font-size: 12px; color: var(--text-secondary); margin-top: 5px; }

/* ── Document Viewer Modal ──────────────────────────────────────── */
#doc-modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.82); backdrop-filter: blur(5px);
  z-index: 9500; align-items: center; justify-content: center;
}
#doc-modal-overlay.active { display: flex; }
#doc-modal {
  background: #1f2937; border-radius: 14px;
  width: 92vw; max-width: 940px; height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden; animation: modalIn 0.25s ease;
}
#doc-modal-header {
  padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
#doc-modal-filename { color: #f9fafb; font-size: 14px; font-weight: 600; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#doc-modal-close {
  background: rgba(255,255,255,0.1); color: #f9fafb; border: none;
  border-radius: 6px; width: 32px; height: 32px; cursor: pointer;
  font-size: 18px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-left: 12px; transition: background var(--tr);
}
#doc-modal-close:hover { background: rgba(255,255,255,0.2); }
#doc-modal-body { flex: 1; overflow: hidden; position: relative; display: flex; align-items: center; justify-content: center; }
#doc-image-viewer { max-width: 100%; max-height: 100%; object-fit: contain; padding: 16px; }
#pdf-container { width: 100%; height: 100%; overflow-y: auto; padding: 16px; background: #525659; text-align: center; }
#pdf-container::-webkit-scrollbar { width: 6px; }
#pdf-container::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }
#pdf-canvas { max-width: 100%; box-shadow: 0 4px 24px rgba(0,0,0,0.5); }
#doc-modal-toolbar {
  padding: 10px 18px; border-top: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.pdf-btn {
  background: rgba(255,255,255,0.1); color: #f9fafb; border: none;
  border-radius: 6px; padding: 6px 14px; cursor: pointer;
  font-size: 13px; font-family: inherit; transition: background var(--tr);
}
.pdf-btn:hover { background: rgba(255,255,255,0.18); }
.pdf-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#pdf-page-info { color: #9ca3af; font-size: 13px; flex: 1; }

/* ── Mood Check-in ──────────────────────────────────────────────── */
.mood-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.mood-btn {
  flex: 1; min-width: 70px; padding: 12px 8px;
  border: 2px solid var(--border); border-radius: var(--radius);
  background: var(--card-bg); text-align: center; cursor: pointer;
  transition: all var(--tr); font-family: inherit; font-size: 13px; color: var(--text-primary);
}
.mood-btn:hover  { border-color: var(--brand); background: var(--brand-light); }
.mood-btn.selected { border-color: var(--brand); background: var(--brand); color: #fff; }
.mood-emoji { font-size: 26px; display: block; margin-bottom: 4px; }

.checkin-done {
  background: var(--success-bg); color: #065f46;
  border: 1px solid #6ee7b7; border-radius: 8px;
  padding: 14px; text-align: center; font-size: 15px; font-weight: 600;
}

/* History items */
.history-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-emoji { font-size: 22px; flex-shrink: 0; }
.history-detail { flex: 1; }
.history-date { font-size: 12px; color: var(--text-muted); }
.history-note { font-size: 13px; color: var(--text-secondary); margin: 2px 0 0; }
.history-mood { font-size: 13px; font-weight: 600; color: var(--text-primary); }

/* ── Empty States ───────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-state .empty-icon { font-size: 52px; margin-bottom: 12px; line-height: 1; }
.empty-state h4 { font-size: 16px; font-weight: 600; color: var(--text-primary); margin: 0 0 6px; }
.empty-state p { color: var(--text-secondary); font-size: 14px; margin: 0; }

/* ── Loading Skeleton ───────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 4px;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .portal-sidebar { transform: translateX(-100%); }
  .portal-sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.25); }
  .sidebar-close { display: flex; }
  .portal-main { margin-left: 0; }
  .portal-topbar { display: flex; }
  .page-body { padding: 16px; }
  .page-header { padding: 16px; }
  .page-header h2 { font-size: 18px; }
  .profile-grid { grid-template-columns: 1fr; }
  .rdp-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 540px) {
  .slots-grid { grid-template-columns: 1fr 1fr; }
  .stats-row { grid-template-columns: 1fr; }
  #doc-modal { width: 98vw; height: 94vh; }
}
@media (max-width: 380px) {
  .slots-grid { grid-template-columns: 1fr; }
}
