/* ── Dashboard Primary Styles ── */
:root {
  --bg: var(--ds-bg);
  --surface: var(--ds-surface-0);
  --surface-2: var(--ds-surface-1);
  --border: var(--ds-border);
  --border-hover: var(--ds-border-hover);
  --text: var(--ds-text);
  --text-muted: var(--ds-text-muted);
  --text-dim: var(--ds-text-dim);
  --accent: var(--ds-accent);
  --accent-glow: var(--ds-accent-bg);
  --success: var(--ds-success);
  --warning: var(--ds-warning);
  --danger: var(--ds-danger);
  --sidebar-w: 220px;
  --header-h: 52px;
  --font: var(--ds-font-sans);
  --mono: var(--ds-font-mono);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  background-image: radial-gradient(ellipse at top right, rgba(88,166,255,0.08) 0%, transparent 60%), radial-gradient(ellipse at bottom left, rgba(88,166,255,0.03) 0%, transparent 50%);
  color: var(--text);
  font-family: var(--font);
  height: 100vh;
  overflow: hidden;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

/* ── Holographic Login Gate (Phase 20) ─────────────────────────────────── */
#login-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: radial-gradient(circle at 50% 50%, rgba(88,166,255,0.08) 0%, var(--bg) 70%);
  position: relative;
  z-index: 1000;
  overflow: hidden;
}

#login-gate::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 800px; height: 800px;
  background: radial-gradient(circle, rgba(63,185,80,0.03) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.login-card {
  background: rgba(13, 17, 23, 0.65);
  box-shadow: 0 32px 64px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.1);
  backdrop-filter: blur(32px) saturate(150%);
  -webkit-backdrop-filter: blur(32px) saturate(150%);
  border: 1px solid rgba(255,255,255,0.08); /* ds-glass-border equivalent */
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 380px;
  position: relative;
  z-index: 2;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.login-brand h1 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--accent);
  text-transform: uppercase;
}

.login-brand p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  letter-spacing: 0.5px;
}

.login-field {
  margin-bottom: 1rem;
}

.login-field label {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.login-field input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.login-field input:focus {
  border-color: var(--accent);
}

.login-field input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.login-field input[aria-invalid="true"] {
  border-color: var(--danger);
}

.login-btn {
  width: 100%;
  padding: 0.7rem;
  margin-top: 0.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.login-btn:hover { opacity: 0.9; }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.login-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.login-btn .ds-spinner-inline {
  margin-right: 6px;
}

#login-error {
  color: var(--danger);
  font-size: 0.8rem;
  text-align: center;
  margin-top: 0.8rem;
  min-height: 1.2em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#login-error:empty {
  display: none;
}

/* 2A: Login gate fade-out / shell reveal */
#login-gate.fade-out {
  animation: loginFadeOut 300ms ease-out forwards;
}

@keyframes loginFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

#shell.reveal {
  animation: ds-fade-in 300ms ease-out both;
}

/* ── Shell Layout ───────────────────────────────── */
#shell {
  display: none;
  height: 100vh;
  width: 100vw;
}

/* ── Sidebar ────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.sidebar-brand {
  padding: 1.2rem 1.2rem 0.8rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand h2 {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--accent);
  text-transform: uppercase;
}

.sidebar-brand span {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-family: var(--mono);
}

.sidebar-nav {
  flex: 1;
  padding: 0.6rem 0;
  overflow-y: auto;
}

.nav-section {
  padding: 0.6rem 1rem 0.3rem;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 1.2rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 450;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  border-left: 2px solid transparent;
}

.nav-item:hover {
  color: var(--text);
  background: linear-gradient(90deg, var(--accent-glow) 0%, transparent 100%);
  border-left-color: rgba(88, 166, 255, 0.5);
  transform: translateX(4px);
}

.nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: linear-gradient(90deg, rgba(88, 166, 255, 0.15) 0%, transparent 100%);
  font-weight: 550;
  box-shadow: -4px 0 12px var(--accent-glow);
}

.nav-icon {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  flex-shrink: 0;
}

.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 1rem 1.2rem;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-meta {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.78rem;
  font-weight: 550;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  font-size: 0.7rem;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ── Main Content Area ──────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: transparent;
}

.topbar {
  height: var(--header-h);
  min-height: var(--header-h);
  border-bottom: 1px solid var(--ds-glass-border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 0.5rem;
  background: var(--ds-glass-bg);
  backdrop-filter: var(--ds-depth-blur);
  -webkit-backdrop-filter: var(--ds-depth-blur);
}

.breadcrumb {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.breadcrumb .sep { color: var(--text-dim); }

.breadcrumb .current {
  color: var(--text);
  font-weight: 550;
}

.status-pill {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  font-family: var(--mono);
  color: var(--text-muted);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.status-dot.offline { background: var(--danger); }

.content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ── Section Pages ──────────────────────────────── */
.section-page {
  display: none;
  width: 100%;
  height: 100%;
}

.section-page.active {
  display: block;
  animation: ds-fade-in 200ms ease-out;
}

.section-page iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: var(--bg);
}

/* ── Overview Page ──────────────────────────────── */
.overview {
  padding: 1.5rem;
  overflow-y: auto;
  height: 100%;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.2rem;
  transition: border-color 0.2s;
}

.stat-card:hover { border-color: var(--border-hover); }

.stat-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--text);
}

.stat-value.ok { color: var(--success); }
.stat-value.warn { color: var(--warning); }
.stat-value.err { color: var(--danger); }

.stat-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 0.3rem;
  font-family: var(--mono);
}

.section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin-bottom: 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.8rem;
}

.quick-link {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.2rem;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  color: var(--text);
}

.quick-link:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.quick-link h3 {
  font-size: 0.85rem;
  font-weight: 550;
  margin-bottom: 0.3rem;
}

.quick-link p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ── 2C: Stat card micro-animation ─────────────── */
.stat-value.ds-updated {
  animation: ds-scale-in 300ms ease-out;
}

/* ── Console Panels (Chat section) ──────────────── */
.chat-tab-btn.active {
  background: var(--accent-glow) !important;
  color: var(--accent) !important;
  border-color: var(--accent) !important;
}

.console-panel-ds {
  min-height: 200px;
}

.console-panel-ds iframe {
  width: 100%;
  height: calc(100vh - 180px);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.console-card {
  background: var(--surface-2);
  padding: 14px;
  margin: 8px 0;
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}

.console-card-warn { border-left-color: var(--warning); }
.console-card-danger { border-left-color: var(--danger); }
.console-card-success { border-left-color: var(--success); }
.console-card-info { border-left-color: #08f; }

.console-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.console-card-title {
  font-weight: 600;
  font-size: 0.85rem;
}

.console-card-meta {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.console-card-body {
  color: var(--text);
  font-size: 0.82rem;
  margin: 6px 0;
}

.console-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.console-empty {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.console-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 56px; }
  .sidebar-brand h2 { display: none; }
  .sidebar-brand span { display: none; }
  .nav-section { display: none; }
  .nav-item span { display: none; }
  .nav-item { justify-content: center; padding: 0.7rem; }
  .user-meta { display: none; }
  .btn-logout { display: none; }
  .sidebar-brand { padding: 1rem 0.8rem; }
  .overview-grid { grid-template-columns: repeat(2, 1fr); }
  #job-drawer { width: 100vw !important; }
}

@media (max-width: 480px) {
  .overview-grid { grid-template-columns: 1fr; }
  .quick-links { grid-template-columns: 1fr; }
  .overview { padding: 1rem; }
  .topbar { padding: 0 0.75rem; }
  .login-card { width: 95vw; padding: 1.5rem 1.2rem; }
}

@media (max-width: 320px) {
  .overview { padding: 0.75rem; }
  body { font-size: 12px; }
  .stat-value { font-size: 1.3rem; }
  .login-card { padding: 1.2rem 1rem; }
  .topbar { padding: 0 0.5rem; gap: 0.3rem; }
  .breadcrumb { font-size: 0.7rem; }
}

/* ── Reviews+CTRL filter buttons ────────────────── */
.review-filter-group {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}
.review-filter-group .filter-btn {
  padding: 3px 10px;
  font-size: 0.72rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.review-filter-group .filter-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.review-filter-group .filter-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── System Monitor health gauge ────────────────── */
.health-gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.2rem 0;
}
.health-gauge .gauge-score {
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--success);
  line-height: 1;
}
.health-gauge .gauge-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.health-gauge.score-warn .gauge-score { color: var(--warning); }
.health-gauge.score-danger .gauge-score { color: var(--danger); }
.agent-health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.agent-health-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}
.agent-health-card .agent-name {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text);
}
.agent-health-card .agent-status {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Notification Overlay — Twitch style ────────── */
.notification-overlay {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.5rem;
  max-height: 50vh;
  overflow: hidden;
  pointer-events: none;
}
.notification-toast {
  pointer-events: auto;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: rgba(30, 30, 40, 0.92);
  backdrop-filter: blur(8px);
  border-left: 3px solid #666;
  color: #e0e0e0;
  font-size: 0.85rem;
  max-width: 360px;
  animation: slideInRight 0.3s ease-out;
  cursor: pointer;
  transition: opacity 0.3s, transform 0.3s;
}
.notification-toast.fade-out {
  opacity: 0;
  transform: translateX(100%);
}
.notification-toast.severity-loud { border-left-color: #ef4444; }
.notification-toast.event-DONE { border-left-color: #22c55e; }
.notification-toast.event-STARTED { border-left-color: #3b82f6; }
.notification-toast.event-FAILED { border-left-color: #ef4444; }
.notification-toast .toast-agent { font-weight: 600; color: #60a5fa; }
.notification-toast .toast-text { opacity: 0.85; margin-top: 2px; }
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.notif-bell {
  position: relative;
  cursor: pointer;
  font-size: 1.2rem;
}
.notif-bell .badge {
  position: absolute;
  top: -5px;
  right: -8px;
  background: #ef4444;
  color: white;
  font-size: 0.65rem;
  border-radius: 999px;
  padding: 1px 5px;
  min-width: 16px;
  text-align: center;
}
