/* ═══════════════════════════════════════════════════════════════════════════
   FMB130 Vehicle Control – Premium Dark Theme
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* ── Color Palette ── */
  --bg-base:        #0a0e17;
  --bg-surface:     #111827;
  --bg-card:        #1a2236;
  --bg-card-hover:  #1f2a42;
  --bg-glass:       rgba(26, 34, 54, 0.75);

  --border:         rgba(255, 255, 255, 0.06);
  --border-hover:   rgba(255, 255, 255, 0.12);

  --text-primary:   #f0f4f8;
  --text-secondary: #8899b4;
  --text-muted:     #4a5b78;

  --accent-blue:    #3b82f6;
  --accent-cyan:    #06b6d4;
  --accent-green:   #10b981;
  --accent-red:     #ef4444;
  --accent-orange:  #f59e0b;
  --accent-purple:  #8b5cf6;

  --gradient-blue:  linear-gradient(135deg, #3b82f6, #06b6d4);
  --gradient-green: linear-gradient(135deg, #10b981, #059669);
  --gradient-red:   linear-gradient(135deg, #ef4444, #dc2626);
  --gradient-orange:linear-gradient(135deg, #f59e0b, #d97706);

  /* ── Car Diagram ── */
  --car-body:       #1e293b;
  --car-stroke:     #475569;
  --car-glass:      #0ea5e920;
  --headlight:      #fbbf24;

  /* ── Spacing / Radius ── */
  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      16px;
  --radius-xl:      20px;

  /* ── Shadow ── */
  --shadow-card:    0 4px 24px rgba(0, 0, 0, 0.3), 0 1px 4px rgba(0, 0, 0, 0.2);
  --shadow-glow:    0 0 20px rgba(59, 130, 246, 0.15);
}

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

/* ═══ HEADER ═══ */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.logo svg {
  color: var(--accent-blue);
}

/* ── Vehicle Selector ── */
#vehicle-selector {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 36px 8px 14px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238899b4' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  min-width: 220px;
  transition: border-color 0.2s;
}

#vehicle-selector:hover {
  border-color: var(--border-hover);
}

#vehicle-selector:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ── Status Badge ── */
.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-badge.online {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-green);
}

.status-badge.offline {
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-red);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.status-badge.offline .status-dot {
  animation: none;
  opacity: 0.5;
}

/* ── Buttons ── */
.btn-primary {
  background: var(--gradient-blue);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ghost:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--bg-card);
}

.btn-danger {
  background: var(--gradient-red);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}

/* ═══ MAIN ═══ */
#dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 20px;
  text-align: center;
}

.empty-state h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 400px;
}

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.3s;
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-header h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tag {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 4px 10px;
  border-radius: 20px;
  font-family: 'SF Mono', monospace;
}

/* ── Vehicle Info ── */
.vehicle-meta {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.meta-value {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ═══ METRICS ROW ═══ */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  opacity: 0;
  transition: opacity 0.3s;
}

.metric-card:hover::before {
  opacity: 1;
}

.metric-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.speed-icon { color: var(--accent-cyan); }
.odo-icon { color: var(--accent-blue); }
.fuel-icon { color: var(--accent-green); }
.rpm-icon { color: var(--accent-orange); }
.temp-icon { color: var(--accent-red); }
.volt-icon { color: var(--accent-purple); }

.metric-card:nth-child(1)::before { background: var(--gradient-blue); }
.metric-card:nth-child(2)::before { background: var(--accent-blue); }
.metric-card:nth-child(3)::before { background: var(--gradient-green); }
.metric-card:nth-child(4)::before { background: var(--gradient-orange); }
.metric-card:nth-child(5)::before { background: var(--gradient-red); }
.metric-card:nth-child(6)::before { background: var(--accent-purple); }

.metric-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
}

.metric-data {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.metric-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.metric-unit {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.metric-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Fuel bar */
.fuel-bar-container {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}

.fuel-bar {
  height: 100%;
  background: var(--gradient-green);
  border-radius: 2px;
  transition: width 1s ease;
}

/* ═══ CONTROLS ROW ═══ */
.controls-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

@media (max-width: 768px) {
  .controls-row {
    grid-template-columns: 1fr;
  }
}

/* ── Door Diagram ── */
.car-diagram {
  display: flex;
  justify-content: center;
  padding: 10px 0;
}

.car-body {
  position: relative;
  width: 200px;
  height: 320px;
}

.car-outline {
  position: relative;
  width: 100%;
  height: 100%;
}

.car-svg {
  width: 100%;
  height: 100%;
}

.door-indicator {
  position: absolute;
  width: 40px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  cursor: default;
  transition: all 0.4s;
  border: 2px solid;
}

.door-indicator.closed {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.door-indicator.open {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--accent-red);
  color: var(--accent-red);
  animation: door-pulse 1.5s infinite;
}

@keyframes door-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 0 12px 2px rgba(239, 68, 68, 0.2); }
}

/* Door positions on the car diagram */
.door-fl { left: -8px;  top: 110px; }
.door-fr { right: -8px; top: 110px; }
.door-rl { left: -8px;  top: 180px; }
.door-rr { right: -8px; top: 180px; }
.door-trunk { left: 50%; bottom: 12px; transform: translateX(-50%); width: 55px; }
.door-hood  { left: 50%; top: 18px;  transform: translateX(-50%); width: 50px; }

/* Lock badge */
.lock-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.lock-badge.locked {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-green);
}

.lock-badge.unlocked {
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-orange);
}

/* ── Control Buttons ── */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.control-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}

.control-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.3s;
  border-radius: inherit;
}

.control-btn:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  color: var(--text-primary);
}

.control-btn:active {
  transform: translateY(0) scale(0.97);
}

.control-btn.loading {
  pointer-events: none;
  opacity: 0.6;
}

.control-btn.loading .control-icon {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.lock-btn:hover { border-color: var(--accent-green); box-shadow: 0 0 16px rgba(16, 185, 129, 0.15); }
.unlock-btn:hover { border-color: var(--accent-orange); box-shadow: 0 0 16px rgba(245, 158, 11, 0.15); }
.trunk-btn:hover { border-color: var(--accent-cyan); box-shadow: 0 0 16px rgba(6, 182, 212, 0.15); }
.signal-btn:hover { border-color: var(--accent-orange); box-shadow: 0 0 16px rgba(245, 158, 11, 0.15); }
.immo-btn:hover { border-color: var(--accent-red); box-shadow: 0 0 16px rgba(239, 68, 68, 0.15); }
.refresh-btn:hover { border-color: var(--accent-blue); box-shadow: 0 0 16px rgba(59, 130, 246, 0.15); }

.lock-btn:hover .control-icon { color: var(--accent-green); }
.unlock-btn:hover .control-icon { color: var(--accent-orange); }
.trunk-btn:hover .control-icon { color: var(--accent-cyan); }
.signal-btn:hover .control-icon { color: var(--accent-orange); }
.immo-btn:hover .control-icon { color: var(--accent-red); }
.refresh-btn:hover .control-icon { color: var(--accent-blue); }

.control-icon {
  transition: color 0.25s, transform 0.3s;
}

/* ═══ MAP ═══ */
.map-card {
  margin-top: 16px;
}

.map-controls {
  display: flex;
  gap: 6px;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.map-container {
  height: 400px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

/* Dark map tiles filter */
.map-container .leaflet-tile-pane {
  filter: brightness(0.7) contrast(1.1) saturate(0.6) hue-rotate(180deg) invert(1);
}

.map-container .leaflet-control-zoom a {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}

.map-container .leaflet-control-attribution {
  background: rgba(10, 14, 23, 0.8) !important;
  color: var(--text-muted) !important;
  font-size: 10px;
}

.map-container .leaflet-control-attribution a {
  color: var(--text-muted) !important;
}

/* Custom car marker */
.car-marker {
  background: none;
  border: none;
}

.car-marker-inner {
  width: 36px;
  height: 36px;
  background: var(--gradient-blue);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.5), 0 2px 8px rgba(0,0,0,0.3);
  border: 3px solid white;
  animation: marker-pulse 2s infinite;
}

@keyframes marker-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.5), 0 2px 8px rgba(0,0,0,0.3); }
  50% { box-shadow: 0 0 30px rgba(59, 130, 246, 0.7), 0 2px 8px rgba(0,0,0,0.3); }
}

/* ═══ TRIP HISTORY ═══ */
.trips-card {
  margin-top: 16px;
}

.trips-container {
  position: relative;
}

.trips-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.trips-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.trip-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.25s;
}

.trip-item:hover {
  border-color: var(--accent-blue);
  background: var(--bg-card-hover);
  transform: translateX(4px);
}

.trip-route-line {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.trip-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--accent-green);
  background: transparent;
}

.trip-dot.end {
  border-color: var(--accent-red);
}

.trip-line {
  width: 2px;
  height: 20px;
  background: var(--border-hover);
}

.trip-info {
  flex: 1;
  min-width: 0;
}

.trip-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.trip-route {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.trip-stats {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
}

.trip-stat {
  text-align: right;
}

.trip-stat-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.trip-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.trip-active-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-green);
  background: rgba(16, 185, 129, 0.12);
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
}

/* ── Trip Detail ── */
.trip-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.trip-detail-header h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.trip-detail-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.trip-detail-stat {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.trip-detail-stat .stat-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
}

.trip-detail-stat .stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.trip-map-container {
  height: 350px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  z-index: 1;
}

.trip-map-container .leaflet-tile-pane {
  filter: brightness(0.7) contrast(1.1) saturate(0.6) hue-rotate(180deg) invert(1);
}

.trip-map-container .leaflet-control-zoom a {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}

.trip-map-container .leaflet-control-attribution {
  background: rgba(10, 14, 23, 0.8) !important;
  color: var(--text-muted) !important;
  font-size: 10px;
}

@media (max-width: 600px) {
  .trip-detail-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .trip-stats {
    gap: 10px;
  }
  .map-container,
  .trip-map-container {
    height: 280px;
  }
}

/* ═══ FLAGS ═══ */
.flags-card {
  margin-top: 16px;
}

.flags-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.flag-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.3s;
}

.flag-item.active {
  color: var(--accent-green);
  border-color: rgba(16, 185, 129, 0.25);
  background: rgba(16, 185, 129, 0.06);
}

.flag-item.warning {
  color: var(--accent-orange);
  border-color: rgba(245, 158, 11, 0.25);
  background: rgba(245, 158, 11, 0.06);
}

.flag-icon {
  font-size: 16px;
  line-height: 1;
}

/* ═══ COMMAND SECTION ═══ */
.command-card {
  margin-top: 16px;
}

.command-input-row {
  display: flex;
  gap: 10px;
}

.command-input-row input {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

.command-input-row input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.command-input-row input::placeholder {
  color: var(--text-muted);
}

.command-log {
  margin-top: 12px;
  max-height: 200px;
  overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.8;
}

.command-log .log-entry {
  padding: 4px 8px;
  border-radius: 4px;
  display: flex;
  gap: 8px;
}

.command-log .log-entry:nth-child(odd) {
  background: rgba(255, 255, 255, 0.02);
}

.log-time {
  color: var(--text-muted);
  flex-shrink: 0;
}

.log-cmd {
  color: var(--accent-cyan);
}

.log-resp {
  color: var(--accent-green);
}

.log-err {
  color: var(--accent-red);
}

/* ═══ TOAST ═══ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  font-size: 14px;
  font-weight: 500;
  min-width: 280px;
  animation: toast-in 0.35s ease-out;
  backdrop-filter: blur(12px);
}

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error   { border-left: 3px solid var(--accent-red); }
.toast.info    { border-left: 3px solid var(--accent-blue); }

.toast.removing {
  animation: toast-out 0.3s ease-in forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(60px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateX(60px); }
}

/* ═══ CONFIRM DIALOG ═══ */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fade-in 0.2s;
}

.confirm-overlay.hidden {
  display: none;
}

.confirm-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
}

.confirm-dialog h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.confirm-dialog p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ═══ UTILITIES ═══ */
.hidden { display: none !important; }

/* ═══ RESPONSIVE ═══ */
@media (max-width: 600px) {
  #app-header {
    padding: 0 12px;
    flex-wrap: wrap;
    height: auto;
    padding-block: 10px;
    gap: 8px;
  }

  .header-center {
    order: 3;
    width: 100%;
  }

  #vehicle-selector {
    width: 100%;
    min-width: unset;
  }

  #dashboard {
    padding: 12px;
  }

  .metrics-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .controls-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ═══ ACTION HISTORY ═══ */
.history-container {
  max-height: 300px;
  overflow-y: auto;
  border-radius: 8px;
  background: var(--surface);
}

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

.history-table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  backdrop-filter: blur(5px);
  z-index: 10;
}

.history-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.history-table tr:hover td {
  background: var(--surface-hover);
}

.history-action {
  font-weight: 600;
  color: var(--primary);
}

.history-user {
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-user-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--surface-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
}

.history-state {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.history-empty {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
  font-style: italic;
}

/* ═══ SCROLLBAR ═══ */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ═══ LOGIN ═══ */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 23, 0.95);
  backdrop-filter: blur(10px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s;
}

.login-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.login-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.login-card h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.login-card p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.login-card input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: white;
  font-size: 16px;
  margin-bottom: 16px;
  transition: border-color 0.2s;
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.login-card button {
  width: 100%;
  padding: 14px;
}

.login-error {
  color: var(--accent-red);
  font-size: 13px;
  margin-top: 12px;
}

/* ═══ MOBILE RESPONSIVENESS IMPROVEMENTS ═══ */
@media (max-width: 768px) {
  #app-header {
    flex-direction: column;
    padding: 16px;
    height: auto;
    gap: 12px;
  }
  
  .header-left, .header-center, .header-right {
    width: 100%;
    justify-content: center;
  }
  
  .header-center {
    order: 3;
    padding: 0;
  }
  
  #vehicle-selector {
    width: 100%;
  }

  .dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  
  .controls-row {
    grid-template-columns: 1fr;
  }
  
  .door-card, .controls-card {
    width: 100%;
  }
  
  .metrics-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .controls-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .flags-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .map-container, .trip-map-container {
    height: 320px;
  }
  
  .login-card {
    width: 90%;
    padding: 24px;
    margin: 20px;
  }
}

@media (max-width: 480px) {
  .metrics-row,
  .controls-grid,
  .flags-grid,
  .trip-detail-stats {
    grid-template-columns: 1fr;
  }
  
  .map-container, .trip-map-container {
    height: 250px;
  }
  
  /* Make car diagram slightly smaller for very small phones */
  .car-body {
    transform: scale(0.8);
  }
}
