/*
 * Footsteps to Freedom — Brand Design System
 * ============================================
 * Dark-mode CRM matching the client recovery app's visual identity.
 * All colours defined as CSS custom properties for easy theming.
 */

/* ── Colour Tokens ───────────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg-body:       #0f1923;
  --bg-sidebar:    #1a2332;
  --bg-card:       #141e2e;
  --bg-card-hover: #1a2840;
  --bg-input:      #1a2332;
  --bg-overlay:    rgba(0,0,0,0.55);

  /* Borders */
  --border:        #3b3b3b;
  --border-accent: #2dd4bf;

  /* Text */
  --text-primary:  #f3f6fa;
  --text-muted:    #b5c0d0;
  --text-faint:    #8ca0b8;
  --text-heading:  #ffffff;

  /* Brand Accent – Teal */
  --accent:        #2dd4bf;
  --accent-hover:  #14b8a6;
  --accent-subtle: rgba(45,212,191,0.12);

  /* Semantic */
  --danger:        #ef4444;
  --danger-subtle: rgba(239,68,68,0.15);
  --warning:       #f59e0b;
  --warning-subtle:rgba(245,158,11,0.15);
  --success:       #22c55e;
  --success-subtle:rgba(34,197,94,0.15);
  --info:          #3b82f6;
  --info-subtle:   rgba(59,130,246,0.14);

  /* Logo stone colours */
  --stone-green:   #2dd4bf;
  --stone-blue:    #6366f1;
  --stone-purple:  #a855f7;

  /* Spacing */
  --sidebar-width: 230px;
  --radius:        12px;
  --radius-sm:     8px;
  --radius-pill:   999px;
}

/* ── Reset & Global ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg-body);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

h1, h2, h3, h4, h5, h6 {
  color: var(--text-heading);
  margin: 0 0 0.5em 0;
  font-weight: 600;
  line-height: 1.3;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

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

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

.sidebar-brand {
  padding: 20px 18px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand .brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.sidebar-brand .brand-stones {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.sidebar-brand .stone {
  width: 14px;
  height: 10px;
  border-radius: 50%;
}
.sidebar-brand .stone.green  { background: var(--stone-green);  width: 10px; }
.sidebar-brand .stone.blue   { background: var(--stone-blue);   width: 14px; }
.sidebar-brand .stone.purple { background: var(--stone-purple); width: 12px; }

.sidebar-brand .brand-text {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-heading);
  letter-spacing: 0.5px;
  line-height: 1.2;
}
.sidebar-brand .brand-text span {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.sidebar-user {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg-body);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.sidebar-user .user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-user .user-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}
.sidebar-user .user-role {
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Nav links */
.sidebar-nav {
  flex: 1;
  padding: 10px 0;
}

.sidebar-nav a,
.sidebar-nav .nav-section {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  font-size: 0.88rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
  text-decoration: none;
}

.sidebar-nav a.active {
  color: var(--accent);
  background: var(--accent-subtle);
  border-left-color: var(--accent);
  font-weight: 600;
}

.sidebar-nav .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.sidebar-nav .nav-section {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-faint);
  margin-top: 14px;
  padding-bottom: 4px;
  cursor: default;
}

.sidebar-nav .nav-badge {
  margin-left: auto;
  background: var(--danger-subtle);
  color: var(--danger);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
}

.sidebar-nav .nav-badge.warn {
  background: var(--warning-subtle);
  color: var(--warning);
}

/* ── Main Content Area ───────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  padding: 24px 28px;
  max-width: 1200px;
}

/* ── Cards (fx-card replacement) ─────────────────────────────── */
.fx-card,
article {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}

article header {
  margin-bottom: 12px;
}

/* ── Pills ───────────────────────────────────────────────────── */
.pill, .fx-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
}

.pill.info, .fx-pill.info {
  background: var(--info-subtle);
  color: #93c5fd;
  border-color: rgba(59,130,246,0.2);
}
.pill.warning, .fx-pill.warning {
  background: var(--warning-subtle);
  color: #fcd34d;
  border-color: rgba(245,158,11,0.2);
}
.pill.high, .fx-pill.high {
  background: var(--danger-subtle);
  color: #fca5a5;
  border-color: rgba(239,68,68,0.2);
}
.pill.success, .fx-pill.success {
  background: var(--success-subtle);
  color: #86efac;
  border-color: rgba(34,197,94,0.2);
}

/* ── Forms & Inputs ──────────────────────────────────────────── */
input, select, textarea {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-subtle);
}
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--danger) !important;
  background: #2a1a1a;
  color: #fff;
}

.field-error {
  color: var(--danger);
  font-size: 0.97em;
  min-height: 18px;
  margin: 2px 0 8px 0;
  font-weight: 500;
  letter-spacing: 0.1px;
}

select option, select optgroup {
  background: var(--bg-sidebar);
  color: var(--text-primary);
}

label {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

/* ── Buttons (48px min tap target per design system) ───────────── */
button, [role="button"], input[type="submit"] {
  background: var(--accent);
  color: var(--bg-body);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  min-height: 48px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background 0.15s;
}

button:hover, [role="button"]:hover, input[type="submit"]:hover {
  background: var(--accent-hover);
  text-decoration: none;
}

button.secondary, [role="button"].secondary {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
button.secondary:hover, [role="button"].secondary:hover {
  background: rgba(255,255,255,0.10);
}

button.outline, [role="button"].outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
button.outline:hover, [role="button"].outline:hover {
  background: var(--accent-subtle);
}

/* ── Tables ──────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
  color: var(--text-primary);
}
table th {
  text-align: left;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
}
table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
table tbody tr:hover {
  background: rgba(255,255,255,0.02);
}

/* ── Utility Classes ─────────────────────────────────────────── */
.muted { color: var(--text-muted); }
.small { font-size: 0.88rem; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 220px; }
.cardgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.container-tight { max-width: 1200px; margin: 0 auto; }
.inlineform { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.fx-accent { color: var(--accent); }

/* Stat number */
.stat-number {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-heading);
}

/* ── Toast ────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 9999;
  width: min(420px, calc(100vw - 36px));
}
.toast article {
  padding: 14px;
  border-left: 4px solid var(--accent);
}
.danger { border-left-color: var(--danger) !important; }

/* ── Sticky filters ──────────────────────────────────────────── */
.sticky-filters {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-body);
  padding-top: 8px;
}

/* Client detail — pinned mobile quick actions */
#mobile-action-bar a,
#mobile-action-bar button {
  color: #f8fafc;
  background: transparent;
  border: none;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}
#mobile-action-bar a:hover,
#mobile-action-bar button:hover {
  color: #fff;
  text-decoration: underline;
}

/* ── Dialog / Modal ──────────────────────────────────────────── */
dialog {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
dialog::backdrop {
  background: var(--bg-overlay);
}
dialog article {
  max-width: 720px;
  border: none;
  margin: 0;
}

/* Client drawer */
#client-drawer {
  width: min(520px, 92vw);
  height: 100vh;
  margin: 0;
  padding: 0;
  border: none;
  position: fixed;
  right: 0;
  top: 0;
  border-radius: 0;
}
#client-drawer article {
  height: 100vh;
  border-radius: 0;
  margin: 0;
  overflow: auto;
}

/* ── Bell dropdown ───────────────────────────────────────────── */
.bell-wrap { position: relative; }
.bell-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 1rem;
}
.bell-btn:hover { background: var(--bg-card-hover); }
.bell-panel {
  position: absolute;
  right: 0;
  top: 44px;
  width: min(420px, 92vw);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-sidebar);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  z-index: 2000;
  padding: 12px;
  display: none;
}
.bell-panel.open { display: block; }
.bell-item { padding: 10px; border-radius: var(--radius-sm); }
.bell-item:hover { background: rgba(255,255,255,0.04); }
.bell-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* ── Risk elements ───────────────────────────────────────────── */
.riskbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.riskdot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.riskdot.high { background: var(--danger); box-shadow: 0 0 8px rgba(239,68,68,0.4); }
.riskdot.med  { background: var(--warning); box-shadow: 0 0 8px rgba(245,158,11,0.3); }
.riskdot.low  { background: var(--success); }

/* ── Calendar ────────────────────────────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.cal-day {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  min-height: 160px;
}
.cal-day.today {
  border-color: var(--accent);
  background: rgba(45,212,191,0.06);
}
.cal-day .day-header {
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}
.cal-day.today .day-header {
  color: var(--accent);
}
.cal-entry {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 7px;
  margin-bottom: 4px;
  font-size: 0.82rem;
}
.cal-entry.dna {
  border-left: 3px solid var(--danger);
}

/* ── Details / Summary ────────────────────────────────────────── */
details {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-primary);
  list-style: disclosure-closed;
}
details[open] summary {
  margin-bottom: 8px;
  list-style: disclosure-open;
}

/* ── Scrollbars (Webkit) ─────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-body); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.20); }

/* ── Links in cards ──────────────────────────────────────────── */
.fx-card a, article a { color: var(--accent); }
.fx-card a:hover, article a:hover { color: var(--accent-hover); }

/* ── Code in cards ───────────────────────────────────────────── */
code {
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88rem;
  color: var(--accent);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: relative;
    min-width: unset;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .main-content {
    margin-left: 0;
    padding: 16px;
  }
  .app-shell {
    flex-direction: column;
  }
  .sidebar-nav a {
    padding: 8px 14px;
  }
  .cal-grid {
    grid-template-columns: 1fr;
  }
}
