@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Surface colors */
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-tertiary: #1a2332;
  --bg-card: #1e293b;
  --bg-card-hover: #243044;
  --bg-sidebar: #111827;

  /* Border */
  --border: #1e293b;
  --border-subtle: #1a2332;
  --border-accent: #334155;

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-muted: #475569;

  /* Accent */
  --accent-blue: #3b82f6;
  --accent-blue-dim: #1e3a5f;
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;

  /* Priority */
  --priority-critical: #ef4444;
  --priority-critical-bg: rgba(239, 68, 68, 0.12);
  --priority-high: #f97316;
  --priority-high-bg: rgba(249, 115, 22, 0.12);
  --priority-medium: #eab308;
  --priority-medium-bg: rgba(234, 179, 8, 0.12);
  --priority-low: #3b82f6;
  --priority-low-bg: rgba(59, 130, 246, 0.12);
  --priority-info: #64748b;
  --priority-info-bg: rgba(100, 116, 139, 0.12);

  /* Status */
  --status-online: #22c55e;
  --status-warning: #eab308;
  --status-offline: #ef4444;
  --status-synced: #22c55e;
  --status-progressing: #3b82f6;
  --status-degraded: #f97316;
  --status-outofsync: #ef4444;

  /* Broadcast */
  --broadcast-critical: #ef4444;
  --broadcast-critical-bg: rgba(239, 68, 68, 0.08);
  --broadcast-critical-border: rgba(239, 68, 68, 0.3);
  --broadcast-high: #f97316;
  --broadcast-high-bg: rgba(249, 115, 22, 0.08);
  --broadcast-high-border: rgba(249, 115, 22, 0.3);
  --broadcast-medium: #eab308;
  --broadcast-medium-bg: rgba(234, 179, 8, 0.06);
  --broadcast-medium-border: rgba(234, 179, 8, 0.25);
  --broadcast-info: #3b82f6;
  --broadcast-info-bg: rgba(59, 130, 246, 0.06);
  --broadcast-info-border: rgba(59, 130, 246, 0.2);

  /* Metrics */
  --metric-green: #22c55e;
  --metric-green-bg: rgba(34, 197, 94, 0.1);

  /* Sizing */
  --header-height: 52px;
  --sidebar-width: 320px;
  --bottom-panel-height: 200px;
  --radius: 8px;
  --radius-lg: 12px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   LAYOUT GRID
   ============================================================ */
.dashboard {
  display: grid;
  grid-template-rows: var(--header-height) 1fr var(--bottom-panel-height);
  grid-template-columns: 1fr minmax(200px, 18%);
  grid-template-areas:
    "header   header"
    "main     sidebar"
    "bottom   sidebar";
  height: 100vh;
  gap: 0;
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

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

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon svg {
  width: 18px;
  height: 18px;
  fill: white;
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #f1f5f9, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-divider {
  width: 1px;
  height: 24px;
  background: var(--border-accent);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.connection-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--status-online);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-time {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.last-updated {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.main {
  grid-area: main;
  padding: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Summary Cards */
.summary-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  flex-shrink: 0;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.2s;
}

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

.summary-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.summary-card-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.summary-card-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 100px;
  font-weight: 600;
}

.badge-up { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-down { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-neutral { background: rgba(100,116,139,0.15); color: #94a3b8; }

.summary-card-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.summary-card-sub {
  font-size: 11px;
  color: var(--text-tertiary);
}

.value-blue { color: var(--accent-blue); }
.value-red { color: var(--priority-critical); }
.value-orange { color: var(--priority-high); }
.value-green { color: var(--metric-green); }
.value-yellow { color: var(--priority-medium); }

/* Content Split */
.content-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title-icon {
  width: 16px;
  height: 16px;
  opacity: 0.6;
}

.panel-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--accent-blue-dim);
  color: var(--accent-blue);
  font-weight: 600;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

/* Hide scrollbar but allow scrolling */
.panel-body::-webkit-scrollbar { width: 3px; }
.panel-body::-webkit-scrollbar-track { background: transparent; }
.panel-body::-webkit-scrollbar-thumb { background: var(--border-accent); border-radius: 10px; }

/* Ticket List */
.ticket-row {
  display: grid;
  grid-template-columns: 6px 1fr auto;
  gap: 12px;
  padding: 10px 16px;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.15s;
}

.ticket-row:hover {
  background: var(--bg-card-hover);
}

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

.priority-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-critical { background: var(--priority-critical); box-shadow: 0 0 6px rgba(239,68,68,0.4); }
.dot-high { background: var(--priority-high); box-shadow: 0 0 6px rgba(249,115,22,0.3); }
.dot-medium { background: var(--priority-medium); }
.dot-low { background: var(--priority-low); }

.ticket-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ticket-key {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ticket-summary {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticket-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.ticket-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.ticket-assignee {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-blue-dim);
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}

.ticket-age {
  font-size: 11px;
  color: var(--text-tertiary);
}

.age-warning { color: var(--priority-high); }
.age-critical { color: var(--priority-critical); }

.sla-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sla-ok { background: rgba(34,197,94,0.12); color: #4ade80; }
.sla-warn { background: rgba(234,179,8,0.12); color: #facc15; }
.sla-breach { background: rgba(239,68,68,0.15); color: #f87171; }

/* Agent Workload */
.agent-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  padding: 10px 16px;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
}

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

.agent-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agent-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.agent-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.agent-status {
  font-size: 11px;
  color: var(--text-tertiary);
}

.agent-bar-container {
  height: 8px;
  background: var(--bg-primary);
  border-radius: 100px;
  overflow: hidden;
  position: relative;
}

.agent-bar {
  height: 100%;
  border-radius: 100px;
  transition: width 0.6s ease;
}

.bar-low { background: linear-gradient(90deg, #22c55e, #4ade80); }
.bar-medium { background: linear-gradient(90deg, #eab308, #facc15); }
.bar-high { background: linear-gradient(90deg, #f97316, #fb923c); }
.bar-critical { background: linear-gradient(90deg, #ef4444, #f87171); }

.agent-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   BROADCAST SIDEBAR
   ============================================================ */
.sidebar {
  grid-area: sidebar;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-count {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 100px;
  background: var(--accent-blue-dim);
  color: var(--accent-blue);
  font-weight: 600;
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-body::-webkit-scrollbar { width: 3px; }
.sidebar-body::-webkit-scrollbar-track { background: transparent; }
.sidebar-body::-webkit-scrollbar-thumb { background: var(--border-accent); border-radius: 10px; }

.broadcast-card {
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-left: 3px solid;
  position: relative;
}

.broadcast-critical {
  background: var(--broadcast-critical-bg);
  border-color: var(--broadcast-critical);
  border-top: 1px solid var(--broadcast-critical-border);
  border-right: 1px solid var(--broadcast-critical-border);
  border-bottom: 1px solid var(--broadcast-critical-border);
}

.broadcast-high {
  background: var(--broadcast-high-bg);
  border-color: var(--broadcast-high);
  border-top: 1px solid var(--broadcast-high-border);
  border-right: 1px solid var(--broadcast-high-border);
  border-bottom: 1px solid var(--broadcast-high-border);
}

.broadcast-medium {
  background: var(--broadcast-medium-bg);
  border-color: var(--broadcast-medium);
  border-top: 1px solid var(--broadcast-medium-border);
  border-right: 1px solid var(--broadcast-medium-border);
  border-bottom: 1px solid var(--broadcast-medium-border);
}

.broadcast-info {
  background: var(--broadcast-info-bg);
  border-color: var(--broadcast-info);
  border-top: 1px solid var(--broadcast-info-border);
  border-right: 1px solid var(--broadcast-info-border);
  border-bottom: 1px solid var(--broadcast-info-border);
}

.broadcast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.broadcast-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 3px;
}

.tag-critical { background: rgba(239,68,68,0.2); color: #f87171; }
.tag-high { background: rgba(249,115,22,0.2); color: #fb923c; }
.tag-medium { background: rgba(234,179,8,0.15); color: #facc15; }
.tag-info { background: rgba(59,130,246,0.15); color: #60a5fa; }

.broadcast-pin {
  font-size: 11px;
  color: var(--text-tertiary);
}

.broadcast-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.broadcast-body {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.broadcast-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-tertiary);
}

.broadcast-category {
  padding: 1px 6px;
  background: rgba(100,116,139,0.1);
  border-radius: 3px;
}

/* ============================================================
   BOTTOM ROTATING PANEL
   ============================================================ */
.bottom-panel {
  grid-area: bottom;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.bottom-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.bottom-panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.rotation-dots {
  display: flex;
  gap: 6px;
}

.rotation-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-accent);
  transition: all 0.3s;
}

.rotation-dot.active {
  background: var(--accent-blue);
  width: 18px;
  border-radius: 3px;
}

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

.panel-slide {
  position: absolute;
  inset: 0;
  display: grid;
  gap: 10px;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.panel-slide.hidden {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

/* Store Status Grid */
.store-grid {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}

.store-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.2s;
}

.store-card.online { border-left: 3px solid var(--status-online); }
.store-card.warning { border-left: 3px solid var(--status-warning); }
.store-card.offline { border-left: 3px solid var(--status-offline); }

.store-code {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.store-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.store-status-dot.online { background: var(--status-online); box-shadow: 0 0 6px rgba(34,197,94,0.4); }
.store-status-dot.warning { background: var(--status-warning); box-shadow: 0 0 6px rgba(234,179,8,0.4); }
.store-status-dot.offline { background: var(--status-offline); box-shadow: 0 0 6px rgba(239,68,68,0.4); }

.store-detail {
  font-size: 10px;
  color: var(--text-tertiary);
  display: flex;
  justify-content: space-between;
}

/* Network Health */
.network-grid {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.network-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.network-site {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.network-nodes {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.node-chip {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 500;
}

.node-healthy { background: rgba(34,197,94,0.12); color: #4ade80; }
.node-degraded { background: rgba(249,115,22,0.12); color: #fb923c; }
.node-down { background: rgba(239,68,68,0.15); color: #f87171; }

/* ArgoCD Deployments */
.deploy-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.deploy-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.deploy-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sync-badge {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sync-synced { background: rgba(34,197,94,0.12); color: #4ade80; }
.sync-progressing { background: rgba(59,130,246,0.15); color: #60a5fa; }
.sync-degraded { background: rgba(249,115,22,0.12); color: #fb923c; }
.sync-outofsync { background: rgba(239,68,68,0.15); color: #f87171; }

.deploy-meta {
  font-size: 10px;
  color: var(--text-tertiary);
  display: flex;
  justify-content: space-between;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: slideIn 0.3s ease forwards;
}

/* Stagger animation for cards */
.summary-card:nth-child(1) { animation-delay: 0ms; }
.summary-card:nth-child(2) { animation-delay: 60ms; }
.summary-card:nth-child(3) { animation-delay: 120ms; }
.summary-card:nth-child(4) { animation-delay: 180ms; }
.summary-card:nth-child(5) { animation-delay: 240ms; }

/* ============================================================
   UTILITIES
   ============================================================ */
.mono { font-variant-numeric: tabular-nums; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
