/* ClarityCBT — Design System
   Fonts: DM Serif Display (headings) + Sora (body)
   Palette: Teal / Ink / Warm White / Amber / Red
*/

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Sora:wght@300;400;500;600&display=swap');

:root {
  --teal:       #2A7B74;
  --teal-light: #3A9D94;
  --teal-pale:  #EAF5F4;
  --ink:        #1A2332;
  --ink-mid:    #3D4F63;
  --ink-light:  #6B7D93;
  --warm:       #F8F5F0;
  --white:      #FFFFFF;
  --amber:      #E8860A;
  --amber-pale: #FDF3E3;
  --red:        #C0392B;
  --red-pale:   #FDECEA;
  --green:      #1E8449;
  --green-pale: #E9F7EF;
  --border:     #DDE3EA;
  --shadow:     0 1px 3px rgba(26,35,50,0.08), 0 2px 8px rgba(26,35,50,0.04);
  --shadow-lg:  0 4px 20px rgba(26,35,50,0.12);
  --radius:     10px;
  --sidebar-w:  240px;
}

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

html { font-size: 15px; }

body {
  font-family: 'Sora', system-ui, sans-serif;
  background: var(--warm);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3 { font-family: 'DM Serif Display', Georgia, serif; font-weight: 400; }

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--ink);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo h1 {
  font-size: 1.3rem;
  color: var(--white);
  letter-spacing: -0.01em;
}

.sidebar-logo span {
  font-family: 'Sora', sans-serif;
  font-size: 0.72rem;
  color: var(--teal-light);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar nav { flex: 1; padding: 12px 0; }

.nav-section {
  padding: 16px 16px 4px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.35);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 400;
  transition: all 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-link:hover { color: var(--white); background: rgba(255,255,255,0.06); }
.nav-link.active { color: var(--white); background: var(--teal); border-radius: 0; }
.nav-link .icon {
  flex: 0 0 22px;
  width: 22px;
  min-width: 22px;
  text-align: center;
  font-size: 1rem;
  line-height: 1;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer button {
  width: 100%;
  padding: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: rgba(255,255,255,0.65);
  font-family: 'Sora', sans-serif;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.sidebar-footer button:hover { background: rgba(255,255,255,0.12); color: var(--white); }

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

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.2rem;
  color: var(--ink);
}

.topbar-actions { display: flex; gap: 10px; align-items: center; }

.page-content {
  padding: 32px;
  flex: 1;
}

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

.card-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.05rem;
  color: var(--ink);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-grid {
  display: grid;
  gap: 20px;
}

.card-grid-2 { grid-template-columns: repeat(2, 1fr); }
.card-grid-3 { grid-template-columns: repeat(3, 1fr); }
.card-grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Stat tiles ─────────────────────────────────────────── */
.stat-tile {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}

.stat-tile .label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-light);
  margin-bottom: 6px;
}

.stat-tile .value {
  font-family: 'DM Serif Display', serif;
  font-size: 2rem;
  color: var(--ink);
  line-height: 1;
}

.stat-tile .sub {
  font-size: 0.8rem;
  color: var(--ink-light);
  margin-top: 4px;
}

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 7px;
  font-family: 'Sora', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--teal); color: var(--white); }
.btn-primary:hover { background: var(--teal-light); }

.btn-secondary {
  background: var(--white);
  color: var(--ink-mid);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--teal); color: var(--teal); }

.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #a93226; }

.btn-amber { background: var(--amber); color: var(--white); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; }

/* ── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-mid);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-family: 'Sora', sans-serif;
  font-size: 0.875rem;
  color: var(--ink);
  background: var(--white);
  transition: border-color 0.15s;
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(42,123,116,0.1); }

.form-textarea { min-height: 100px; resize: vertical; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Traffic lights ─────────────────────────────────────── */
.traffic-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}

.traffic-green { background: var(--green-pale); color: var(--green); }
.traffic-amber { background: var(--amber-pale); color: var(--amber); }
.traffic-red   { background: var(--red-pale);   color: var(--red);   }

.traffic-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-green { background: var(--green); }
.dot-amber { background: var(--amber); }
.dot-red   { background: var(--red);   }

/* ── Alert banners ──────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-amber { background: var(--amber-pale); border: 1px solid #f0c060; color: #7a4500; }
.alert-red   { background: var(--red-pale);   border: 1px solid #e8aaaa; color: #7a1a1a; }
.alert-green { background: var(--green-pale); border: 1px solid #a0d8b0; color: #145a32; }
.alert-info  { background: var(--teal-pale);  border: 1px solid #b0d8d5; color: #1a4a47; }

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: var(--warm);
  padding: 10px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-light);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--ink-mid);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--teal-pale); }

/* ── Search bar ─────────────────────────────────────────── */
.search-bar {
  position: relative;
  max-width: 360px;
}

.search-bar input {
  width: 100%;
  padding: 9px 13px 9px 38px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-family: 'Sora', sans-serif;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
}

.search-bar input:focus { border-color: var(--teal); }
.search-bar::before {
  content: '🔍';
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
}

/* ── Tabs ───────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
}

.tab-btn {
  padding: 10px 20px;
  font-family: 'Sora', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-light);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.tab-btn:hover { color: var(--teal); }
.tab-btn.active { color: var(--teal); border-bottom-color: var(--teal); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Modals ─────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,35,50,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-lg { max-width: 800px; }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 {
  font-size: 1.1rem;
  color: var(--ink);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--ink-light);
  line-height: 1;
  padding: 2px 6px;
}

.modal-close:hover { color: var(--ink); }

.modal-body { padding: 24px; flex: 1; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Client header ──────────────────────────────────────── */
.client-header {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.client-avatar {
  width: 52px; height: 52px;
  background: var(--teal);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'DM Serif Display', serif;
  font-size: 1.3rem;
  color: var(--white);
  flex-shrink: 0;
}

.client-info { flex: 1; min-width: 0; }

.client-name {
  font-family: 'DM Serif Display', serif;
  font-size: 1.4rem;
  color: var(--ink);
}

.client-meta {
  font-size: 0.8rem;
  color: var(--ink-light);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 2px;
}

/* ── Outcome score display ──────────────────────────────── */
.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
}

/* PHQ-9 thresholds */
.phq-minimal { background: var(--green-pale); color: var(--green); }
.phq-mild    { background: #E8F4FD; color: #1a6da0; }
.phq-moderate{ background: var(--amber-pale); color: var(--amber); }
.phq-severe  { background: var(--red-pale);   color: var(--red);   }

/* ── Checklist items ────────────────────────────────────── */
.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.check-item:last-child { border-bottom: none; }

.check-item.outstanding .label { color: var(--amber); font-weight: 500; }
.check-item.urgent .label      { color: var(--red);   font-weight: 600; }

/* ── Empty states ───────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--ink-light);
}

.empty .icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty p { font-size: 0.9rem; }

/* ── Login page ─────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  padding: 20px;
}

.login-card {
  background: var(--white);
  border-radius: 14px;
  padding: 40px 44px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 1.8rem;
  color: var(--teal);
  margin-bottom: 4px;
}

.login-sub {
  font-size: 0.8rem;
  color: var(--ink-light);
  margin-bottom: 32px;
}

.login-error {
  background: var(--red-pale);
  color: var(--red);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: none;
}

/* ── ADHD badge ─────────────────────────────────────────── */
.adhd-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: #EDE9FE;
  color: #5B21B6;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
}

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-light); }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .card-grid-3, .card-grid-4 { grid-template-columns: 1fr 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .sidebar { width: 200px; }
  .main { margin-left: 200px; }
  .page-content { padding: 16px; }
  .card-grid-2, .card-grid-3, .card-grid-4 { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
}

@media (max-width: 480px) {
  .sidebar { position: fixed; transform: translateX(-100%); transition: transform 0.25s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
}
