/* ==========================================================================
   StadiumOps Copilot — Enterprise Design System
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tokens & Variables
-------------------------------------------------------------------------- */
:root {
  /* Colors - Backgrounds (Enterprise Slate) */
  --bg-app: #09090b; /* Very dark, almost black */
  --bg-panel: #18181b; /* Zinc 900 */
  --bg-panel-hover: #27272a; /* Zinc 800 */
  --bg-input: #09090b;
  --bg-overlay: rgba(9, 9, 11, 0.8);
  
  /* Colors - Borders */
  --border-light: rgba(255, 255, 255, 0.1);
  --border-focus: #3b82f6; /* Blue 500 */
  
  /* Colors - Typography */
  --text-primary: #fafafa; /* Zinc 50 */
  --text-secondary: #a1a1aa; /* Zinc 400 */
  --text-muted: #71717a; /* Zinc 500 */
  
  /* Colors - Semantic (Accessible Contrast) */
  --color-success: #10b981; /* Emerald 500 */
  --color-success-bg: rgba(16, 185, 129, 0.1);
  --color-warning: #f59e0b; /* Amber 500 */
  --color-warning-bg: rgba(245, 158, 11, 0.1);
  --color-danger: #ef4444; /* Red 500 */
  --color-danger-bg: rgba(239, 68, 68, 0.1);
  --color-info: #3b82f6; /* Blue 500 */
  --color-info-bg: rgba(59, 130, 246, 0.1);
  
  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  
  /* Radii */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
  
  /* Motion */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Fonts */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* --------------------------------------------------------------------------
   Resets & Globals
-------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, p {
  margin: 0;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: var(--color-info);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Accessibility Focus */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-info);
  color: white;
  padding: 8px;
  z-index: 100;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 0;
}

/* --------------------------------------------------------------------------
   Scrollbars
-------------------------------------------------------------------------- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--bg-panel-hover);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Layouts
-------------------------------------------------------------------------- */

/* Command Bar (Header) */
.command-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-6);
  background: rgba(9, 9, 11, 0.75);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
}

.cmd-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.cmd-logo {
  color: var(--text-primary);
  width: 24px;
  height: 24px;
}

.cmd-titles {
  display: flex;
  flex-direction: column;
}

.cmd-titles h1 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
}

.cmd-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.cmd-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.cmd-actions .btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.cmd-actions .btn-icon:hover {
  color: var(--text-primary);
  background: var(--bg-panel);
}

.cmd-shortcut {
  font-size: 0.75rem;
  background: var(--bg-panel-hover);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
}

.cmd-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--bg-panel-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
}

/* KPI Strip */
.kpi-strip {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-6);
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
}
.kpi-strip::-webkit-scrollbar {
  display: none; /* Safari/Chrome */
}

.kpi-card {
  flex: 0 0 auto;
  min-width: 240px;
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  box-shadow: var(--shadow-sm);
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
}

.kpi-header svg {
  width: 16px;
  height: 16px;
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.kpi-trend {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: var(--radius-full);
}
.kpi-trend.positive { color: var(--color-success); background: var(--color-success-bg); }
.kpi-trend.negative { color: var(--color-danger); background: var(--color-danger-bg); }
.kpi-trend.neutral { color: var(--text-secondary); background: var(--bg-panel-hover); }


/* Main Grid */
.app-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-6);
  padding: 0 var(--space-6) var(--space-6) var(--space-6);
  max-width: 1600px;
  margin: 0 auto;
}

/* Panel Positioning in 12-col grid */
.panel-status       { grid-column: span 12; }
.panel-left         { grid-column: span 4; }
.panel-mid-top      { grid-column: span 4; }
.panel-mid-bottom   { grid-column: span 4; }
.panel-right-top    { grid-column: span 6; }
.panel-right-bottom { grid-column: span 6; }

@media (max-width: 1200px) {
  .panel-left         { grid-column: span 6; }
  .panel-mid-top      { grid-column: span 6; }
  .panel-mid-bottom   { grid-column: span 6; }
  .panel-right-top    { grid-column: span 6; }
}

@media (max-width: 768px) {
  .app-grid { grid-template-columns: 1fr; }
  .panel { grid-column: span 1 !important; }
}

/* --------------------------------------------------------------------------
   Panels
-------------------------------------------------------------------------- */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  transition: box-shadow var(--transition-normal);
  animation: fadeIn 0.5s ease-out both;
}

.panel:hover {
  box-shadow: var(--shadow-lg);
}

/* Stagger animations */
.panel:nth-child(1) { animation-delay: 0.05s; }
.panel:nth-child(2) { animation-delay: 0.1s; }
.panel:nth-child(3) { animation-delay: 0.15s; }
.panel:nth-child(4) { animation-delay: 0.2s; }
.panel:nth-child(5) { animation-delay: 0.25s; }
.panel:nth-child(6) { animation-delay: 0.3s; }

.panel-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-light);
}

.panel-header svg {
  color: var(--text-secondary);
  width: 20px;
  height: 20px;
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Components
-------------------------------------------------------------------------- */

/* Buttons */
.btn, button {
  background: var(--bg-panel-hover);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: inherit;
}

.btn:hover:not(:disabled), button:hover:not(:disabled) {
  background: var(--border-light);
  border-color: var(--text-muted);
}

.btn-primary {
  background: var(--text-primary);
  color: var(--bg-app);
  border: none;
}
.btn-primary:hover:not(:disabled) {
  background: var(--text-secondary);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Inputs & Textareas */
input, textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  transition: border-color var(--transition-fast);
  box-sizing: border-box;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid transparent;
}
.badge-low { color: var(--color-success); background: var(--color-success-bg); border-color: rgba(16,185,129,0.2); }
.badge-medium { color: var(--color-warning); background: var(--color-warning-bg); border-color: rgba(245,158,11,0.2); }
.badge-high { color: var(--color-danger); background: var(--color-danger-bg); border-color: rgba(239,68,68,0.2); }
.badge-info { color: var(--color-info); background: var(--color-info-bg); border-color: rgba(59,130,246,0.2); }
.badge-outline { background: transparent; border-color: var(--border-light); color: var(--text-secondary); }

/* Progress Bar */
.progress-container {
  width: 100%;
  height: 6px;
  background: var(--bg-panel-hover);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: var(--space-1);
}
.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Loading Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-panel-hover) 25%, var(--border-light) 50%, var(--bg-panel-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   Specific Panel Styles
-------------------------------------------------------------------------- */

/* Gates Grid */
.gate-card {
  background: var(--bg-app);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  transition: border-color var(--transition-fast);
}
.gate-card:hover {
  border-color: var(--text-muted);
}
.gate-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-2);
}
.gate-card__title {
  font-size: 1rem;
  font-weight: 600;
}
.gate-card__metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  margin-top: var(--space-3);
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.gate-metric {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.gate-metric svg { width: 14px; height: 14px; }
.gate-metric-val { color: var(--text-primary); font-weight: 500; }

.gate-card--no-wheelchair {
  opacity: 0.6;
}

/* AI Section in Gates */
.gate-ai-section {
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-light);
}
.btn-gate-ai { width: 100%; justify-content: center; }
.ai-recommendation-card {
  margin-top: var(--space-2);
  padding: var(--space-3);
  background: var(--color-info-bg);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text-primary);
}
.ai-label {
  color: var(--color-info);
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-1);
  font-weight: 600;
}

/* Assistant Chat */
.assistant-history {
  flex-grow: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  padding-right: var(--space-2);
}
.chat-msg {
  display: flex;
  gap: var(--space-3);
  font-size: 0.875rem;
}
.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-msg--user .msg-avatar {
  background: var(--bg-panel-hover);
  color: var(--text-secondary);
}
.chat-msg--assistant .msg-avatar {
  background: var(--text-primary);
  color: var(--bg-app);
}
.msg-content {
  flex-grow: 1;
  color: var(--text-primary);
  line-height: 1.6;
}
.msg-content p { margin-bottom: var(--space-2); }
.msg-content ul { list-style: disc; padding-left: var(--space-4); margin-bottom: var(--space-2); }
.msg-content strong { color: var(--text-primary); font-weight: 600; }

.assistant-input-group {
  display: flex;
  gap: var(--space-2);
  margin-top: auto;
}
.assistant-input {
  margin-bottom: 0;
}

/* Briefing & Markdown */
.briefing-content {
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-secondary);
}
.briefing-content strong { color: var(--text-primary); }
.briefing-content ul {
  list-style: none;
}
.briefing-content li {
  position: relative;
  padding-left: var(--space-4);
  margin-bottom: var(--space-2);
}
.briefing-content li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--color-info);
}
.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.75rem;
  color: var(--color-info);
  background: var(--color-info-bg);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-3);
  font-weight: 500;
}

/* Broadcast */
.broadcast-input-group {
  position: relative;
  margin-bottom: var(--space-4);
}
.broadcast-counter {
  position: absolute;
  bottom: var(--space-2);
  right: var(--space-2);
  font-size: 0.75rem;
  color: var(--text-muted);
}
.broadcast-controls {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.broadcast-results {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.translation-card {
  background: var(--bg-app);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-primary);
}
.translation-card__header {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-2);
  font-family: var(--font-sans);
  color: var(--text-secondary);
  font-size: 0.75rem;
}

/* Accessibility */
.access-queue {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.access-req {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3);
  background: var(--bg-app);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  transition: opacity var(--transition-normal);
}
.access-req.completed {
  opacity: 0.4;
}
.access-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.access-title {
  font-weight: 500;
  font-size: 0.875rem;
}
.access-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  gap: var(--space-2);
}

/* --------------------------------------------------------------------------
   Command Palette Overlay
-------------------------------------------------------------------------- */
.palette-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  opacity: 1;
  transition: opacity var(--transition-fast);
}
.palette-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.palette-modal {
  width: 100%;
  max-width: 600px;
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}
.palette-input-group {
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-light);
}
.palette-input-group svg {
  color: var(--text-muted);
  width: 20px;
  height: 20px;
}
.palette-input-group input {
  background: transparent;
  border: none;
  margin: 0;
  padding: 0 var(--space-3);
  font-size: 1rem;
  color: var(--text-primary);
}
.palette-input-group input:focus {
  outline: none;
  border: none;
}
.palette-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.palette-results {
  padding: var(--space-2);
  max-height: 300px;
  overflow-y: auto;
}
.palette-item {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.palette-item:hover {
  background: var(--bg-panel-hover);
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Utilities & Animations
-------------------------------------------------------------------------- */
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }

.flex { display: flex; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-2 { gap: var(--space-2); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  100% { background-position: -200% 0; }
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}
.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: var(--radius-full);
  animation: typing 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}
