/* =============================================================================
   DCAS Move-Up App — Component Styles
   File: css/components.css
   Covers: unit rows, status pills, recommendation cards, incident rows,
           skeleton loaders, mini-map thumbnails, alert badges
   ============================================================================= */

/* -----------------------------------------------------------------------------
   1. UNIT LIST ROWS
   Each row: ambulance icon + call sign | status pill + bar
   ----------------------------------------------------------------------------- */
.unit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-snap);
  gap: 6px;
  min-height: 28px;
}

.unit-row:hover {
  background: var(--bg-surface-hover);
}

.unit-row.selected {
  background: rgba(0, 92, 171, 0.12);
  border-left: 2px solid var(--dcas-blue);
}

.unit-row.alert {
  /* Unit at under-capacity station — subtle red highlight */
  background: rgba(227, 24, 55, 0.06);
  border-left: 2px solid var(--dcas-red);
}

/* Left side: icon + call sign */
.unit-identity {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}

.unit-icon {
  width: 20px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.85;
}

/* SVG ambulance icon rendered inline */
.unit-icon svg {
  width: 100%;
  height: 100%;
}

.unit-callsign {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Right side: status pill + bar */
.unit-status-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Status bar — horizontal bar like in the wireframe */
.unit-status-bar {
  width: 56px;
  height: 5px;
  border-radius: 2px;
  background: var(--bg-surface);
  position: relative;
  overflow: hidden;
}

.unit-status-bar-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  border-radius: 2px;
  transition: width var(--dur-mid) var(--ease-out),
              background var(--dur-mid) var(--ease-out);
}

/* Status pill — text badge */
.status-pill {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 2px;
  white-space: nowrap;
}

.status-pill--available {
  background: rgba(0, 200, 150, 0.12);
  color: var(--status-available);
  border: 1px solid rgba(0, 200, 150, 0.25);
}

.status-pill--busy {
  background: rgba(227, 24, 55, 0.12);
  color: var(--status-busy);
  border: 1px solid rgba(227, 24, 55, 0.25);
}

.status-pill--transit {
  background: rgba(240, 165, 0, 0.12);
  color: var(--status-transit);
  border: 1px solid rgba(240, 165, 0, 0.25);
}

.status-pill--offline {
  background: rgba(74, 90, 112, 0.12);
  color: var(--status-offline);
  border: 1px solid rgba(74, 90, 112, 0.25);
}

/* Bar fill colours matching status */
.unit-status-bar-fill.available { background: var(--status-available); }
.unit-status-bar-fill.busy      { background: var(--status-busy); }
.unit-status-bar-fill.transit   { background: var(--status-transit); }
.unit-status-bar-fill.offline   { background: var(--status-offline); }

/* -----------------------------------------------------------------------------
   2. RECOMMENDATION CARDS
   ----------------------------------------------------------------------------- */
.rec-card {
  margin: 6px 8px;
  padding: 10px 10px 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  cursor: pointer;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  overflow: hidden;
  animation: fade-in var(--dur-mid) var(--ease-out) forwards;
}

.rec-card:hover {
  border-color: var(--dcas-blue);
  box-shadow: 0 0 0 1px var(--dcas-blue-glow), 0 4px 16px rgba(0,0,0,0.4);
}

/* Priority stripe on left edge */
.rec-card--critical { border-left: 3px solid var(--sev-critical); }
.rec-card--high     { border-left: 3px solid var(--sev-high); }
.rec-card--medium   { border-left: 3px solid var(--sev-medium); }
.rec-card--low      { border-left: 3px solid var(--sev-low); }

.rec-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 5px;
}

.rec-priority-badge {
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 2px;
  flex-shrink: 0;
}

.rec-priority-badge--critical {
  background: rgba(227, 24, 55, 0.18);
  color: var(--sev-critical);
  border: 1px solid rgba(227, 24, 55, 0.3);
}

.rec-priority-badge--high {
  background: rgba(240, 165, 0, 0.18);
  color: var(--sev-high);
  border: 1px solid rgba(240, 165, 0, 0.3);
}

.rec-priority-badge--medium {
  background: rgba(0, 92, 171, 0.18);
  color: var(--text-accent-blue);
  border: 1px solid rgba(0, 92, 171, 0.3);
}

.rec-eta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.rec-card-body {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 8px;
}

/* Highlighted unit callsign / station name within rec text */
.rec-card-body strong {
  color: var(--text-accent-blue);
  font-weight: 600;
}

.rec-card-body .rec-station-from {
  color: var(--status-transit);
  font-weight: 600;
}

.rec-card-body .rec-station-to {
  color: var(--status-available);
  font-weight: 600;
}

/* Mini-map thumbnail placeholder — replaced with actual MapView in Step 5 */
.rec-mini-map {
  width: 100%;
  height: 68px;
  background: var(--bg-panel);
  border-top: 1px solid var(--border-subtle);
  margin: 0 -10px;
  position: relative;
  overflow: hidden;
}

.rec-mini-map-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-tertiary);
  letter-spacing: 0.06em;
}

/* Mini-map canvas (will be set by mapManager) */
.rec-mini-map canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Action button row */
.rec-card-actions {
  display: flex;
  gap: 6px;
  padding: 6px 0 8px;
}

.rec-btn {
  flex: 1;
  padding: 5px 0;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 3px;
  transition: background var(--dur-fast);
  text-align: center;
}

.rec-btn--accept {
  background: rgba(0, 92, 171, 0.2);
  border: 1px solid var(--dcas-blue);
  color: var(--text-accent-blue);
}

.rec-btn--accept:hover {
  background: rgba(0, 92, 171, 0.35);
}

.rec-btn--dismiss {
  background: var(--bg-input);
  border: 1px solid var(--border-mid);
  color: var(--text-tertiary);
}

.rec-btn--dismiss:hover {
  background: var(--bg-surface-hover);
  color: var(--text-secondary);
}

/* Empty state */
.rec-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
  line-height: 1.6;
}

.rec-empty-icon {
  font-size: 28px;
  margin-bottom: 10px;
  opacity: 0.4;
}

/* -----------------------------------------------------------------------------
   3. INCIDENT LOG ROWS
   ----------------------------------------------------------------------------- */
.incident-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 11px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--dur-fast);
}

.incident-row:hover { background: var(--bg-surface-hover); }

.incident-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  white-space: nowrap;
  flex-shrink: 0;
}

.incident-class {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 2px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.incident-class--emergency {
  background: rgba(227, 24, 55, 0.14);
  color: var(--dcas-red);
}

.incident-class--transfer {
  background: rgba(0, 92, 171, 0.14);
  color: var(--text-accent-blue);
}

.incident-class--activity {
  background: rgba(240, 165, 0, 0.14);
  color: var(--status-transit);
}

.incident-desc {
  flex: 1;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.incident-unit {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

/* -----------------------------------------------------------------------------
   4. SKELETON LOADERS
   Shown while data is fetching / engine is initialising
   ----------------------------------------------------------------------------- */
.skeleton {
  pointer-events: none;
}

/* Pulsing shimmer animation */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skel-bar,
.skel-pill,
.skel-line,
.skel-mini-map {
  background: linear-gradient(
    90deg,
    var(--bg-surface) 25%,
    var(--bg-surface-hover) 50%,
    var(--bg-surface) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 3px;
}

/* Unit row skeletons */
.unit-row.skeleton {
  justify-content: space-between;
  gap: 8px;
}

.skel-bar {
  height: 8px;
  flex: 1;
  max-width: 80px;
}

.skel-pill {
  width: 48px;
  height: 8px;
}

/* Rec card skeletons */
.rec-card.skeleton {
  cursor: default;
}

.skel-line {
  height: 9px;
  width: 100%;
  margin-bottom: 7px;
}

.skel-line--short { width: 55%; }

.skel-mini-map {
  height: 60px;
  margin: 8px 0 0;
  border-radius: 0;
}

/* -----------------------------------------------------------------------------
   5. ALERT / NOTIFICATION BADGE
   Used on right-panel header when recommendations are active
   ----------------------------------------------------------------------------- */
.alert-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--dcas-red);
  color: #fff;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  border-radius: 50%;
  flex-shrink: 0;
  animation: badge-pop var(--dur-mid) var(--ease-snap);
}

@keyframes badge-pop {
  0%   { transform: scale(0.6); opacity: 0; }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

/* -----------------------------------------------------------------------------
   6. STATION CAPACITY INDICATOR
   Used in the map popup / tooltip for each station
   ----------------------------------------------------------------------------- */
.station-popup {
  background: var(--bg-panel);
  border: 1px solid var(--border-mid);
  border-radius: 5px;
  padding: 10px 12px;
  min-width: 180px;
}

.station-popup-name {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.station-popup-zone {
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.station-capacity-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.capacity-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--bg-surface);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}

.capacity-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width var(--dur-slow) var(--ease-out);
}

/* Capacity fills: green when OK, red when under threshold */
.capacity-bar-fill.ok       { background: var(--status-available); }
.capacity-bar-fill.warning  { background: var(--status-transit); }
.capacity-bar-fill.critical { background: var(--status-busy); }

/* -----------------------------------------------------------------------------
   7. CUSTOM MAP POPUP (ESRI overrides for dark theme)
   ----------------------------------------------------------------------------- */
.esri-popup__main-container {
  background: var(--bg-panel) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-mid) !important;
  border-radius: 5px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6) !important;
  font-family: var(--font-body) !important;
}

.esri-popup__header {
  background: var(--bg-panel-header) !important;
  border-bottom: 1px solid var(--border-mid) !important;
}

.esri-popup__header-title {
  color: var(--text-primary) !important;
  font-family: var(--font-display) !important;
  font-size: 13px !important;
  font-weight: 600 !important;
}

.esri-popup__button {
  color: var(--text-secondary) !important;
}

.esri-popup__button:hover {
  background: var(--bg-surface-hover) !important;
  color: var(--text-primary) !important;
}

/* Override blue link color in popups */
.esri-popup__content a {
  color: var(--text-accent-blue) !important;
}

/* -----------------------------------------------------------------------------
   8. TOOLTIP (hover on units/stations on map)
   ----------------------------------------------------------------------------- */
.dcas-tooltip {
  position: absolute;
  background: var(--bg-panel);
  border: 1px solid var(--border-mid);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-secondary);
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  animation: fade-in 100ms ease-out;
}

.dcas-tooltip strong {
  color: var(--text-primary);
  display: block;
  font-size: 12px;
  margin-bottom: 2px;
}
