/* CASSI Rail Innovation - Custom Styles */

/* Status colors */
.status-ok { color: #16a34a; }
.status-warning { color: #d97706; }
.status-critical { color: #dc2626; }
.bg-status-ok { background-color: #dcfce7; }
.bg-status-warning { background-color: #fef3c7; }
.bg-status-critical { background-color: #fee2e2; }

/* Navigation accent line (railroad signal inspired: blue/amber/blue) */
.nav-accent {
  height: 3px;
  background: linear-gradient(to right, #3b82f6, #f59e0b, #3b82f6);
}

/* Report text formatting */
.report-text {
  white-space: pre-wrap;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1.4;
  background: #1e293b;
  color: #e2e8f0;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  max-height: 70vh;
  overflow-y: auto;
}

/* KPI card hover */
.kpi-card {
  transition: transform 0.2s, box-shadow 0.2s;
}
.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.10);
}

/* Loading spinner */
.spinner {
  border: 3px solid #e5e7eb;
  border-top: 3px solid #2563eb;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Tab styles */
.tab-btn {
  padding: 0.75rem 1.25rem;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  color: #6b7280;
  font-size: 0.875rem;
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}
.tab-btn.active {
  border-bottom-color: #2563eb;
  color: #1e40af;
  font-weight: 600;
}
.tab-btn:hover {
  color: #1e40af;
  background-color: #f8fafc;
}

/* Condition badges */
.badge { padding: 0.15rem 0.5rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; }
.badge-c { background: #dcfce7; color: #166534; }
.badge-a { background: #fef3c7; color: #92400e; }
.badge-r { background: #fee2e2; color: #991b1b; }
.badge-nt { background: #e5e7eb; color: #374151; }

/* Subdivision card hover */
.sub-card {
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.sub-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.12);
  border-left-color: #1d4ed8;
}

/* Search input with icon */
.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.search-wrapper svg {
  position: absolute;
  left: 0.75rem;
  color: #9ca3af;
  pointer-events: none;
}
.search-wrapper input {
  padding-left: 2.5rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Report Renderer (rr-*) — professional formatted analysis view
   ═══════════════════════════════════════════════════════════════════════════ */

/* Container for the rendered report */
.rr-container {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 1.5rem 2rem;
  max-height: 75vh;
  overflow-y: auto;
  overflow-x: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 0.875rem;
  line-height: 1.6;
  color: #1a202c;
}

.rr-empty { color: #718096; font-style: italic; }

/* ── Section headers ───────────────────────────────────────────────────── */

.rr-section-header {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a365d;
  margin: 1.5rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid #2c5282;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.rr-section-header:first-child { margin-top: 0; }

.rr-section-actions { border-bottom-color: #dd6b20; }

.rr-subsection-header {
  font-size: 0.95rem;
  font-weight: 600;
  color: #2c5282;
  margin: 1.25rem 0 0.5rem;
}

.rr-subsection-minor {
  font-size: 0.9rem;
  color: #4a5568;
  margin: 1rem 0 0.4rem;
  font-weight: 600;
}

.rr-critical-header { color: #c53030; }
.rr-warning-header { color: #dd6b20; }

.rr-track-header {
  font-size: 0.9rem;
  font-weight: 600;
  color: #3182ce;
  background: #f7fafc;
  padding: 0.4rem 0.75rem;
  border-left: 3px solid #3182ce;
  margin: 1rem 0 0.5rem;
  border-radius: 0 4px 4px 0;
}

/* ── Severity badges ───────────────────────────────────────────────────── */

.rr-badge-line {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.35rem 0;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  background: #f7fafc;
  border-left: 3px solid transparent;
}

.rr-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.rr-badge-text { flex: 1; }

.rr-badge-critical { background: #fed7d7; color: #c53030; }
.rr-badge-line:has(.rr-badge-critical) { border-left-color: #c53030; background: #fff5f5; }

.rr-badge-warning { background: #fefcbf; color: #b7791f; }
.rr-badge-line:has(.rr-badge-warning) { border-left-color: #dd6b20; background: #fffaf0; }

.rr-badge-info { background: #bee3f8; color: #2b6cb0; }
.rr-badge-line:has(.rr-badge-info) { border-left-color: #3182ce; background: #ebf8ff; }

.rr-badge-ok { background: #c6f6d5; color: #276749; }
.rr-badge-line:has(.rr-badge-ok) { border-left-color: #276749; background: #f0fff4; }

/* ── Critical banners ──────────────────────────────────────────────────── */

.rr-critical-banner {
  background: #c53030;
  color: #fff;
  font-weight: 700;
  text-align: center;
  padding: 0.6rem 1rem;
  border-radius: 6px;
  margin: 1rem 0;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}
.rr-critical-banner-sm { font-size: 0.85rem; padding: 0.4rem 0.75rem; }

.rr-primary-finding {
  background: #fff5f5;
  border: 1px solid #feb2b2;
  border-left: 4px solid #c53030;
  color: #c53030;
  font-weight: 700;
  padding: 0.5rem 0.75rem;
  border-radius: 0 6px 6px 0;
  margin: 0.75rem 0;
}

.rr-not-equipment {
  background: #f0fff4;
  border: 1px solid #9ae6b4;
  border-left: 4px solid #276749;
  color: #276749;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-radius: 0 6px 6px 0;
  margin: 0.5rem 0;
}

/* ── Collapsible sections ──────────────────────────────────────────────── */

.rr-collapsible {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin: 1rem 0;
  overflow: hidden;
}

.rr-collapsible-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1a365d;
  background: linear-gradient(135deg, #f7fafc, #edf2f7);
  padding: 0.6rem 1rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.15s;
}
.rr-collapsible-title:hover { background: linear-gradient(135deg, #edf2f7, #e2e8f0); }

.rr-collapsible-title::before {
  content: '\25B6';
  font-size: 0.6rem;
  transition: transform 0.2s;
  color: #718096;
}
.rr-collapsible[open] > .rr-collapsible-title::before {
  transform: rotate(90deg);
}

/* Hide default marker in Safari/Chrome */
.rr-collapsible-title::-webkit-details-marker { display: none; }

.rr-collapsible-body {
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid #e2e8f0;
}

/* ── Tables ────────────────────────────────────────────────────────────── */

.rr-table-wrap {
  overflow-x: auto;
  margin: 0.75rem 0;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.rr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.rr-table th {
  background: #1a365d;
  color: #fff;
  font-weight: 600;
  padding: 0.5rem 0.6rem;
  text-align: left;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.rr-table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid #edf2f7;
  color: #2d3748;
}

.rr-table tbody tr:nth-child(even) { background: #f7fafc; }
.rr-table tbody tr:hover { background: #edf2f7; }

/* ── Numbered / lettered items ─────────────────────────────────────────── */

.rr-numbered-item {
  margin: 0.3rem 0 0.3rem 0.5rem;
  padding: 0.25rem 0;
}
.rr-item-num {
  font-weight: 700;
  color: #2c5282;
  margin-right: 0.25rem;
}

.rr-lettered-item {
  margin: 0.15rem 0 0.15rem 2rem;
  color: #4a5568;
}

/* ── Bullets ───────────────────────────────────────────────────────────── */

.rr-bullet {
  margin: 0.2rem 0 0.2rem 1rem;
  padding-left: 0.75rem;
  position: relative;
}
.rr-bullet::before {
  content: '\2022';
  position: absolute;
  left: 0;
  color: #4a5568;
  font-weight: 700;
}

.rr-sub-bullet {
  margin: 0.1rem 0 0.1rem 2.5rem;
  padding-left: 0.75rem;
  position: relative;
  color: #718096;
  font-size: 0.825rem;
}
.rr-sub-bullet::before {
  content: '\25E6';
  position: absolute;
  left: 0;
  color: #a0aec0;
}

/* ── Key-value lines ───────────────────────────────────────────────────── */

.rr-kv {
  margin: 0.2rem 0 0.2rem 0.5rem;
  padding: 0.15rem 0;
}
.rr-kv-key { font-weight: 600; color: #2d3748; }
.rr-kv-critical .rr-kv-key { color: #c53030; }
.rr-kv-warning .rr-kv-key { color: #dd6b20; }
.rr-kv-ok .rr-kv-key { color: #276749; }
.rr-kv-muted { color: #718096; font-style: italic; }

/* ── Action arrows ─────────────────────────────────────────────────────── */

.rr-action {
  margin: 0.2rem 0 0.2rem 1.5rem;
  padding-left: 1.2rem;
  position: relative;
  color: #4a5568;
}
.rr-action::before {
  content: '\2192';
  position: absolute;
  left: 0;
  font-weight: 700;
  color: #3182ce;
}
.rr-action-critical { color: #c53030; font-weight: 600; }
.rr-action-critical::before { color: #c53030; }

/* ── Misc elements ─────────────────────────────────────────────────────── */

.rr-event-header {
  font-weight: 600;
  color: #3182ce;
  background: #f7fafc;
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  margin: 0.75rem 0 0.4rem;
  font-size: 0.85rem;
}

.rr-date-entry {
  font-weight: 600;
  color: #2c5282;
  margin: 0.75rem 0 0.25rem;
  padding: 0.25rem 0;
  border-bottom: 1px dashed #cbd5e0;
}

.rr-highlight {
  font-weight: 600;
  color: #2d3748;
  margin: 0.4rem 0;
}

.rr-note {
  color: #718096;
  font-style: italic;
  margin: 0.3rem 0;
}

.rr-body {
  margin: 0.2rem 0;
  color: #2d3748;
}

/* ── View toggle button ────────────────────────────────────────────────── */

.rr-view-toggle {
  display: inline-flex;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  overflow: hidden;
  font-size: 0.8rem;
}
.rr-view-toggle button {
  padding: 0.35rem 0.75rem;
  border: none;
  background: #f7fafc;
  color: #4a5568;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.rr-view-toggle button:not(:last-child) { border-right: 1px solid #cbd5e0; }
.rr-view-toggle button.active {
  background: #2c5282;
  color: #fff;
}
.rr-view-toggle button:hover:not(.active) { background: #edf2f7; }

/* ═══════════════════════════════════════════════════════════════════════════ */

@media print {
  nav, .nav-accent, .no-print { display: none !important; }
  .report-text { max-height: none; background: white; color: black; }
  .rr-container { max-height: none; border: none; box-shadow: none; }
  .rr-collapsible[open] > .rr-collapsible-body,
  .rr-collapsible:not([open]) > .rr-collapsible-body {
    display: block !important;
  }
  .rr-collapsible { border: none; }
  .rr-collapsible-title::before { display: none; }
}
