/* ═══════════════════════════════════════════════════════
   Memory Core Hub — Page styles
   Responsive, mobile-first, tab-based layout on small screens
   ═══════════════════════════════════════════════════════ */

/* ── Body ── */
.mc-body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
}

/* ── Shell ── */
.mc-shell {
  position: relative;
  z-index: 1;
  width: min(1400px, 100%);
  margin: 0 auto;
  padding: calc(1.25rem + var(--safe-top)) calc(1rem + var(--safe-right)) calc(2rem + var(--safe-bottom)) calc(1rem + var(--safe-left));
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ══════════════════════════════════════
   TOPBAR
══════════════════════════════════════ */
.mc-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.25rem 1.4rem;
}
.mc-topbar-copy {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: 720px;
  min-width: 0;
}
.mc-topbar-title {
  font-size: clamp(1.3rem, 3vw, 2rem);
  font-family: var(--font-display), "Plus Jakarta Sans", -apple-system, sans-serif;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.mc-topbar-sub {
  font-size: 0.9rem;
  color: var(--muted-strong);
  line-height: 1.6;
}
.mc-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ══════════════════════════════════════
   STATS ROW
══════════════════════════════════════ */
.mc-stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}
.mc-stat-card {
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  border-radius: var(--radius-lg, 18px);
}
.mc-stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.mc-stat-card strong {
  font-family: var(--font-display), "Plus Jakarta Sans", -apple-system, sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  letter-spacing: -0.03em;
}
.mc-stat-sub {
  font-size: 0.78rem;
  color: var(--muted-strong);
  line-height: 1.4;
}

/* ══════════════════════════════════════
   MOBILE TABS (hidden on desktop)
══════════════════════════════════════ */
.mc-tabs {
  display: none;
  gap: 4px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  width: 100%;
}
.mc-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0.55rem 0.5rem;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted-strong);
  background: transparent;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color 160ms ease, background 160ms ease, box-shadow 160ms ease;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.mc-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.mc-tab.active {
  color: #0b1424;
  background: linear-gradient(135deg, var(--accent), var(--accent-2, #34d399));
  box-shadow: 0 2px 12px rgba(56, 189, 248, 0.28);
}
.mc-tab svg { flex-shrink: 0; }
.mc-tab.active svg { opacity: 1; }

/* ══════════════════════════════════════
   MAIN LAYOUT
══════════════════════════════════════ */
.mc-layout {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

/* ══════════════════════════════════════
   SIDEBAR
══════════════════════════════════════ */
.mc-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

/* ══════════════════════════════════════
   SHARED CARD STYLES
══════════════════════════════════════ */
.mc-card {
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius-lg, 18px);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.mc-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.mc-card-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-display), "Plus Jakarta Sans", -apple-system, sans-serif;
  line-height: 1.25;
}
.mc-mini-status {
  font-size: 0.76rem;
  color: var(--muted-strong);
  text-align: right;
  flex-shrink: 0;
}

/* Profile body */
.mc-profile-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Launcher copy block */
.mc-launcher-copy {
  font-size: 0.82rem;
  color: var(--muted-strong);
  line-height: 1.55;
  padding: 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.mc-launcher-copy:empty { display: none; }

/* Button stack in sidebar */
.mc-btn-stack {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.mc-btn-stack .primary-button,
.mc-btn-stack .ghost-button {
  width: 100%;
  justify-content: center;
}

/* Template list */
.mc-template-list {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

/* ══════════════════════════════════════
   WORKSPACE
══════════════════════════════════════ */
.mc-workspace {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

/* Toolbar */
.mc-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.mc-toolbar-copy {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}
.mc-toolbar-status {
  font-size: 0.82rem;
  color: var(--muted-strong);
  line-height: 1.5;
}
.mc-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0;
}
.mc-filter-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Split: projects + viewer */
.mc-split {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

/* Projects pane */
.mc-projects-pane {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 0;
}
.mc-pane-head {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.mc-pane-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-display), "Plus Jakarta Sans", -apple-system, sans-serif;
}

.mc-project-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  max-height: 60vh;
  -webkit-overflow-scrolling: touch;
  padding-right: 0.1rem;
}

/* Viewer pane */
.mc-viewer-pane {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 0;
}
.mc-viewer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.mc-viewer-title {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}
.mc-viewer-meta {
  font-size: 0.82rem;
  color: var(--muted-strong);
  line-height: 1.55;
}
.mc-viewer-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0;
}
.mc-viewer-body {
  overflow-y: auto;
  max-height: 62vh;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding-right: 0.15rem;
}

/* ══════════════════════════════════════
   RESPONSIVE — 1280px  (collapse split)
══════════════════════════════════════ */
@media (max-width: 1280px) {
  .mc-split {
    grid-template-columns: 1fr;
  }
  .mc-project-list,
  .mc-viewer-body {
    max-height: 50vh;
  }
}

/* ══════════════════════════════════════
   RESPONSIVE — 1040px  (collapse layout)
══════════════════════════════════════ */
@media (max-width: 1040px) {
  .mc-layout {
    grid-template-columns: 1fr;
  }
  .mc-stats-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ══════════════════════════════════════
   RESPONSIVE — 900px  (mobile tab mode)
══════════════════════════════════════ */
@media (max-width: 900px) {
  .mc-shell {
    padding: calc(0.85rem + var(--safe-top)) calc(0.75rem + var(--safe-right)) calc(1.5rem + var(--safe-bottom)) calc(0.75rem + var(--safe-left));
    gap: 0.85rem;
  }

  /* Show tabs */
  .mc-tabs { display: flex; }

  /* Tab-panel visibility:
     The .mc-body carries the active tab name.
     Panels are shown/hidden via data-mc-panel matching. */
  .mc-sidebar { display: none; }
  .mc-workspace { display: none; }
  .mc-toolbar { display: none; }
  .mc-projects-pane { display: none; }
  .mc-viewer-pane { display: none; }

  /* Overview tab → show sidebar */
  .mc-body[data-mc-tab="overview"] .mc-sidebar { display: flex; }

  /* Projects tab → show workspace, toolbar, projects pane */
  .mc-body[data-mc-tab="projects"] .mc-workspace { display: flex; }
  .mc-body[data-mc-tab="projects"] .mc-toolbar   { display: flex; }
  .mc-body[data-mc-tab="projects"] .mc-projects-pane { display: flex; }

  /* Viewer tab → show workspace, toolbar, viewer pane */
  .mc-body[data-mc-tab="viewer"] .mc-workspace { display: flex; }
  .mc-body[data-mc-tab="viewer"] .mc-toolbar   { display: flex; }
  .mc-body[data-mc-tab="viewer"] .mc-viewer-pane { display: flex; }

  /* Flatten split on mobile */
  .mc-split { grid-template-columns: 1fr; gap: 0; }

  /* Remove max-height constraints — let pages scroll naturally */
  .mc-project-list,
  .mc-viewer-body {
    max-height: none;
    overflow-y: visible;
  }

  /* Toolbar: stack on mobile */
  .mc-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }
  .mc-toolbar-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  /* Viewer actions: wrap nicely */
  .mc-viewer-head {
    flex-direction: column;
    gap: 0.75rem;
  }
  .mc-viewer-actions {
    justify-content: flex-start;
    width: 100%;
  }
  .mc-viewer-actions .primary-button,
  .mc-viewer-actions .ghost-button {
    flex: 1 1 calc(50% - 0.25rem);
    justify-content: center;
  }

  /* Topbar: stack on mobile */
  .mc-topbar {
    flex-direction: column;
    gap: 0.85rem;
  }
  .mc-topbar-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .mc-topbar-actions > * { flex: 1 1 auto; justify-content: center; }
}

/* ══════════════════════════════════════
   RESPONSIVE — 640px  (small phone)
══════════════════════════════════════ */
@media (max-width: 640px) {
  .mc-topbar-title { font-size: 1.3rem; }
  .mc-topbar-sub { font-size: 0.84rem; }
  .mc-topbar { padding: 1rem; }
  .mc-card { padding: 0.95rem 1rem; }
  .mc-stats-row { grid-template-columns: repeat(2, 1fr); gap: 0.55rem; }
  .mc-stat-card strong { font-size: 1.5rem; }
  .mc-stat-card { padding: 0.85rem 0.9rem; }

  .mc-viewer-actions .primary-button,
  .mc-viewer-actions .ghost-button {
    flex: 1 1 100%;
  }

  .mc-tabs { gap: 2px; padding: 3px; }
  .mc-tab { font-size: 0.8rem; padding: 0.5rem 0.4rem; }
  .mc-tab svg { display: none; }
}

@media (max-width: 400px) {
  .mc-shell { padding-left: calc(0.55rem + var(--safe-left)); padding-right: calc(0.55rem + var(--safe-right)); }
  .mc-stats-row { grid-template-columns: 1fr 1fr; gap: 0.45rem; }
}

/* ── Touch improvements ── */
button, a {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.ghost-button, .primary-button, .mc-tab {
  min-height: 44px;
}
.small-button { min-height: 38px; }

/* Momentum scroll */
.mc-project-list,
.mc-viewer-body,
.mc-shell {
  -webkit-overflow-scrolling: touch;
}
