/* ===========================================================
   ConnectingSynapse — App Shell (sidebar + topbar layout)
   Used by pages/dashboard.html, pages/study-schedule.html,
   pages/search.html. Shares brand tokens with css/main.css
   (navy/gold, Outfit) — this file adds the sidebar/topbar
   layout patterns for the logged-in study area.
=========================================================== */

:root {
  --shell-sidebar-w: 272px;
  --shell-topbar-h: 64px;
  --shell-line: #e1e4eb;
  --shell-line-soft: #edeff3;
  --shell-surface-sunken: #f4f5f8;
  --shell-ink-700: #33395a;
  --shell-ink-500: var(--color-text-muted);
  --shell-ink-400: #8890a4;
  --shell-radius-sm: 8px;
  --shell-radius-md: 12px;
  --shell-radius-lg: 16px;
  --shell-shadow-card: 0 1px 2px rgba(11,23,59,0.05), 0 1px 10px rgba(11,23,59,0.06);
  --shell-shadow-pop: 0 8px 28px rgba(11,23,59,0.18);
}

.app-shell { display: flex; min-height: 100vh; background: var(--shell-surface-sunken); }

/* ---------- Sidebar ---------- */

.shell-sidebar {
  width: var(--shell-sidebar-w);
  flex-shrink: 0;
  background: var(--color-navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: transform .25s ease;
  z-index: 40;
}

.shell-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.shell-sidebar-logo img { height: 34px; width: auto; }
.shell-sidebar-logo .wordmark { height: 30px; width: auto; }

.shell-nav { padding: 10px 10px; border-bottom: 1px solid rgba(255,255,255,0.1); }

.shell-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--shell-radius-sm);
  font-weight: 600;
  font-size: 14px;
  color: #c7cde0;
  margin-bottom: 2px;
}
.shell-nav-item i { width: 18px; text-align: center; color: #8b93b3; font-size: 15px; }
.shell-nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.shell-nav-item.active { background: var(--color-gold); color: var(--color-navy); }
.shell-nav-item.active i { color: var(--color-navy); }

.shell-section-label {
  padding: 16px 18px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #7a82a3;
}

.shell-topics { padding: 4px 10px 20px; flex: 1; }

.shell-topics-item { border-radius: var(--shell-radius-sm); margin-bottom: 2px; }

.shell-topics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 8px;
  border-radius: var(--shell-radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  color: #dfe3ef;
  cursor: pointer;
}
.shell-topics-header:hover { background: rgba(255,255,255,0.08); }
.shell-topics-header .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.shell-topics-header .label { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.shell-topics-header .label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-topics-header .angle-right { font-size: 11px; color: #7a82a3; transition: transform .18s ease; }
.shell-topics-item.open .angle-right { transform: rotate(90deg); }

.shell-topics-body { display: none; padding: 2px 8px 10px 26px; }
.shell-topics-item.open .shell-topics-body { display: block; }

.shell-topics-body .sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--shell-radius-sm);
  font-size: 13px;
  color: #b7bedb;
}
.shell-topics-body .sub:hover { background: rgba(255,255,255,0.08); color: #fff; }
.shell-topics-body .sub span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shell-topics-body .tag { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; flex-shrink: 0; }
.shell-topics-body .tag.visited { background: rgba(46,204,113,0.18); color: #6be79a; }
.shell-topics-body .tag.new { background: rgba(255,255,255,0.1); color: #9aa2c2; }

/* ---------- Topbar ---------- */

.shell-topbar {
  height: var(--shell-topbar-h);
  border-bottom: 1px solid var(--shell-line);
  background: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.shell-menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--color-navy);
  padding: 6px;
  cursor: pointer;
}

.shell-search { flex: 1; max-width: 480px; position: relative; }
.shell-search input {
  width: 100%;
  border: 1px solid var(--shell-line);
  background: var(--shell-surface-sunken);
  border-radius: 999px;
  padding: 9px 16px 9px 38px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--color-text);
}
.shell-search input:focus { outline: none; border-color: var(--color-gold); background: #fff; }
.shell-search i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--shell-ink-400); font-size: 13px; }

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

.shell-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-navy), #1c3466);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ---------- Main ---------- */

.shell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.shell-content { padding: 28px 32px 60px; max-width: 1180px; width: 100%; margin: 0 auto; }

.shell-page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.shell-page-header h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; color: var(--color-navy); }
.shell-page-header p { margin: 0; color: var(--shell-ink-500); font-size: 14px; }

.shell-grid-2 { display: grid; grid-template-columns: 1fr 320px; gap: 22px; align-items: start; }

.shell-card {
  background: #fff;
  border: 1px solid var(--shell-line);
  border-radius: var(--shell-radius-lg);
  box-shadow: var(--shell-shadow-card);
}
.shell-card-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 4px; }
.shell-card-header h2 { font-size: 16px; font-weight: 700; margin: 0; color: var(--color-navy); }
.shell-card-header a.shell-see-all { font-size: 12.5px; font-weight: 700; color: var(--color-gold-hover); }
.shell-card-body { padding: 12px 20px 20px; }

/* stat row */
.shell-stat-row { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 22px; }
.shell-stat-card {
  flex: 1; min-width: 150px;
  background: #fff;
  border: 1px solid var(--shell-line);
  border-radius: var(--shell-radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shell-shadow-card);
}
.shell-stat-card .shell-stat-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; margin-bottom: 10px; color: #fff;
}
.shell-stat-card .shell-stat-value { font-size: 21px; font-weight: 700; line-height: 1.1; color: var(--color-navy); }
.shell-stat-card .shell-stat-label { font-size: 12.5px; color: var(--shell-ink-500); font-weight: 600; margin-top: 2px; }

/* subject row (replaces MedPath's video row — real subjects, not fake videos) */
.shell-subject-row { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 6px; margin: 0 -4px; }
.shell-subject-row::-webkit-scrollbar { height: 6px; }
.shell-subject-row::-webkit-scrollbar-thumb { background: var(--shell-line); border-radius: 4px; }

.shell-subject-card {
  width: 200px; flex-shrink: 0; padding: 14px; text-decoration: none;
  border: 1px solid var(--shell-line); border-radius: var(--shell-radius-md);
  display: block; color: inherit;
}
.shell-subject-card:hover { border-color: var(--color-gold); text-decoration: none; }
.shell-subject-card .cat-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.shell-subject-card .cat { font-size: 11px; font-weight: 700; color: var(--shell-ink-400); text-transform: uppercase; letter-spacing: .04em; }
.shell-subject-card .name { font-size: 14.5px; font-weight: 700; color: var(--color-navy); margin-top: 6px; line-height: 1.3; }
.shell-subject-card .meta { font-size: 12px; color: var(--shell-ink-500); margin-top: 6px; }

/* module item (real modules: SynaCards, SynaDose, etc — replaces fake quiz bank) */
.shell-module-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--shell-line-soft);
}
.shell-module-item:last-child { border-bottom: none; }
.shell-module-item .icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--shell-surface-sunken);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-navy); font-size: 16px; flex-shrink: 0;
}
.shell-module-item .icon img {
  width: 24px; height: 24px; object-fit: contain;
}
.shell-module-item .body { flex: 1; min-width: 0; }
.shell-module-item .name { font-weight: 700; font-size: 14px; margin-bottom: 2px; color: var(--color-navy); }
.shell-module-item .sub { font-size: 12px; color: var(--shell-ink-400); }

/* progress ring */
.shell-progress-ring-wrap { position: relative; width: 88px; height: 88px; flex-shrink: 0; }
.shell-progress-ring-wrap svg { transform: rotate(-90deg); }
.shell-progress-ring-wrap .pct {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px; color: var(--color-navy);
}

/* empty / continue list */
.shell-continue-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--shell-line-soft);
  text-decoration: none; color: inherit;
}
.shell-continue-item:last-child { border-bottom: none; }
.shell-continue-item:hover .name { color: var(--color-gold-hover); text-decoration: underline; }
.shell-continue-item .cat-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.shell-continue-item .body { flex: 1; min-width: 0; }
.shell-continue-item .name { font-weight: 700; font-size: 13.5px; color: var(--color-navy); }
.shell-continue-item .sub { font-size: 11.5px; color: var(--shell-ink-400); margin-top: 2px; }

.shell-empty { text-align: center; padding: 24px 16px; color: var(--shell-ink-500); font-size: 13.5px; }

/* agenda (study schedule) */
.shell-agenda-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--shell-line-soft); }
.shell-agenda-item:last-child { border-bottom: none; }
.shell-agenda-time { width: 64px; flex-shrink: 0; font-size: 12px; font-weight: 700; color: var(--shell-ink-400); padding-top: 2px; }
.shell-agenda-bar { width: 4px; border-radius: 4px; flex-shrink: 0; }
.shell-agenda-body { flex: 1; }
.shell-agenda-body .title { font-weight: 700; font-size: 13.5px; color: var(--color-navy); }
.shell-agenda-body .sub { font-size: 12px; color: var(--shell-ink-500); margin-top: 2px; }
.shell-agenda-remove { background: none; border: none; color: var(--shell-ink-400); cursor: pointer; font-size: 13px; padding: 4px; }
.shell-agenda-remove:hover { color: #e74c3c; }

.shell-day-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.shell-day-tab {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--shell-line);
  background: #fff; font-size: 13px; font-weight: 700; color: var(--shell-ink-500); cursor: pointer;
  font-family: var(--font);
}
.shell-day-tab.active-day { background: var(--color-navy); color: #fff; border-color: var(--color-navy); }

.shell-add-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.shell-add-form input, .shell-add-form select {
  padding: 9px 12px; border-radius: 8px; border: 1.5px solid #c7cace;
  font-family: var(--font); font-size: 13.5px; color: var(--color-navy);
}
.shell-add-form input[type="time"] { width: 110px; }
.shell-add-form input[type="text"] { flex: 1; min-width: 160px; }

.shell-search-empty-hint { color: var(--shell-ink-500); font-size: 13.5px; padding: 32px 8px; text-align: center; }

.shell-note {
  font-size: 12.5px; color: var(--shell-ink-400); background: var(--shell-surface-sunken);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 18px;
}

footer.shell-footer { text-align: center; padding: 24px; color: var(--shell-ink-400); font-size: 12px; }

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .shell-grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .shell-sidebar { position: fixed; left: 0; transform: translateX(-100%); box-shadow: var(--shell-shadow-pop); }
  .shell-sidebar.open { transform: translateX(0); }
  .shell-menu-toggle { display: inline-flex; }
  .shell-search { display: none; }
  .shell-content { padding: 20px 16px 48px; }
}

.shell-sidebar-scrim { display: none; position: fixed; inset: 0; background: rgba(11,23,59,.45); z-index: 35; }
.shell-sidebar-scrim.show { display: block; }
