/**
 * 🌞 Sunday App Framework — Console Shell (shared layout)
 *
 * Problem this solves:
 * - New consoles often include tokens/base/utilities, but miss the *shell* styles
 *   (header, tabs, content layout, basic buttons). That makes every new console
 *   look “messed up” until someone copies CSS from another console.
 *
 * Contract:
 * - Include this in every console `index.html` (bundled + hosted):
 *     /css/console-shell.css
 * - Then consoles can provide only minimal branding overrides.
 */

:root {
  /* Consoles can override these in their own CSS */
  --console-brand: var(--sunday-brand, #8b5cf6);
  --console-accent: var(--sunday-accent, #7ce3ff);
  --console-brand-glow: color-mix(in srgb, var(--console-brand) 35%, transparent);
}

/* Shell layout */
.console-root {
  /* Ensure the console uses an internal scroll container (not <body>) so
     sticky sidebars work reliably. */
  height: 100vh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sunday-bg, #0b0c10);
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--sunday-surface, #0f131c);
  border-bottom: 1px solid var(--sunday-line, #1e2636);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  font-size: 28px;
  filter: drop-shadow(0 0 10px var(--console-brand-glow));
}

.app-title {
  font-size: 18px;
  font-weight: 800;
  margin: 0;
}

.app-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--sunday-text-muted, #9bb1c7);
}

/* Tabs */
.tabs-container {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 24px;
  background: var(--sunday-surface, #0f131c);
  border-bottom: 1px solid var(--sunday-line, #1e2636);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tabs-container::-webkit-scrollbar {
  display: none;
}

.tabs {
  display: flex;
  gap: 4px;
  width: 100%;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--sunday-text-muted, #9bb1c7);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--sunday-text, #e9f3ff);
  background: color-mix(in srgb, var(--sunday-card, #141820) 70%, transparent);
}

.tab-btn.active {
  color: var(--console-brand);
  border-bottom-color: var(--console-brand);
}

.tab-icon {
  font-size: 16px;
}

.tab-btn.active .tab-icon {
  filter: drop-shadow(0 0 8px var(--console-brand-glow));
}

/* Content */
.content-container {
  flex: 1;
  overflow-y: auto;
  background: var(--sunday-bg, #0b0c10);
}

/* Basic buttons (shared) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--sunday-radius-md, 10px);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  transition: 0.15s ease;
  user-select: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 13px;
}

.btn-secondary {
  background: var(--sunday-card, #141820);
  color: var(--sunday-text, #e9f3ff);
  border-color: var(--sunday-line, #1e2636);
}

.btn-secondary:hover {
  background: var(--sunday-surface, #0f131c);
  border-color: var(--console-brand);
}

/* Markdown rendering (shared) */
.sunday-markdown {
  color: var(--sunday-text, #e9f3ff);
  line-height: 1.65;
  max-width: 980px;
}

.sunday-markdown img {
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--sunday-line, #1e2636);
  margin: 10px 0;
}

.sunday-markdown hr {
  border: none;
  border-top: 1px solid var(--sunday-line, #1e2636);
  margin: 16px 0;
}

.sunday-markdown blockquote {
  margin: 12px 0;
  padding: 10px 12px;
  border-left: 3px solid var(--console-brand, var(--sunday-brand, #8b5cf6));
  background: color-mix(in srgb, var(--sunday-card, #141820) 70%, transparent);
  border-radius: 10px;
  color: color-mix(in srgb, var(--sunday-text, #e9f3ff) 92%, var(--sunday-text-muted, #9bb1c7));
}

.sunday-md-anchor {
  display: inline-block;
  margin-right: 8px;
  opacity: 0.35;
  text-decoration: none;
  color: var(--sunday-text-muted, #9bb1c7);
}

.sunday-markdown h1:hover .sunday-md-anchor,
.sunday-markdown h2:hover .sunday-md-anchor,
.sunday-markdown h3:hover .sunday-md-anchor,
.sunday-markdown h4:hover .sunday-md-anchor,
.sunday-markdown h5:hover .sunday-md-anchor,
.sunday-markdown h6:hover .sunday-md-anchor {
  opacity: 1;
}

/* TOC */
.sunday-md-toc {
  margin: 10px 0 16px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--sunday-line, #1e2636);
  background: color-mix(in srgb, var(--sunday-card, #141820) 65%, transparent);
}

/* Split docs layout: pinned TOC + scrollable body */
.sunday-md-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

@media (max-width: 980px) {
  .sunday-md-layout {
    grid-template-columns: 1fr;
  }
}

.sunday-md-aside {
  position: sticky;
  top: 12px;
  align-self: start;
  height: fit-content;
  max-height: calc(100vh - 24px);
  overflow: auto;
}

.sunday-md-body {
  min-width: 0;
}

.sunday-md-toc-title {
  font-weight: 900;
  margin-bottom: 8px;
}

.sunday-md-toc ul {
  margin: 0 0 0 18px;
}

.sunday-md-toc li {
  margin: 6px 0;
}

.sunday-md-toc .lvl-3,
.sunday-md-toc .lvl-4,
.sunday-md-toc .lvl-5,
.sunday-md-toc .lvl-6 {
  margin-left: 10px;
}

/* Task lists */
.sunday-md-task {
  list-style: none;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.sunday-md-task input[type="checkbox"] {
  margin-top: 4px;
  accent-color: var(--console-brand, var(--sunday-brand, #8b5cf6));
}

.sunday-markdown h1,
.sunday-markdown h2,
.sunday-markdown h3,
.sunday-markdown h4,
.sunday-markdown h5,
.sunday-markdown h6 {
  margin: 18px 0 10px;
}

.sunday-markdown p {
  margin: 10px 0;
  color: color-mix(in srgb, var(--sunday-text, #e9f3ff) 92%, var(--sunday-text-muted, #9bb1c7));
}

.sunday-markdown ul,
.sunday-markdown ol {
  margin: 10px 0 10px 22px;
}

.sunday-markdown li {
  margin: 6px 0;
}

.sunday-markdown a {
  color: var(--console-accent, var(--sunday-accent, #7ce3ff));
  text-decoration: none;
}

.sunday-markdown a:hover {
  text-decoration: underline;
}

.sunday-markdown code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  background: color-mix(in srgb, var(--sunday-card, #141820) 65%, transparent);
  border: 1px solid var(--sunday-line, #1e2636);
  padding: 2px 6px;
  border-radius: 8px;
}

.sunday-md-code {
  margin: 12px 0;
  padding: 12px;
  border-radius: 12px;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--sunday-line, #1e2636);
  overflow: auto;
}

.sunday-md-code code {
  border: none;
  background: transparent;
  padding: 0;
  display: block;
  white-space: pre;
}

/* Tables */
.sunday-md-table-wrap {
  width: 100%;
  overflow: auto;
  margin: 12px 0;
  border-radius: 12px;
  border: 1px solid var(--sunday-line, #1e2636);
  background: color-mix(in srgb, var(--sunday-card, #141820) 55%, transparent);
}

.sunday-md-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

.sunday-md-table th,
.sunday-md-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--sunday-line, #1e2636);
  vertical-align: top;
}

.sunday-md-table th {
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--sunday-surface, #0f131c) 82%, transparent);
  color: var(--sunday-text, #e9f3ff);
  font-weight: 800;
  z-index: 1;
}

.sunday-md-table tr:last-child td {
  border-bottom: none;
}

/* ─────────────────────────────────────────────────────────────────────────────
 * Auth Route Styles
 * Hide navigation chrome (header, tabs, FAB) on login/register/auth pages
 * ───────────────────────────────────────────────────────────────────────────── */

/* Body class-based hiding (applied by router) */
body.sunday-auth-route #appHeader,
body.sunday-auth-route .app-header,
body.sunday-auth-route .console-header,
body.sunday-auth-route .global-header,
body.sunday-auth-route #global-header-container,
body.sunday-auth-route .tabs-container,
body.sunday-auth-route #mainTabs,
body.sunday-auth-route .sunday-fab,
body.sunday-auth-route .fab-button,
body.sunday-auth-route .fab-container,
body.sunday-auth-route [class*="fab"],
body.sunday-auth-route .quick-actions-modal,
html.is-auth-page #appHeader,
html.is-auth-page .app-header,
html.is-auth-page .console-header,
html.is-auth-page .global-header,
html.is-auth-page #global-header-container,
html.is-auth-page .tabs-container,
html.is-auth-page #mainTabs,
html.is-auth-page .sunday-fab,
html.is-auth-page .fab-button,
html.is-auth-page .fab-container,
html.is-auth-page [class*="fab"],
html.is-auth-page .quick-actions-modal {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Adjust content container when auth page (no header offset needed) */
body.sunday-auth-route #contentContainer,
html.is-auth-page #contentContainer {
  padding-top: 0 !important;
  margin-top: 0 !important;
}

