/* ═══════════════════════════════════════════════════
   Luminwell — Calendar (dashboard view)
   Pure CSS, no JavaScript
═══════════════════════════════════════════════════ */

/* ── Tokens ───────────────────────────────────────── */
:root {
  --sb-bg:       #175d92;
  --sb-deep:     #134a75;
  --sb-hover:    rgba(255,255,255,.1);
  --sb-active:   rgba(255,255,255,.18);
  --sb-line:     rgba(255,255,255,.12);
  --sb-text:     #f4f8fc;
  --sb-muted:    rgba(244,248,252,.58);

  --page-bg:     #f8f9fb;
  --surface:     #ffffff;
  --teal:        #2d9676;
  --teal-pale:   #eaf5f1;
  --teal-deep:   #1d6e55;
  --text:        #0c1929;
  --muted:       #64748b;
  --soft:        #94a3b8;
  --border:      rgba(12,25,41,.09);
  --shadow:      0 1px 3px rgba(12,25,41,.05), 0 8px 28px rgba(12,25,41,.06);
  --shadow-sm:   0 1px 3px rgba(12,25,41,.06);
  --r:           12px;
  --r-full:      9999px;
  --sb-width:    268px;
  --font:        "DM Sans", system-ui, -apple-system, sans-serif;
}

/* ── Reset ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
p, h1, h2, h3 { margin: 0; }

/* ── CSS-only filter state (hidden radio inputs) ──── */
.filter-input {
  position: absolute;
  width: 0; height: 0;
  opacity: 0;
  pointer-events: none;
}

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

/* ══════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════ */
.sidebar {
  width: var(--sb-width);
  flex-shrink: 0;
  background: var(--sb-bg);
  color: var(--sb-text);
  display: flex;
  flex-direction: column;
  padding: 16px 14px 14px;
  overflow: hidden;
}
.sidebar__head {
  display: flex; align-items: center; gap: 10px;
  padding: 0 6px 18px; margin-bottom: 4px;
  border-bottom: 1px solid var(--sb-line);
}
.sidebar__logo-img { width: 30px; height: 30px; object-fit: contain; flex-shrink: 0; border-radius: 6px; }
.sidebar__logo     { font-size: 11px; font-weight: 700; letter-spacing: .18em; flex: 1; min-width: 0; }

.sidebar__block       { margin-bottom: 18px; }
.sidebar__block--fill { flex: 1; display: flex; flex-direction: column; min-height: 0; margin-bottom: 0; }
.sidebar__label       { padding: 0 8px 8px; font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--sb-muted); }

.sidebar__new {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; height: 36px; padding: 0 12px;
  border: 1px solid rgba(255,255,255,.22); border-radius: 10px;
  background: rgba(255,255,255,.06); color: var(--sb-text);
  font-size: 13px; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: background .15s, border-color .15s;
}
.sidebar__new:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.3); }
.sidebar__new svg { width: 16px; height: 16px; flex-shrink: 0; }

.sb-nav { display: flex; flex-direction: column; gap: 2px; }
.sb-nav__link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--sb-text); font-size: 13px; font-weight: 500;
  transition: background .15s;
}
.sb-nav__link:hover     { background: var(--sb-hover); }
.sb-nav__link.is-active { background: var(--sb-active); box-shadow: inset 0 0 0 1px rgba(255,255,255,.07); }
.sb-nav__icon { width: 17px; height: 17px; flex-shrink: 0; opacity: .92; }

.sb-recent {
  flex: 1; min-height: 60px;
  display: flex; flex-direction: column; gap: 1px;
  overflow-y: auto; margin: 0 -2px; padding: 0 2px 4px;
}
.sb-recent__btn {
  width: 100%; padding: 8px 10px; border: none; border-radius: 8px;
  background: transparent; color: inherit; cursor: pointer; text-align: left;
  font-family: var(--font); transition: background .15s;
}
.sb-recent__btn:hover { background: var(--sb-hover); }
.sb-recent__title {
  font-size: 12px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.sb-recent__meta { font-size: 11px; color: var(--sb-muted); margin-top: 2px; }

.sidebar__foot {
  padding-top: 12px; margin-top: auto;
  border-top: 1px solid var(--sb-line);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.sidebar__avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar__avatar svg { width: 17px; height: 17px; }
.sidebar__who     { flex: 1; min-width: 0; }
.sidebar__name    { font-size: 13px; font-weight: 700; }
.sidebar__credits { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--sb-muted); margin-top: 1px; }
.sidebar__credits svg { width: 12px; height: 12px; }

/* ══════════════════════════════════════════════════
   MAIN + TOPBAR
══════════════════════════════════════════════════ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 56px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0; gap: 12px;
}
.topbar__left  { display: flex; align-items: center; gap: 10px; }
.topbar__logo-img { width: 30px; height: 30px; object-fit: contain; border-radius: 6px; }
.topbar__title { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
.topbar__right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.topbar__crisis {
  padding: 5px 12px; border-radius: var(--r-full);
  background: rgba(239,68,68,.09); color: #b91c1c;
  font-size: 12px; font-weight: 700; transition: background .15s;
}
.topbar__crisis:hover { background: rgba(239,68,68,.16); }
.topbar__icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: none;
  background: transparent; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.topbar__icon-btn:hover { background: rgba(12,25,41,.05); color: var(--text); }
.topbar__icon-btn svg { width: 18px; height: 18px; }

/* ══════════════════════════════════════════════════
   CALENDAR PAGE SHELL
══════════════════════════════════════════════════ */
.cal-page {
  flex: 1;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

/* ── Dashboard header ─────────────────────────────── */
.cal-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.cal-greeting__eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 4px;
}
.cal-greeting__title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1.1;
}
.cal-greeting__sub {
  font-size: 14px;
  color: var(--muted);
  margin-top: 5px;
}

.btn-new {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 10px;
  background: var(--sb-bg);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background .14s, box-shadow .14s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-new:hover { background: var(--sb-deep); box-shadow: 0 4px 14px rgba(23,93,146,.32); }
.btn-new svg { width: 16px; height: 16px; }

/* ── Stats strip ──────────────────────────────────── */
.dash-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.dash-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.dash-stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--r) var(--r) 0 0;
}
.dash-stat--journal::before { background: #3b82f6; }
.dash-stat--session::before { background: var(--teal); }
.dash-stat--active::before  { background: #8b5cf6; }
.dash-stat--mood::before    { background: #f59e0b; }

.dash-stat__icon {
  font-size: 16px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
}
.dash-stat__icon svg { width: 18px; height: 18px; }

.dash-stat--journal .dash-stat__icon { color: #3b82f6; }
.dash-stat--session .dash-stat__icon { color: var(--teal); }
.dash-stat--active  .dash-stat__icon { color: #8b5cf6; }
.dash-stat--mood    .dash-stat__icon { color: #f59e0b; }

.dash-stat__num {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--text);
  line-height: 1;
}
.dash-stat__label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-top: 3px;
}
.dash-stat__trend {
  font-size: 11px;
  font-weight: 600;
  color: var(--teal);
  margin-top: 2px;
}

/* ── Controls bar ─────────────────────────────────── */
.cal-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-nav-btn {
  width: 32px; height: 32px;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .14s, color .14s;
}
.cal-nav-btn:hover { background: rgba(12,25,41,.04); color: var(--text); }
.cal-nav-btn svg  { width: 16px; height: 16px; }
.cal-month-h {
  font-size: 20px; font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0; min-width: 148px; text-align: center;
}

/* Filter chips — label elements linked to hidden radio inputs */
.cal-chips { display: flex; gap: 6px; }
.chip {
  display: inline-flex; align-items: center;
  padding: 5px 14px; border-radius: var(--r-full);
  font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--surface); color: var(--muted);
  cursor: pointer; transition: all .14s; user-select: none;
}
.chip:hover { border-color: var(--sb-bg); color: var(--sb-bg); }

/* CSS-only active chip highlighting via :has() */
html:has(#filter-all:checked)     label[for="filter-all"],
html:has(#filter-journal:checked) label[for="filter-journal"],
html:has(#filter-session:checked) label[for="filter-session"] {
  background: var(--sb-bg);
  color: #fff;
  border-color: var(--sb-bg);
}

/* CSS-only filtering — hides events on calendar grid AND in right panel */
html:has(#filter-journal:checked) .cal-event--session,
html:has(#filter-journal:checked) .ev-card--session { display: none; }

html:has(#filter-session:checked) .cal-event--journal,
html:has(#filter-session:checked) .ev-card--journal  { display: none; }

.cal-controls-right { display: flex; gap: 8px; margin-left: auto; }

/* ══════════════════════════════════════════════════
   TWO-COLUMN CONTENT LAYOUT
══════════════════════════════════════════════════ */
.cal-content {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.cal-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ══════════════════════════════════════════════════
   CALENDAR GRID
══════════════════════════════════════════════════ */
.cal-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.cal-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
  background: rgba(12,25,41,.025);
}
.cal-dow {
  padding: 10px 12px;
  font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--soft); text-align: center;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }

.cal-cell {
  min-height: 100px;
  padding: 8px 10px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background .12s;
}
.cal-cell:nth-child(7n)      { border-right: none; }
.cal-cell:nth-last-child(-n+7) { border-bottom: none; }
.cal-cell--other-month { background: rgba(12,25,41,.018); }
.cal-cell--other-month .day-num { color: var(--soft); }
.cal-cell--has-event:hover { background: rgba(23,93,146,.035); cursor: default; }

/* Today ring */
.cal-cell--today .day-num {
  background: var(--sb-bg);
  color: #fff;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}

.cell-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.day-num {
  font-size: 13px; font-weight: 600; color: var(--text);
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Mood dot */
.mood-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.mood--great { background: #10b981; }
.mood--good  { background: #3b82f6; }
.mood--okay  { background: #f59e0b; }
.mood--low   { background: #f87171; }

/* Event pills on calendar cells */
.cal-events { display: flex; flex-direction: column; gap: 3px; }
.cal-event {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 7px; border-radius: 6px;
  font-size: 11px; font-weight: 600; line-height: 1.2;
  text-decoration: none; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  transition: opacity .12s, filter .12s;
}
.cal-event:hover { opacity: .82; filter: brightness(.96); }
.cal-event svg { width: 10px; height: 10px; flex-shrink: 0; }
.cal-event--journal { background: #dbeafe; color: #1d4ed8; }
.cal-event--session { background: var(--teal-pale); color: #1d6e55; }

/* ── Legend ───────────────────────────────────────── */
.cal-legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  align-items: center; padding: 4px 2px;
}
.leg-item { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; color: var(--muted); }
.leg-dot { width: 10px; height: 10px; border-radius: 50%; }
.leg-dot--journal { background: #3b82f6; }
.leg-dot--session { background: var(--teal); }
.leg-dot--today   { background: var(--sb-bg); }
.leg-dot--mood    { background: linear-gradient(135deg,#10b981,#f59e0b); }

/* ══════════════════════════════════════════════════
   RIGHT PANEL
══════════════════════════════════════════════════ */
.cal-panel {
  width: 304px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
}

/* Panel section card */
.panel-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.panel-section__head {
  padding: 13px 16px 11px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(12,25,41,.018);
}
.panel-section__title { font-size: 13px; font-weight: 700; color: var(--text); }
.panel-section__badge {
  font-size: 10px; font-weight: 700;
  color: var(--muted); background: var(--page-bg);
  padding: 2px 8px; border-radius: var(--r-full);
  border: 1px solid var(--border);
}

/* ── Upcoming card (today's session) ─────────────── */
.upcoming-wrap { padding: 14px 16px; }
.upcoming-card {
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(23,93,146,.07) 0%, rgba(45,150,118,.05) 100%);
  border: 1.5px solid rgba(23,93,146,.2);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.upcoming-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: var(--sb-bg); margin-bottom: 2px;
}
.upcoming-pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--sb-bg);
  animation: lw-pulse 1.8s ease-in-out infinite;
}
@keyframes lw-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .45; transform: scale(.78); }
}
.upcoming-title { font-size: 14px; font-weight: 700; color: var(--text); }
.upcoming-meta  { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.upcoming-meta svg { width: 12px; height: 12px; flex-shrink: 0; opacity: .65; }

/* ── Mood distribution chart ─────────────────────── */
.mood-chart { padding: 14px 16px; display: flex; flex-direction: column; gap: 9px; }
.mood-bar-row { display: flex; align-items: center; gap: 8px; }
.mood-bar-label { font-size: 11px; font-weight: 600; color: var(--muted); width: 34px; flex-shrink: 0; }
.mood-bar-track { flex: 1; height: 6px; background: #f1f5f9; border-radius: var(--r-full); overflow: hidden; }
.mood-bar-fill  { height: 100%; border-radius: var(--r-full); }
.mood-bar-fill--great { background: #10b981; }
.mood-bar-fill--good  { background: #3b82f6; }
.mood-bar-fill--okay  { background: #f59e0b; }
.mood-bar-fill--low   { background: #f87171; }
.mood-bar-count { font-size: 11px; font-weight: 700; color: var(--soft); width: 14px; text-align: right; flex-shrink: 0; }

/* ── Activity heatmap dots ───────────────────────── */
.heat-wrap { padding: 0 16px 14px; }
.heat-label { font-size: 11px; font-weight: 600; color: var(--soft); margin-bottom: 8px; }
.heat-row { display: flex; gap: 5px; flex-wrap: wrap; }
.heat-dot {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--page-bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: var(--soft);
  position: relative;
}
.heat-dot--journal { background: rgba(59,130,246,.15); border-color: rgba(59,130,246,.3); color: #1d4ed8; }
.heat-dot--session { background: rgba(45,150,118,.15); border-color: rgba(45,150,118,.3); color: var(--teal-deep); }
.heat-dot--both    { background: linear-gradient(135deg, rgba(59,130,246,.18), rgba(45,150,118,.18)); border-color: rgba(45,150,118,.3); color: var(--teal-deep); }
.heat-dot--today   { box-shadow: 0 0 0 2px var(--sb-bg); }

/* ── Event list (event cards in right panel) ─────── */
.ev-list { display: flex; flex-direction: column; }

.ev-card {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-left: 3px solid transparent;
  transition: background .12s;
}
.ev-card:last-child { border-bottom: none; }
.ev-card:hover      { background: rgba(12,25,41,.02); }
.ev-card--journal   { border-left-color: #3b82f6; }
.ev-card--session   { border-left-color: var(--teal); }
.ev-card--today     { background: rgba(23,93,146,.04); }

.ev-card__header {
  display: flex; align-items: center;
  justify-content: space-between; gap: 8px;
}
.ev-type {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; padding: 2px 7px; border-radius: var(--r-full);
}
.ev-type svg { width: 9px; height: 9px; }
.ev-type--journal { background: #dbeafe; color: #1d4ed8; }
.ev-type--session { background: var(--teal-pale); color: #1d6e55; }

.ev-card__date  { font-size: 11px; font-weight: 600; color: var(--soft); white-space: nowrap; }
.ev-card__title { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.3; }
.ev-card__preview {
  font-size: 12px; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.ev-card__meta {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--muted);
}
.ev-card__meta svg { width: 11px; height: 11px; opacity: .7; }
.ev-card__footer {
  display: flex; align-items: center;
  justify-content: space-between; gap: 8px;
  margin-top: 1px;
}
.ev-mood-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: var(--r-full);
}
.ev-mood-badge--great { background: rgba(16,185,129,.1);  color: #065f46; }
.ev-mood-badge--good  { background: rgba(59,130,246,.1);  color: #1d4ed8; }
.ev-mood-badge--okay  { background: rgba(245,158,11,.1);  color: #92400e; }
.ev-mood-badge--low   { background: rgba(248,113,113,.1); color: #b91c1c; }
.ev-card__link {
  font-size: 11px; font-weight: 700; color: var(--sb-bg);
  white-space: nowrap; transition: color .12s;
}
.ev-card__link:hover { color: var(--sb-deep); }

.ev-card__today-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--sb-bg);
}
.ev-card__today-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--sb-bg);
  animation: lw-pulse 1.8s ease-in-out infinite;
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 1100px) {
  .cal-panel { width: 268px; }
  .dash-strip { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .cal-content  { flex-direction: column; }
  .cal-panel    { width: 100%; position: static; }
  .dash-strip   { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 720px) {
  .cal-page     { padding: 16px; gap: 14px; }
  .cal-event span { display: none; }
  .cal-cell     { min-height: 72px; padding: 6px; }
  .dash-strip   { grid-template-columns: repeat(2, 1fr); }
  .cal-greeting__title { font-size: 22px; }
}
@media (max-width: 520px) {
  .sidebar { display: none; }
  .cal-month-h { font-size: 16px; min-width: 110px; }
}
