/**
 * Transit Core Enterprise Production Design System (v2.0)
 * WCAG 2.1 AA / Section 508 ADA Compliant Design Tokens & Components
 * Self-contained stylesheet engineered for deterministic multi-tenant dashboards.
 */

:root {
  /* Brand Core Colors */
  --brand-primary: #0284c7;        /* Sky 600 */
  --brand-primary-hover: #0369a1;  /* Sky 700 */
  --brand-primary-light: #e0f2fe;  /* Sky 100 */
  --brand-primary-dark: #075985;   /* Sky 800 */

  /* Neutral Surface Palette (Light Theme Default) */
  --bg-page: #f8fafc;              /* Slate 50 */
  --bg-surface: #ffffff;           /* White */
  --bg-surface-elevated: #f1f5f9;  /* Slate 100 */
  --bg-surface-subtle: #f8fafc;    /* Slate 50 */

  /* High-Contrast Typography (Exceeds WCAG 1.4.3 4.5:1 ratio) */
  --text-primary: #090d16;         /* 16:1 contrast ratio against white */
  --text-secondary: #334155;       /* 7:1 contrast ratio against white */
  --text-muted: #475569;           /* 4.6:1 contrast ratio against white */
  --text-inverse: #ffffff;

  /* Deterministic Borders */
  --border-subtle: #e2e8f0;        /* Slate 200 */
  --border-default: #cbd5e1;       /* Slate 300 */
  --border-strong: #94a3b8;        /* Slate 400 */
  --border-focus: #0284c7;

  /* Semantic Status Tokens */
  --status-success-bg: #ecfdf5;
  --status-success-text: #065f46;
  --status-success-border: #a7f3d0;

  --status-warning-bg: #fffbeb;
  --status-warning-text: #92400e;
  --status-warning-border: #fde68a;

  --status-danger-bg: #fff1f2;
  --status-danger-text: #9f1239;
  --status-danger-border: #fecdd3;

  --status-info-bg: #f0f9ff;
  --status-info-text: #075985;
  --status-info-border: #bae6fd;

  /* Shadows & Radius */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.06);

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, Menlo, monospace;
}

/* Base Document Setup */
html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.font-mono {
  font-family: var(--font-mono);
}

/* Accessibility Focus Rings (WCAG 2.4.7 Focus Visible) */
:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

/* Section 508 / WCAG 2.4.1 Skip Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 1rem;
  background: var(--brand-primary-dark);
  color: var(--text-inverse);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  z-index: 1000;
  text-decoration: none;
  font-weight: 700;
  transition: top 0.15s ease-in-out;
}
.skip-link:focus {
  top: 1rem;
}

/* ==========================================================================
   Component: Cards & Containers
   ========================================================================== */
.dash-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  color: var(--text-primary);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.dash-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.dash-card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dash-card-body {
  padding: 1.5rem;
}

.dash-card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-surface-subtle);
  border-bottom-left-radius: var(--radius-xl);
  border-bottom-right-radius: var(--radius-xl);
}

/* ==========================================================================
   Component: Stat Widgets
   ========================================================================== */
.dash-stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
}
.dash-stat-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.dash-stat-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.dash-stat-value {
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-mono);
  line-height: 1.2;
  margin-top: 0.25rem;
}

/* ==========================================================================
   Component: Buttons & Controls
   ========================================================================== */
.dash-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
  line-height: 1.25;
}

.dash-btn-primary {
  background-color: var(--brand-primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
}
.dash-btn-primary:hover {
  background-color: var(--brand-primary-hover);
  box-shadow: var(--shadow-md);
}

.dash-btn-secondary {
  background-color: var(--bg-surface);
  border-color: var(--border-default);
  color: var(--text-secondary);
}
.dash-btn-secondary:hover {
  background-color: var(--bg-surface-elevated);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.dash-btn-danger {
  background-color: #e11d48;
  color: var(--text-inverse);
}
.dash-btn-danger:hover {
  background-color: #be123c;
}

/* ==========================================================================
   Component: Status Badges
   ========================================================================== */
.dash-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  font-family: var(--font-mono);
}

.dash-badge-success {
  background-color: var(--status-success-bg);
  color: var(--status-success-text);
  border: 1px solid var(--status-success-border);
}

.dash-badge-warning {
  background-color: var(--status-warning-bg);
  color: var(--status-warning-text);
  border: 1px solid var(--status-warning-border);
}

.dash-badge-danger {
  background-color: var(--status-danger-bg);
  color: var(--status-danger-text);
  border: 1px solid var(--status-danger-border);
}

.dash-badge-info {
  background-color: var(--status-info-bg);
  color: var(--status-info-text);
  border: 1px solid var(--status-info-border);
}

/* ==========================================================================
   Component: Form Controls (WCAG 1.4.11 Non-text Contrast >= 3:1)
   ========================================================================== */
.dash-input, .dash-select, .dash-textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background-color: var(--bg-surface);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

.dash-input:focus, .dash-select:focus, .dash-textarea:focus {
  border-color: var(--brand-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.25);
}

.dash-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

/* ==========================================================================
   Component: Accessible Data Tables
   ========================================================================== */
.dash-table-container {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.8125rem;
}

.dash-table thead {
  background-color: var(--bg-surface-elevated);
  border-bottom: 2px solid var(--border-default);
}

.dash-table th {
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dash-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.dash-table tbody tr:hover {
  background-color: var(--bg-surface-subtle);
}

.dash-table tbody tr:last-child td {
  border-bottom: none;
}

/* ==========================================================================
   Component: Interactive Mobile Handset Simulator (160 GSM-7 Budget)
   ========================================================================== */
.phone-mockup {
  width: 320px;
  height: 600px;
  background-color: #0f172a;
  border-radius: 40px;
  border: 10px solid #1e293b;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  margin: 0 auto;
}

.phone-screen {
  flex: 1;
  background-color: #0b1120;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sms-bubble-inbound {
  align-self: flex-start;
  background-color: #334155;
  color: #f8fafc;
  padding: 0.625rem 0.875rem;
  border-radius: 1rem;
  border-bottom-left-radius: 0.25rem;
  font-size: 0.8125rem;
  max-width: 80%;
  line-height: 1.4;
}

.sms-bubble-outbound {
  align-self: flex-end;
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  color: #ffffff;
  padding: 0.625rem 0.875rem;
  border-radius: 1rem;
  border-bottom-right-radius: 0.25rem;
  font-size: 0.8125rem;
  max-width: 80%;
  line-height: 1.4;
  word-break: break-word;
}

.char-meter-container {
  padding: 0.75rem 1rem;
  background-color: #0f172a;
  border-top: 1px solid #1e293b;
}

.char-meter-bar-track {
  height: 6px;
  width: 100%;
  background-color: #334155;
  border-radius: var(--radius-full);
  overflow: hidden;
}

.char-meter-bar-fill {
  height: 100%;
  background-color: #38bdf8;
  transition: width 0.15s ease, background-color 0.15s ease;
}

.char-meter-bar-fill.warning {
  background-color: #f59e0b;
}

.char-meter-bar-fill.overflow {
  background-color: #ef4444;
}

/* ==========================================================================
   Component: Accessible Floating Toasts
   ========================================================================== */
#dash-toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.dash-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  animation: toast-slide-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 280px;
}

.dash-toast.toast-success {
  border-left: 4px solid #10b981;
}

.dash-toast.toast-error {
  border-left: 4px solid #ef4444;
}

.dash-toast.toast-warning {
  border-left: 4px solid #f59e0b;
}

@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translateY(1rem) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
