/* =========================================================
   CT Dashboards — Shell Layout
   Sidebar, topbar, main content area, view transitions.
   Operator Stellar — pixel discipline, tight grid.
   All colors come from theme-tokens.css / palettes.css.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500&family=Playfair+Display:ital,wght@0,600;0,700;1,600&display=swap');

/* Suppress all transitions during theme swap so nothing "plays catch-up" when the fade reveals the new theme */
[data-theme-switching] * { transition: none !important; }

/* ─── Body-level reset (in addition to theme-tokens.css) ─── */
html, body { height: 100%; overflow: hidden; }
body { display: flex; }

/* ─── Icon utility ─── */
.icon {
  width: 15px; height: 15px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.icon-sm { width: 13px; height: 13px; }
.icon-lg { width: 18px; height: 18px; stroke-width: 1.2; }

/* =========================================================
   SIDEBAR
   ========================================================= */
.ct-sidebar {
  width: 220px;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 10px 8px 12px;
  transition: background .3s, border-color .3s, width .25s ease;
  z-index: 100;
}
.ct-sidebar.collapsed { width: 56px; }
.ct-sidebar.collapsed .ct-brand-text,
.ct-sidebar.collapsed .ct-cmdk-trigger span:not(.kbd),
.ct-sidebar.collapsed .ct-nav-item span,
.ct-sidebar.collapsed .ct-nav-label,
.ct-sidebar.collapsed .ct-avatar-text,
.ct-sidebar.collapsed .ct-nav-badge { display: none; }
.ct-sidebar.collapsed .ct-cmdk-trigger .kbd { display: none; }
.ct-sidebar.collapsed .ct-nav-item { justify-content: center; padding: 8px; }

/* Brand */
.ct-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.ct-brand-mark {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--a);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 3px 14px var(--a-shadow);
  position: relative;
  flex-shrink: 0;
}
.ct-brand-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 7px;
  background: linear-gradient(135deg, rgba(255,255,255,0.35), transparent 50%);
  pointer-events: none;
}
.ct-brand-text h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.ct-brand-text p {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 1px;
  letter-spacing: 0;
}

/* CMDK trigger in the sidebar */
.ct-cmdk-trigger {
  margin: 6px 0 10px;
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all .12s;
  font-size: 12px;
  color: var(--text-3);
  font-family: inherit;
  width: 100%;
}
.ct-cmdk-trigger:hover {
  border-color: var(--border-2);
  color: var(--text-2);
}
.ct-cmdk-trigger .kbd {
  margin-left: auto;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-4);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

/* Navigation */
.ct-nav-section { margin-top: 12px; }
.ct-nav-section:first-of-type { margin-top: 2px; }
.ct-nav-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 10px 4px;
}

.ct-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all .12s;
  user-select: none;
  margin-bottom: 1px;
  position: relative;
  text-decoration: none;
}
.ct-nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.ct-nav-item.active {
  background: var(--a-soft);
  color: var(--a);
  font-weight: 600;
}
.ct-nav-item .icon { color: var(--text-3); width: 14px; height: 14px; }
.ct-nav-item.active .icon { color: var(--a); }
.ct-nav-item:hover .icon { color: var(--text-2); }
.ct-nav-item.disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.ct-nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--fg-red);
  color: var(--txt-red);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.ct-nav-badge.gold {
  background: var(--a-soft);
  color: var(--a);
}

/* Sidebar footer */
.ct-sidebar-footer {
  margin-top: auto;
  padding: 8px 8px 2px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ct-avatar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  min-width: 0;
}
.ct-avatar-img {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.ct-avatar-text {
  min-width: 0;
  overflow: hidden;
}
.ct-avatar-text strong {
  color: var(--text);
  font-weight: 600;
  display: block;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ct-avatar-text span {
  color: var(--text-3);
  font-size: 10px;
}

/* Theme switch */
.ct-theme-switch {
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
}
.ct-theme-switch::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-3);
  transition: transform .25s cubic-bezier(.16, 1, .3, 1), background .2s;
}
[data-theme="dark"] .ct-theme-switch::after {
  transform: translateX(14px);
  background: var(--a);
}

/* =========================================================
   MAIN AREA
   ========================================================= */
.ct-main {
  flex: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Topbar */
.ct-topbar {
  height: 46px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: 12px;
  transition: background-color 0.25s ease, border-color 0.25s ease;
  flex-shrink: 0;
  transition: background .3s, border-color .3s;
}
.ct-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
}
.ct-breadcrumb strong {
  color: var(--text);
  font-weight: 600;
}
.ct-breadcrumb .sep {
  color: var(--text-4);
  font-size: 10px;
}

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

/* Content scroll area */
.ct-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: var(--bg);
  transition: background-color 0.2s ease;
  position: relative;
}
.ct-content::-webkit-scrollbar { width: 10px; }
.ct-content::-webkit-scrollbar-track { background: transparent; }
.ct-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
  border: 2px solid var(--bg);
}
.ct-content iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* View transition */
.ct-view-enter {
  animation: ctViewIn .35s ease-out;
}
@keyframes ctViewIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Mobile ─── */
@media (max-width: 768px) {
  .ct-sidebar {
    position: fixed;
    left: -220px;
    z-index: 200;
    transition: left .3s ease;
  }
  .ct-sidebar.mobile-open { left: 0; }
  .ct-topbar { padding: 0 16px; }
}
