/**
 * Smart Traffic Ambulance — Modern Responsive Stylesheet
 */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f1f5f9;
  color: #0f172a;
  min-height: 100vh;
}

.container {
  width: 96%;
  max-width: 1200px;
  margin: 20px auto;
  background: #ffffff;
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

/* =====================================================
   HEADER
   ===================================================== */
header.main-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e2e8f0;
}

.header-icon {
  font-size: 34px;
  background: #fee2e2;
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.2);
}

header h1 {
  font-size: 24px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.5px;
}

header p {
  color: #64748b;
  font-size: 13px;
  margin-top: 2px;
}

/* =====================================================
   STATUS CARDS
   ===================================================== */
.status-section {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.status-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.status-title {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  margin-bottom: 6px;
}

.status {
  font-weight: 700;
  font-size: 15px;
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
}

.stopped {
  background: #f1f5f9;
  color: #64748b;
}

.connecting {
  background: #fef3c7;
  color: #d97706;
}

.live {
  background: #dcfce7;
  color: #15803d;
}

/* =====================================================
   DATA METRICS
   ===================================================== */
.data-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.data-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.data-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  margin-bottom: 4px;
}

.data-card strong {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* =====================================================
   DESTINATION CONTROLS
   ===================================================== */
.destination-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 20px;
}

.section-heading h2 {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 4px;
}

.section-heading p {
  color: #64748b;
  font-size: 13px;
  margin-bottom: 12px;
}

.destination-controls {
  display: flex;
  gap: 12px;
}

select {
  flex: 1;
  padding: 12px 14px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  background: white;
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

select:focus {
  border-color: #2563eb;
}

.route-button {
  background: #2563eb;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.route-button:hover:not(:disabled) {
  background: #1d4ed8;
}

.route-button:active {
  transform: scale(0.98);
}

.route-button:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

/* =====================================================
   MAP CONTAINER & LEGEND
   ===================================================== */
.map-section {
  margin-bottom: 12px;
}

#map {
  width: 100%;
  height: 480px;
  min-height: 480px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  background: #f8fafc;
}

.legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
  margin: 12px 0 20px;
  font-size: 12px;
  color: #475569;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-marker {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  display: inline-block;
}

.legend-junction {
  background: #475569;
}

.legend-ambulance {
  background: #dc2626;
}

.legend-hospital {
  background: #7b1fa2;
}

.legend-route {
  width: 24px;
  height: 5px;
  background: #2563eb;
  border-radius: 2px;
  display: inline-block;
}

/* =====================================================
   ROUTE METRICS
   ===================================================== */
.route-section {
  margin-bottom: 24px;
}

.route-section h2 {
  font-size: 17px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 12px;
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.route-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.route-card-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 4px;
}

.route-card strong {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

/* =====================================================
   JUNCTION SEQUENCE BADGES
   ===================================================== */
.sequence-section {
  margin-bottom: 24px;
}

.junction-sequence {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  min-height: 54px;
}

.sequence-item {
  background: #2563eb;
  color: white;
  padding: 6px 12px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sequence-arrow {
  font-size: 16px;
  font-weight: 800;
  color: #94a3b8;
}

.sequence-hospital {
  background: #7b1fa2;
  color: white;
  padding: 6px 12px;
  border-radius: 16px;
  font-weight: 700;
  font-size: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* =====================================================
   VIRTUAL ARDUINO SERIAL MONITOR
   ===================================================== */
.serial-section {
  margin-bottom: 24px;
}

.serial-console {
  background: #090d16;
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 12px 14px;
  height: 180px;
  overflow-y: auto;
  color: #cbd5e1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
}

/* =====================================================
   BUTTONS & MESSAGES
   ===================================================== */
.button-section {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

button {
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

button:active {
  transform: scale(0.98);
}

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

.start-button {
  background: #16a34a;
  color: white;
}

.start-button:hover:not(:disabled) {
  background: #15803d;
}

.stop-button {
  background: #dc2626;
  color: white;
}

.stop-button:hover:not(:disabled) {
  background: #b91c1c;
}

.message {
  margin-top: 20px;
  padding: 12px 16px;
  background: #f1f5f9;
  border-left: 4px solid #2563eb;
  border-radius: 6px;
  color: #334155;
  font-size: 13px;
  font-weight: 500;
}

footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
  color: #94a3b8;
  font-size: 12px;
}

/* =====================================================
   RESPONSIVE DESIGN (Mobile & Tablet)
   ===================================================== */
@media (max-width: 768px) {
  .container {
    width: 100%;
    margin: 0;
    border-radius: 0;
    padding: 16px;
  }

  .status-section {
    grid-template-columns: 1fr;
  }

  .destination-controls {
    flex-direction: column;
  }

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

  #map {
    height: 380px;
    min-height: 380px;
  }

  .button-section button {
    width: 100%;
  }

  footer {
    flex-direction: column;
    gap: 6px;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .route-grid {
    grid-template-columns: 1fr;
  }
}
