/* ==========================================================================
   AuraBily — Core Shell Components (Layer 06)
   App Header, Desktop Sidebar Rail, 4-Destination Mobile Bottom Nav,
   Contextual Bottom Dock, Queue/Logs Drawer & Settings Modal.
   Zero !important, zero #id selectors.
   ========================================================================== */

/* ── Top App Bar (Clean, Restrained, Non-Cluttered) ──────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  height: var(--header-height);
  padding: 0 var(--space-3);
  background: var(--surface-primary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.sidebar-collapse-btn {
  display: none;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-border);
  background: var(--surface-base);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-subtitle {
  display: none;
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-context-badge {
  display: none;
  font-size: var(--text-xs);
  font-family: var(--font-display);
  color: var(--text-secondary);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.cmd-trigger-btn {
  display: none;
  align-items: center;
  gap: var(--space-2);
  min-height: 36px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  transition: border-color var(--motion-fast) var(--ease-standard), color var(--motion-fast) var(--ease-standard);
}

.cmd-trigger-btn:hover {
  border-color: var(--accent-border);
  color: var(--accent);
}

.gpu-queue-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--ctrl-h-md);
  max-width: 165px;
  overflow: hidden;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--motion-fast) var(--ease-standard), background-color var(--motion-fast) var(--ease-standard);
}

.gpu-queue-btn span:not(.status-dot):not(.header-queue-badge) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-tabs-bar {
  display: none;
}

.gpu-queue-btn:hover {
  border-color: var(--accent-border);
  color: var(--text-primary);
}

.header-queue-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--text-inverse);
  font-size: 0.68rem;
  font-weight: 700;
}

/* ── Desktop Collapsible Navigation Sidebar ──────────────────────────────── */
.main-mode-switcher {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidebar-section-title {
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--space-2) var(--space-3) var(--space-1);
}

.mode-switch-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: var(--touch-min);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 500;
  border: 1px solid transparent;
  transition:
    transform var(--motion-fast) var(--ease-standard),
    background-color var(--motion-fast) var(--ease-standard),
    color var(--motion-fast) var(--ease-standard),
    border-color var(--motion-fast) var(--ease-standard);
}

.mode-switch-btn:hover {
  background: var(--surface-elevated);
  color: var(--text-primary);
}

.mode-switch-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
  font-weight: 600;
}

.mode-switch-btn .mode-icon {
  font-size: 1.1rem;
  width: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

.sidebar-footer-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

/* ── Mobile Bottom Navigation (4 Destinations, Safe-Area, 48px+ Targets) ── */
.mobile-nav {
  position: fixed;
  left: var(--space-3);
  right: var(--space-3);
  bottom: calc(var(--space-2) + var(--safe-bottom));
  z-index: var(--z-nav);
  height: 60px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  padding: var(--space-1);
  border-radius: var(--radius-pill);
  background: var(--surface-primary);
  border: 1px solid var(--accent-border);
  box-shadow: var(--shadow-md);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 500;
  transition:
    transform var(--motion-fast) var(--ease-standard),
    background-color var(--motion-fast) var(--ease-standard),
    color var(--motion-fast) var(--ease-standard);
}

.nav-item svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
}

.nav-item:active {
  transform: scale(0.95);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

/* ── Studio Cards ────────────────────────────────────────────────────────── */
.studio-card {
  background: var(--surface-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}

/* ── Contextual Bottom Sticky Action Dock (Always Accessible Launch CTA) ─── */
.studio-sticky-cta-dock {
  position: sticky;
  bottom: 0;
  z-index: var(--z-sticky-cta);
  margin-top: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface-primary) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--accent-border);
  box-shadow: var(--shadow-md);
}

.progress-card {
  display: none;
  margin-top: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  border: 1px solid var(--accent-border);
}

.progress-card.active,
.progress-card.visible {
  display: block;
}

.progress-header,
.progress-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.progress-track {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-base);
  overflow: hidden;
  margin: var(--space-2) 0;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-gradient);
  border-radius: var(--radius-pill);
  transition: width 220ms var(--ease-standard);
}

/* ── Theme Switcher & Lang Picker (Inside Settings / Sidebar) ────────────── */
.theme-switch-wrapper {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
}

.theme-switch-icon {
  display: inline-flex;
  color: var(--text-muted);
}

.theme-switch-icon.active {
  color: var(--accent);
}

.theme-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.theme-switch-slider {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-base);
  border: 1px solid var(--border-structural);
  transition: background-color var(--motion-fast) var(--ease-standard);
}

.theme-switch-slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform var(--motion-fast) var(--ease-standard);
}

.theme-switch input:checked + .theme-switch-slider::before {
  transform: translateX(16px);
}

/* ── Settings Modal & Telemetry Drawer ───────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 8, 8, 0.78);
  padding: 0;
}

.modal-backdrop.open {
  display: flex;
}

.settings-modal-content {
  position: relative;
  width: min(520px, 100%);
  max-height: 90dvh;
  margin: var(--space-3);
  overflow-y: auto;
  background: var(--surface-primary);
  border: 1px solid var(--border-structural);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-modal);
}

.settings-inner-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.settings-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-1);
}

.settings-subtitle,
.settings-help-text {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.settings-inline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.meta-row:last-child {
  border-bottom: none;
}

.settings-val-highlight {
  color: var(--accent);
  font-weight: 600;
}

.lightbox-close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  z-index: 40;
  width: var(--ctrl-h-md);
  height: var(--ctrl-h-md);
  min-width: var(--ctrl-h-md);
  min-height: var(--ctrl-h-md);
  border-radius: 50%;
  background: var(--surface-overlay);
  border: 1px solid var(--border-structural);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: border-color var(--motion-fast) var(--ease-standard), color var(--motion-fast) var(--ease-standard);
}

.lightbox-close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Queue & Logs Telemetry Drawer */
.telemetry-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-backdrop);
  background: rgba(8, 8, 8, 0.65);
  display: none;
}

.telemetry-backdrop.open,
.telemetry-backdrop.active {
  display: block;
}

.telemetry-drawer {
  position: fixed;
  left: var(--space-2);
  right: var(--space-2);
  bottom: calc(var(--mobile-nav-height) + var(--safe-bottom) + var(--space-2));
  z-index: var(--z-drawer);
  max-height: 70dvh;
  background: var(--surface-primary);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.telemetry-drawer.open {
  display: flex;
}

.telemetry-drawer-tabs {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2);
  background: var(--surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.telemetry-tab-btn {
  flex: 1;
  min-width: 0;
  min-height: var(--ctrl-h-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
}

.telemetry-tab-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.telemetry-close-btn {
  min-width: var(--ctrl-h-md);
  min-height: var(--ctrl-h-md);
  flex-shrink: 0;
}

.telemetry-drawer-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.telemetry-drawer .queue-panel,
.telemetry-drawer .console-logviewer {
  position: static;
  inset: auto;
  width: 100%;
  max-width: none;
  height: auto;
  max-height: none;
  flex: 1;
  min-height: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  animation: none;
  z-index: auto;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.telemetry-drawer .queue-panel.tab-active,
.telemetry-drawer .console-logviewer.tab-active {
  display: flex;
}

.queue-header,
.logviewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
}

.logviewer-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.logviewer-actions .btn-micro {
  min-height: var(--ctrl-h-md);
  min-width: var(--ctrl-h-md);
}

.queue-body,
.logviewer-body {
  padding: var(--space-3) var(--space-4);
  overflow-y: auto;
  flex: 1;
}

.log-entry {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  word-break: break-word;
}

.log-entry.warn {
  color: var(--warning);
}

.log-entry.error {
  color: var(--danger);
}
