/* ASCF Admin Mega Console — enterprise glass + modular rail */
/* Design tokens inherited from design-tokens.css */

body.app-ready {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-deep);
}

.glass-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.glass-bg::before,
.glass-bg::after {
  content: '';
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
}
.glass-bg::before {
  background: var(--accent);
  top: -80px;
  left: -60px;
}
.glass-bg::after {
  background: var(--ntt-turquoise, #00dfed);
  bottom: -100px;
  right: -40px;
}

#app.app-mega {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  height: 100vh;
  min-height: 0;
}

/* ── Rail (sidebar modular) ── */
.app-mega .sidebar {
  width: 220px;
  background: rgba(13, 17, 26, 0.92);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-color);
}
.app-mega .sidebar-header {
  padding: 0.8rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
}
.app-mega .sidebar-header--ntt .ntt-brand-logo--rail {
  max-width: 100%;
}
.app-mega .sidebar-header h1 {
  font-size: 1rem;
  background: linear-gradient(90deg, #fff 30%, #8b92a0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.app-mega .nav-item {
  margin: 2px 0.4rem;
  border-radius: 9px;
  border: 1px solid transparent;
}
.app-mega .nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-color);
}
.app-mega .nav-item.active {
  background: rgba(0, 188, 212, 0.12);
  border-color: rgba(0, 188, 212, 0.35);
  color: var(--accent);
}
.app-mega .nav-item-primary {
  font-weight: 600;
  border-color: rgba(0, 188, 212, 0.2);
}
.app-mega .nav-collapse summary {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
}

/* ── Main chrome ── */
.app-mega .main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.app-mega .main-header {
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  background: rgba(13, 17, 26, 0.75);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  height: auto;
  min-height: var(--header-h);
}
.app-mega .main-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  min-width: 140px;
}
.app-mega .header-module-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  flex: 1;
  min-width: 120px;
}

.server-status-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.server-status-bar .status-indicator {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.78rem;
}
.server-status-bar .pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}
.server-status-bar .pulse-dot.online {
  background: var(--green);
  box-shadow: 0 0 8px rgba(46, 204, 113, 0.5);
  animation: mega-pulse 1.5s ease-in-out infinite alternate;
}
.server-status-bar .pulse-dot.offline {
  background: var(--red);
}
@keyframes mega-pulse {
  from { opacity: 0.65; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1.05); }
}

.app-mega .main-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.9rem 1rem 1.15rem;
}

/* ── Compact density pass ── */
.app-mega .main-content {
  padding: 0.85rem 0.95rem 1rem;
}
.app-mega .card {
  padding: 0.75rem;
  border-radius: 12px;
}
.app-mega .card-header {
  margin-bottom: 0.5rem;
  padding-bottom: 0.35rem;
}
.app-mega .card-title {
  font-size: 0.78rem;
}
.app-mega .badge {
  padding: 0.1rem 0.34rem;
  font-size: 0.52rem;
}
.app-mega .grid-2,
.app-mega .grid-3,
.app-mega .grid-4 {
  gap: 0.6rem;
}
.app-mega .flex {
  gap: 0.6rem;
}
.app-mega .gap-sm {
  gap: 0.28rem;
}
.app-mega .gap-lg {
  gap: 0.8rem;
}
.app-mega .mt-1 {
  margin-top: 0.55rem;
}
.app-mega .mb-1 {
  margin-bottom: 0.55rem;
}
.app-mega .dashboard-grid {
  gap: 0.6rem;
  min-height: min(56vh, 500px);
}
.app-mega .dashboard-card {
  padding: 0.75rem;
  border-radius: 12px;
}
.app-mega .dashboard-card .card-title {
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.32rem;
}
.app-mega .metrics-grid {
  gap: 0.32rem;
  margin-bottom: 0.45rem;
}
.app-mega .metric-pill {
  padding: 0.32rem 0.38rem;
  border-radius: 8px;
}
.app-mega .metric-pill .metric-value {
  font-size: 0.9rem;
}
.app-mega .chart-container {
  min-height: 140px;
}
.app-mega .logs-container {
  min-height: 120px;
  max-height: 240px;
  padding: 0.35rem;
}
.app-mega .btn {
  padding: 0.3rem 0.68rem;
  font-size: 0.7rem;
}
.app-mega .btn-sm {
  padding: 0.24rem 0.55rem;
  font-size: 0.66rem;
}
.app-mega .btn-mini {
  padding: 0.12rem 0.34rem;
  font-size: 0.6rem;
}
.app-mega .vehicle-grid {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.6rem;
}
.app-mega .client-selector-grid {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.6rem;
}
.app-mega .client-selector-card,
.app-mega .vehicle-card,
.app-mega .detail-panel,
.app-mega .ux-flow-card {
  padding: 0.8rem;
  border-radius: 12px;
}
.app-mega .ux-flow-cards {
  gap: 0.75rem;
}
.app-mega .ux-hub-hero {
  padding: 1rem 0.6rem;
}
.app-mega .ux-hub-title {
  font-size: 1.45rem;
}
.app-mega .ux-hub-subtitle {
  font-size: 0.85rem;
  margin-bottom: 1.35rem;
}
.app-mega .wizard-shell {
  max-width: 760px;
}
.app-mega #panel-wizard-chat.active {
  min-height: calc(100vh - var(--header-h) - 2.25rem);
}
.app-mega #panel-launcher .card {
  max-width: 560px;
}

/* Panels */
.app-mega .panel {
  display: none;
  animation: mega-fade 0.2s ease;
}
.app-mega .panel.active {
  display: block;
}
.app-mega .panel.active.panel-layout-grid,
.app-mega #panel-telemetry.panel.active {
  display: grid;
}
@keyframes mega-fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Telemetry — 3-column enterprise grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr minmax(280px, 380px);
  gap: 1.25rem;
  min-height: min(70vh, 640px);
}
.dashboard-card {
  background: var(--card-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-shadow: var(--card-glow);
}
.dashboard-card .card-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}
.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.metric-pill {
  text-align: center;
  padding: 0.5rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
}
.metric-pill .metric-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.metric-pill .metric-value {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.chart-container {
  flex: 1;
  min-height: 200px;
  position: relative;
}
.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}
.logs-container {
  flex: 1;
  min-height: 180px;
  max-height: 420px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  padding: 0.5rem;
}
.log-entry,
.console-line {
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
}
.log-entry.system,
.console-line.system { color: var(--text-secondary); }
.log-entry.mcp_allowed,
.console-line.mcp_allowed { color: var(--green); }
.log-entry.mcp_blocked,
.console-line.mcp_blocked { color: var(--red); }
.log-entry.mcp_call,
.console-line.mcp_call { color: var(--accent); }
.btn-mini {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.btn-mini:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Wizard module */
.app-mega .wizard-shell {
  max-width: 920px;
  margin: 0 auto;
}
.app-mega .wizard-hero {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}
.app-mega .steps {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  padding: 0.35rem;
  border: 1px solid var(--border-subtle);
}
.app-mega .chip {
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
}
.app-mega .chip.selected {
  box-shadow: 0 0 12px rgba(0, 188, 212, 0.15);
}

/* Assistant strip */
.assistant-quick-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.assistant-quick-bar .btn-assistant {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-smooth);
}
.assistant-quick-bar .btn-assistant:hover,
.assistant-quick-bar .btn-assistant.active {
  border-color: var(--accent);
  background: rgba(0, 188, 212, 0.12);
  color: var(--accent);
}
.assistant-quick-bar .btn-assistant-primary {
  background: rgba(0, 188, 212, 0.18);
  border-color: var(--accent);
}

/* Enterprise empty panels fill */
.enterprise-panel-host {
  min-height: 200px;
}
.enterprise-panel-host .card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
}

/* ═══════════════════════════════════════════════════════════
   F02 — Loading States (skeleton + spinner)
   ═══════════════════════════════════════════════════════════ */

@keyframes skeleton-pulse {
  0% { opacity: 0.4; }
  50% { opacity: 0.8; }
  100% { opacity: 0.4; }
}
@keyframes spinner-rotate {
  to { transform: rotate(360deg); }
}

.skeleton-loader {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.5rem 0;
}
.skeleton-line {
  height: 14px;
  border-radius: 6px;
  background: var(--border-medium);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.skeleton-line:nth-child(2) { width: 85%; }
.skeleton-line:nth-child(3) { width: 70%; }
.skeleton-line:nth-child(4) { width: 92%; }
.skeleton-line.skeleton-heading { height: 20px; width: 55%; margin-bottom: 0.3rem; }
.skeleton-line.skeleton-avatar { width: 40px; height: 40px; border-radius: 50%; }
.skeleton-line.skeleton-btn { width: 120px; height: 32px; border-radius: 8px; }

.spinner-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 2rem 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-medium);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spinner-rotate 0.6s linear infinite;
}

/* ═══════════════════════════════════════════════════════════
   F03 — Error Banner + Retry
   ═══════════════════════════════════════════════════════════ */

.error-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  background: rgba(231, 76, 60, 0.12);
  border: 1px solid rgba(231, 76, 60, 0.25);
  margin: 0.5rem 0;
  font-size: 0.82rem;
  line-height: 1.4;
}
.error-banner .error-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}
.error-banner .error-body {
  flex: 1;
  color: var(--text-primary);
}
.error-banner .error-detail {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-top: 0.2rem;
}
.error-banner .error-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
}
.error-banner .btn-retry {
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  border-radius: 6px;
  border: 1px solid var(--border-medium);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-smooth);
}
.error-banner .btn-retry:hover {
  border-color: var(--accent);
  background: rgba(0, 188, 212, 0.12);
}

/* WS reconnect indicator */
.ws-reconnect-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(243, 156, 18, 0.15);
  color: var(--amber);
  border: 1px solid rgba(243, 156, 18, 0.2);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════
   F01 — Onboarding Modal
   ═══════════════════════════════════════════════════════════ */

.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 10, 16, 0.85);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.onboarding-modal {
  max-width: 540px;
  width: min(540px, 90vw);
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem 1.75rem;
  animation: slideUp 0.35s ease;
  text-align: center;
}
.onboarding-modal h2 {
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  font-weight: 700;
  margin-bottom: 0.3rem;
}
.onboarding-modal .onboarding-lead {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}
.onboarding-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.onboarding-card {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  text-align: left;
  transition: var(--transition-smooth);
  font-family: inherit;
  font-size: inherit;
  color: var(--text-primary);
  width: 100%;
}
.onboarding-card:hover {
  border-color: var(--accent);
  background: rgba(0, 188, 212, 0.08);
  transform: translateX(4px);
}
.onboarding-card .oc-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(0, 188, 212, 0.1);
}
.onboarding-card .oc-text {
  flex: 1;
}
.onboarding-card .oc-title {
  font-weight: 600;
  font-size: 0.9rem;
}
.onboarding-card .oc-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.1rem;
}
.onboarding-skip {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  transition: var(--transition-smooth);
}
.onboarding-skip:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
}

#panel-wizard-chat.active {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--header-h) - 4rem);
}
#panel-wizard-chat .wizard-ent-container {
  flex: 1;
  min-height: 0;
  max-width: none;
  height: auto;
}

#panel-launcher .card {
  max-width: 720px;
}

/* ═══════════════════════════════════════════════════════════
   F04 — UX Flow Cards (Home Hub)
   ═══════════════════════════════════════════════════════════ */

.ux-hub-hero {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1rem;
}
.ux-hub-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  background: linear-gradient(90deg, #fff 20%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.ux-hub-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 2.5rem;
}
.ux-hub-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}

.ux-flow-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}
.ux-flow-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
}
.ux-flow-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: transparent;
  transition: var(--transition-smooth);
}
.ux-flow-card:hover {
  transform: translateY(-4px);
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}
.ux-flow-card:hover::before {
  background: var(--accent);
}

.ux-flow-card .ux-flow-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
}
.ux-flow-card .build-icon { background: rgba(0, 188, 212, 0.15); color: #00bcd4; }
.ux-flow-card .run-icon { background: rgba(46, 204, 113, 0.15); color: #2ecc71; }
.ux-flow-card .sim-icon { background: rgba(155, 89, 182, 0.15); color: #9b59b6; }
.ux-flow-card .mcp-icon { background: rgba(255, 255, 255, 0.1); color: #fff; border: 1px solid rgba(255, 255, 255, 0.2); }

.ux-flow-card.mcp-card:hover::before {
  background: #fff;
}

.ux-flow-content {
  flex: 1;
}
.ux-flow-content h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}
.ux-flow-content p {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-secondary);
}
.ux-flow-action {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: auto;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.ux-flow-card:hover .ux-flow-action {
  opacity: 1;
}
.mcp-card .ux-flow-action {
  color: #fff;
}

@media (max-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .app-mega .sidebar {
    width: 56px;
  }
  .app-mega .sidebar-header small,
  .app-mega .nav-item span:not(.nav-icon),
  .app-mega .nav-group-title,
  .app-mega .nav-collapse summary {
    display: none;
  }
  .app-mega .nav-collapse .nav-item {
    display: flex;
    justify-content: center;
  }
}
