/* ─────────────────────────────────────────────────────────────────────────────
 * tc-shell.css — canonical TherapyConnect v2 design system.
 *
 * Reference page: contacts.html (the "good" example). Every v2 page should
 * either link this file or paste the same CSS-variable definitions into its
 * own <style> block.
 *
 * Loaded by:  <link rel="stylesheet" href="/php_api_v2/web/tc-shell.css">
 * ────────────────────────────────────────────────────────────────────────── */

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

:root {
  /* ── Brand (v1 TC-blue palette — canonical for all v2 pages) ── */
  --teal:        #0061d4;   /* primary accent (v1 TC blue) */
  --teal2:       #0052B0;   /* darker — gradient stop, hover */
  --teal-soft:   #7BB6F2;   /* on-navy accent (sidebar active text) */
  --navy:        #0b3f82;   /* sidebar bg */

  /* ── Surfaces ── */
  --bg:          #f7fbff;   /* page bg */
  --surface:     #FFFFFF;   /* card bg / topbar bg */
  --border:      #d7e5f8;
  --border-soft: #eef5ff;

  /* ── Text ── */
  --text:        #243447;
  --subtext:     #6B7A8D;
  --muted:       #8B92A5;

  /* ── Status ── */
  --success: #10B981;
  --warning: #F59E0B;
  --danger:  #DC2626;
  --info:    #2563EB;
  --purple:  #7C3AED;

  /* ── Radii / spacing ── */
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-pill: 50px;

  /* ── Layout ── */
  --sidebar-w: 240px;
  --topbar-h:  64px;

  /* ── Type ── */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', Menlo, Consolas, monospace;
}

html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  display: flex;
}

/* ── SIDEBAR ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); min-height: 100vh;
  background: var(--navy);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0;
  z-index: 50;
  transition: transform .25s;
}
.sidebar-logo {
  padding: 22px 24px 20px;
  font-size: 1.1rem; font-weight: 800;
  color: #fff; letter-spacing: -.3px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  text-decoration: none; display: block;
}
.sidebar-logo span { color: var(--teal-soft); }
/* Third logo segment injected by tc-brand.js — TherapyConnectData / TherapyConnectCE.
   Inherits color so it matches "Therapy" in any context (white sidebar, light header). */
.tc-brand-suffix { color: inherit; font-weight: inherit; }
.sidebar-logo .tc-brand-suffix { color: #fff; }

/* Canonical 5-pill language toggle — used in topbars across the platform.
   Pages that defined their own .lang-toggle / .lang-btn styles will be
   overridden by these rules; the dashboard look is the source of truth. */
.lang-toggle { display: inline-flex; align-items: center; background: #f7fbff; border: 1.5px solid var(--border); border-radius: 50px; padding: 3px; gap: 2px; }
.lang-toggle .lang-btn { padding: 5px 12px; border-radius: 50px; border: none; background: transparent; font-size: .75rem; font-weight: 700; cursor: pointer; color: var(--subtext); letter-spacing: .3px; font-family: inherit; transition: background .15s, color .15s, box-shadow .2s; }
.lang-toggle .lang-btn:hover { color: var(--text); }
.lang-toggle .lang-btn.active { background: var(--teal); color: #fff; box-shadow: 0 2px 6px rgba(0,97,212,.3); }

/* When tc-sidebar.js injects a sidebar onto a page that didn't ship with one
   (the public marketing pages), body content needs to shift right by the
   sidebar width. Sidebar is position:fixed so this is just left padding.
   Override the global body display:flex back to block so the marketing
   page's natural top-nav + .page block layout isn't turned into two
   side-by-side flex columns.
   Mobile: drop the padding so the sidebar can slide over content instead. */
body.has-injected-sidebar { display: block; padding-left: var(--sidebar-w); }
/* Pages that explicitly opt out of the sidebar layout (marketing/landing pages
   loaded by an anonymous visitor). Without this, the global body{display:flex}
   stacks their top-nav and main column horizontally. */
body.no-sidebar { display: block; }
@media (max-width: 768px) {
  body.has-injected-sidebar { padding-left: 0; }
  .sidebar.tc-sidebar-injected { transform: translateX(-100%); }
}

/* Back button at the top of the sidebar (injected by tc-sidebar.js).
   Sits above the section labels, ghost-style on the dark navy background. */
.sidebar-back { display: flex; align-items: center; gap: 8px; margin: 12px 12px 6px; padding: 8px 12px; border-radius: var(--r-md, 10px); border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04); color: rgba(255,255,255,.7); font-size: .8rem; font-weight: 600; cursor: pointer; font-family: inherit; transition: background .15s, color .15s, border-color .15s; text-decoration: none; }
.sidebar-back:hover { background: rgba(255,255,255,.10); color: #fff; border-color: rgba(255,255,255,.22); }
.sidebar-back svg { width: 14px; height: 14px; flex-shrink: 0; }

.sidebar-nav {
  flex: 1; padding: 16px 12px;
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto;
}
.nav-section-label {
  font-size: .68rem; font-weight: 700;
  color: rgba(255,255,255,.25);
  letter-spacing: 1px; text-transform: uppercase;
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--r-md);
  color: rgba(255,255,255,.55);
  font-size: .875rem; font-weight: 500;
  text-decoration: none; cursor: pointer;
  transition: background .15s, color .15s;
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.85); }
.nav-item.active { background: rgba(13,158,138,.2); color: var(--teal-soft); }

/* Profile-aware "My Notes" entry — appears at the top of the sidebar when
   the URL carries a ?profile= param (client.html / program-detail / etc.).
   The parent section label shows the active client's name in title case. */
.nav-item.nav-profile-notes { color: rgba(255,255,255,.78); }
.nav-item.nav-profile-notes:hover { color: #fff; }
.nav-item.nav-profile-notes.active { background: rgba(0,97,212,.28); color: #fff; }
.nav-pro-badge {
  margin-left: auto;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  font-size: .58rem;
  font-weight: 800;
  letter-spacing: .6px;
  padding: 2px 6px;
  border-radius: 50px;
  text-transform: uppercase;
  line-height: 1;
}
/* When the user IS a PRO subscriber, the badge stays visible but takes a
   subtle green tint so it reads as "you have this" instead of "upgrade
   to unlock". Same shape and weight, different colour vocabulary. */
.nav-pro-badge.pro-active {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 0 0 1px rgba(16,185,129,.25) inset;
}
#profile-section-label { color: var(--teal-soft); text-transform: none; letter-spacing: .3px; font-size: .82rem; font-weight: 700; padding-top: 18px; }

/* Profile section block — shows the active client's name + a muted id chip
   underneath. Lives at the top of the sidebar on every page where the URL
   carries a ?profile= or ?id=. */
.nav-profile-header { padding: 18px 12px 6px; display: flex; flex-direction: column; gap: 4px; }
.nav-profile-header .nav-profile-name { color: #fff; font-size: .92rem; font-weight: 700; letter-spacing: -.1px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-profile-header .nav-profile-pid {
  align-self: flex-start;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.65);
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .3px;
  padding: 2px 8px;
  border-radius: 50px;
  border: 1px solid rgba(255,255,255,.1);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Notification badge — canonical red pill for unread/pending counts.
   Use via tc-nav-badges.js: tcNavBadge.set('contacts.html', 5) → injects
   <span class="nav-badge">5</span> at the end of the matching nav-item.
   .nav-badge.dot variant = small empty dot (no number).
   Also reusable inside cards / topbar — anywhere a red unread marker is needed. */
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .65rem;
  font-weight: 800;
  letter-spacing: .2px;
  padding: 2px 7px;
  min-width: 18px;
  height: 18px;
  border-radius: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 0 0 2px var(--navy);   /* halo so it pops on the dark sidebar */
}
.nav-badge.dot {
  min-width: 10px;
  width: 10px;
  height: 10px;
  padding: 0;
  font-size: 0;
  box-shadow: 0 0 0 2px var(--navy);
}
/* On a light surface (topbar, cards) the navy halo is wrong — drop the box-shadow */
.topbar .nav-badge, .card .nav-badge, .surface-light .nav-badge { box-shadow: none; }

.sidebar-footer { padding: 16px 12px; border-top: 1px solid rgba(255,255,255,.07); }
.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--r-md);
  cursor: pointer; transition: background .15s;
}
.user-row:hover { background: rgba(255,255,255,.06); }
.s-avatar {
  width: 34px; height: 34px; border-radius: var(--r-md);
  background: linear-gradient(135deg, var(--teal), var(--teal2));
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.user-name { font-size: .88rem; font-weight: 700; color: #fff; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; letter-spacing: -.1px; }
.user-plan {
  font-size: .62rem; font-weight: 800; letter-spacing: .6px; text-transform: uppercase;
  color: rgba(255,255,255,.7);
  background: rgba(255,255,255,.10);
  padding: 2px 8px; border-radius: 50px;
  align-self: flex-start; line-height: 1.4;
}
.user-plan.pro { color: var(--teal-soft); background: rgba(123,182,242,.18); }

/* Policies link injected at the very bottom of the sidebar by
   tc-sidebar.js. Sits below the user-pill row in .sidebar-footer.
   Visible enough to read at a glance; underlined on hover so it reads
   as a link, not a label. */
.sidebar-policies {
  display: block;
  text-align: center;
  margin-top: 12px;
  padding: 10px 10px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .2px;
  color: rgba(255,255,255,.85);
  text-decoration: none;
  border-top: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03);
  border-radius: 0 0 6px 6px;
  transition: color .15s, background .15s;
}
.sidebar-policies:hover {
  color: #fff;
  background: rgba(255,255,255,.08);
  text-decoration: underline;
}

/* ── MAIN ────────────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w); flex: 1;
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 28px; gap: 16px;
  position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-size: 1rem; font-weight: 700; color: var(--text); flex: 1; }
.search-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--r-md); padding: 7px 12px; width: 220px;
}
.search-wrap svg { width: 15px; height: 15px; color: var(--subtext); flex-shrink: 0; }
.search-wrap input {
  border: none; background: transparent;
  font-size: .82rem; font-family: inherit; color: var(--text);
  outline: none; width: 100%;
}
.content { flex: 1; padding: 28px 32px; max-width: 960px; }

/* ── PAGE HEADERS ────────────────────────────────────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-title  { font-size: 1.4rem; font-weight: 800; color: var(--text); letter-spacing: -.4px; margin-bottom: 4px; }
.page-sub    { font-size: .875rem; color: var(--subtext); }

/* ── CARDS ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px 20px;
  transition: box-shadow .2s;
}
.card:hover { box-shadow: 0 2px 12px rgba(0,0,0,.06); }
.card.interactive { cursor: pointer; transition: box-shadow .2s, transform .15s, border-color .2s; }
.card.interactive:hover { box-shadow: 0 8px 24px rgba(13,158,138,.10); transform: translateY(-2px); border-color: rgba(13,158,138,.25); }

/* ── TAGS / PILLS ────────────────────────────────────────────────────────── */
.tag { font-size: .7rem; font-weight: 600; padding: 3px 9px; border-radius: var(--r-pill); background: rgba(13,158,138,.1); color: var(--teal); }
.tag.therapy { background: rgba(99,102,241,.1); color: #6366F1; }
.tag.warning { background: rgba(245,158,11,.1); color: #D97706; }
.tag.danger  { background: rgba(220,38,38,.1);  color: #B91C1C; }
.tag.success { background: rgba(16,185,129,.1); color: #047857; }
.tag.muted   { background: rgba(107,122,141,.1); color: var(--subtext); }

/* ── BUTTONS ─────────────────────────────────────────────────────────────── */
.btn {
  padding: 8px 16px; border-radius: var(--r-sm);
  font-size: .82rem; font-weight: 700;
  cursor: pointer; border: none; text-decoration: none;
  display: inline-flex; align-items: center; gap: 7px;
  font-family: inherit;
  transition: background .15s, color .15s, border-color .15s, opacity .15s;
}
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--teal2); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--subtext); border: 1.5px solid var(--border); }
.btn-ghost:hover { color: var(--teal); border-color: var(--teal); }
.btn-danger { background: rgba(220,38,38,.1); color: var(--danger); border: 1.5px solid rgba(220,38,38,.2); }
.btn-danger:hover { background: rgba(220,38,38,.18); }

/* ── INPUTS ──────────────────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.label { display: block; font-size: .82rem; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.input, .select, .textarea {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  font-size: .92rem; color: var(--text); background: var(--surface);
  font-family: inherit;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(13,158,138,.12);
}
.textarea { resize: vertical; min-height: 70px; }

/* ── TABS ────────────────────────────────────────────────────────────────── */
.tabs-bar { display: flex; gap: 8px; border-bottom: 1px solid var(--border); margin-bottom: 18px; align-items: center; flex-wrap: wrap; }
.tab-btn {
  background: transparent; border: none;
  color: var(--muted); padding: 9px 14px;
  font-size: .86rem; font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-family: inherit; transition: color .15s, border-color .15s;
  display: flex; align-items: center; gap: 8px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--teal); border-bottom-color: var(--teal); }

/* ── EMPTY / SKELETON ────────────────────────────────────────────────────── */
.empty { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 60px 32px; text-align: center; }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty h3 { font-size: 1.05rem; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.empty p  { font-size: .875rem; color: var(--subtext); max-width: 380px; margin: 0 auto; }

.skeleton { background: linear-gradient(90deg,#f0f0f0 25%,#e0e0e0 50%,#f0f0f0 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-sm); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── HAMBURGER + MOBILE ──────────────────────────────────────────────────── */
.hamburger { display: none; background: none; border: none; cursor: pointer; padding: 4px; color: var(--text); }
.hamburger svg { width: 22px; height: 22px; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 49; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main { margin-left: 0; }
  .hamburger { display: flex; }
  .content { padding: 20px 16px; }
  .search-wrap { width: 100%; }
}

/* ── ALERT BANNERS ───────────────────────────────────────────────────────── */
.alert { padding: 11px 14px; border-radius: var(--r-md); font-size: .88rem; font-weight: 500; margin-bottom: 14px; }
.alert.alert-info    { background: rgba(37,99,235,.08); border: 1px solid rgba(37,99,235,.18); color: #1d4ed8; }
.alert.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert.alert-warn    { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
