/* ======================================== */
/* Components - Cards, inputs, buttons      */
/* ======================================== */

/* CARDS */
.card {
    background: #151922;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid #222;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: 0.15s;
}

.card:hover {
    background: #1a2030;
}

.card.selected {
    border: 1px solid #22c55e;
    box-shadow: 0 0 0 1px #22c55e inset;
}

/* VEHICLE INFO */
.vehicle-left {
    display: flex;
    flex-direction: column;
}

.vehicle-id {
    font-weight: bold;
    font-size: 15px;
}

.vehicle-driver {
    font-size: 13px;
    color: #aaa;
}

.vehicle-ign {
    font-size: 12px;
    color: #888;
}

/* STATUS DOT */
.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.status-green {
    background: #22c55e;
}

.status-red {
    background: #ef4444;
}

/* LIST CARD */
.list-card {
    background: #0e131a;
    border: 1px solid #1f2a37;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-left {
    display: flex;
    flex-direction: column;
}

.list-title {
    font-weight: 600;
    font-size: 14px;
}

.list-sub {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 3px;
}

.list-actions {
    display: flex;
    gap: 6px;
}

/* ICON BUTTON */
.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid #263041;
    background: #111827;
    color: #9ca3af;
    cursor: pointer;
    transition: 0.2s;
}

.icon-btn:hover {
    background: #1f2937;
    color: #fff;
}

.icon-btn.danger {
    border: 1px solid #dc2626;
    color: #dc2626;
}

.icon-btn.danger:hover {
    background: #dc2626;
    color: #fff;
}

/* BUTTON COLORS */
.btn-blue {
    background: #2563eb;
    color: #fff;
}

.btn-green {
    background: #16a34a;
    color: #fff;
}

.btn-red {
    background: #dc2626;
    color: #fff;
}

.btn-orange {
    background: #ea580c;
    color: #fff;
}

.btn-gray {
    background: #374151;
    color: #fff;
}

/* STAT */
.stat {
    background: #0e131a;
    border: 1px solid #1f2a37;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    color: #9ca3af;
}

.stat b {
    color: #fff;
    margin-left: 4px;
}

/* HISTORY VEHICLE */
.history-vehicle {
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 6px;
    background: #111827;
    cursor: pointer;
    font-size: 14px;
}

.history-vehicle:hover {
    background: #1f2937;
}

.history-vehicle.selected {
    background: #2563eb;
    color: #fff;
}

/* HISTORY TITLE */
.history-title {
    margin-top: 16px;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #9ca3af;
    border-bottom: 1px solid #1f2a37;
    padding-bottom: 6px;
}

/* SECTION TITLE */
.section-title {
    margin-top: 18px;
    margin-bottom: 10px;
    font-size: 15px;
    font-weight: bold;
    color: #e6e6e6;
    border-bottom: 1px solid #1f2228;
    padding-bottom: 6px;
}

/* FORM SECTION */
.form-section {
    margin-bottom: 22px;
}

.form-title {
    font-size: 15px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #e6e6e6;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

/* INPUT DARK */
.input-dark {
    width: 100%;
    box-sizing: border-box;
    background: #0e131a;
    border: 1px solid #263041;
    border-radius: 8px;
    padding: 10px;
    color: #fff;
    font-size: 14px;
}

.input-dark::placeholder {
    color: #6b7280;
}

/* CHECKBOX ROW */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0 10px 0;
    font-size: 13px;
    color: #9ca3af;
}

/* BTN PRIMARY */
.btn-primary {
    width: 100%;
    background: #2563eb;
    border: none;
    border-radius: 8px;
    padding: 11px;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.btn-primary:hover {
    background: #1d4ed8;
}

/* FIELD PROPORTIONS */
.field-plate {
    flex: 0.6;
}

.field-name {
    flex: 1.4;
}

.field-driver {
    flex: 1.4;
}

.field-rfid {
    flex: 0.8;
}

/* TOGGLE LIMIT */
.toggle-limit {
    width: 100%;
    height: 42px;
    background: transparent;
    border: 1px solid #dc2626;
    color: #dc2626;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.toggle-limit.active {
    background: #16a34a;
    border: 1px solid #16a34a;
    color: #fff;
}

.limit-toggle {
    width: 100%;
    height: 42px;
    background: transparent;
    border: 1px solid #dc2626;
    color: #dc2626;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.limit-toggle.active {
    border: 3px solid #22c55e;
    color: #22c55e;
    box-shadow: 0 0 0 2px #22c55e inset;
}

/* SPEED CHART */
#speedChart {
    margin-top: 10px;
}

/* FIELD INPUTS (for history) */
.field input {
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    padding: 0 10px;
    font-size: 14px;
}

.plate-field {
    width: 130px;
}

.plate-field input {
    font-weight: 600;
    letter-spacing: 1px;
}

.date-field {
    padding: 0 6px;
}

.date-field .icon {
    font-size: 14px;
    margin-left: 6px;
    opacity: 0.7;
}

.date-field input {
    width: 120px;
}

.btn-icon:hover {
    background: #1d4ed8;
}

.time-field input {
    width: 90px;
}

/* ======================================== */
/* Base Utility Classes                        */
/* ======================================== */

.hidden {
  display: none !important;
}

/* Left panel pages */
#page_manage,
#page_list,
#page_telemetry,
#page_history,
#page_reports {
  position: fixed;
  left: 110px;
  top: 50px;
  bottom: 0;
  width: 380px;
  background: #11151b;
  border-right: 1px solid #1f2228;
  overflow-y: auto;
  padding: 15px;
  z-index: 100;
  transition: left 0.3s ease;
}

/* When side panel is open, shift main dashboard */
#mainDashboard.panel-open {
  margin-left: 410px;
}

/* ======================================== */
/* Main Dashboard Layout                      */
/* ======================================== */

#mainDashboard {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 18px;
  gap: 16px;
  overflow: hidden;
  min-height: 0;
}

/* 6 Cards like global dashboard */
.home-cards {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 18px;
  margin-bottom: 16px;
}

.gcard {
  background: #1a1f2e;
  border-radius: 14px;
  padding: 18px;
  border: 1px solid #2d3748;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.gicon {
  font-size: 22px;
  opacity: 0.8;
}

.gtitle {
  font-size: 12px;
  color: #9ca3af;
  letter-spacing: 1px;
}

.gvalue {
  font-size: 32px;
  font-weight: bold;
  margin-top: 4px;
  color: #fff;
}

.gsub {
  font-size: 12px;
  color: #6b7280;
}

.dash-middle {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.map-area {
  min-height: 400px;
  border-radius: 14px;
  overflow: hidden;
  background: #1a1f2e;
  position: relative;
  border: 1px solid #2d3748;
  padding: 20px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.map-area h2 {
  color: #00d4ff;
  margin: 0 0 15px 0;
  font-size: 1.2rem;
}

.map-area #map {
  flex: 1;
  min-height: 0;
  border-radius: 8px;
  background: #0f1419;
  position: relative;
}

.map-area .legend {
  display: flex;
  gap: 15px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.map-area .legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: #9ca3af;
}

.map-area .legend-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.map-area .last-update {
  font-size: 0.75rem;
  color: #6b7280;
  margin-top: 8px;
}

.map-header {
  display: none;
}

#map {
  position: relative;
  height: 100%;
}

.list-area {
  background: #1a1f2e;
  border-radius: 14px;
  padding: 10px 10px 16px 10px;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 100%;
  box-sizing: border-box;
}

/* Vehicle list styling */
.list-area #active_list {
  padding: 0;
  margin: 0;
  list-style: none;
}

.vehicle-card {
  background: #111827;
  border-radius: 12px;
  padding: 14px;
  border: 1px solid #1f2a37;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: 0.2s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

.vehicle-card:hover {
  background: #1f2937;
}

.vehicle-info {
  display: flex;
  flex-direction: column;
}

.vehicle-plate {
  font-weight: bold;
  font-size: 14px;
}

.vehicle-driver {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 2px;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.status-green {
  background: #22c55e;
}

.status-red {
  background: #ef4444;
}

/* ======================================== */
/* MOBILE RESPONSIVE FIXES                   */
/* ======================================== */

/* Mobile - Cards grid becomes scrollable horizontal */
@media (max-width: 1200px) {
  .home-cards {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
  
  .gcard {
    min-width: 120px;
    padding: 14px;
    min-height: 100px;
  }
  
  .gvalue {
    font-size: 24px;
  }
  
  .gtitle {
    font-size: 10px;
  }
}

/* Mobile smaller - 2 columns */
@media (max-width: 768px) {
  .home-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 10px;
  }
  
  .gcard {
    min-width: 140px;
    flex: 1;
    padding: 12px;
    min-height: 90px;
  }
  
  .gicon {
    font-size: 18px;
  }
  
  .gtitle {
    font-size: 9px;
    letter-spacing: 0.5px;
  }
  
  .gvalue {
    font-size: 18px;
  }
  
  .gsub {
    font-size: 10px;
  }
  
  /* Middle section - stack map and list */
  .dash-middle {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 300px;
  }
  
  .map-area {
    height: auto;
    min-height: 300px;
  }
  
  .map-area #map {
    height: 350px;
  }
  
  .list-area {
    max-height: 300px;
  }
  
  /* Sidebar hidden on mobile - use hamburger */
  #sidebar {
    width: 60px;
    padding: 8px;
  }
  
  #sidebar button {
    font-size: 10px;
    height: 40px;
  }
  
  #mainDashboard {
    padding: 10px;
  }
}

/* ======================================== */
/* FLEET MANAGEMENT PAGE                     */
/* ======================================== */

#page_fleet {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0f1115;
  min-height: 0;
}

/* Fleet Tab Bar */
.fleet-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 18px 0 18px;
  border-bottom: 1px solid #1f2228;
  background: #0b0d10;
  flex-shrink: 0;
}

.fleet-tab {
  height: 40px;
  padding: 0 20px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: #9ca3af;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  width: auto;
  transition: 0.2s;
  margin-bottom: -1px;
}

.fleet-tab:hover {
  color: #e6e6e6;
  background: #151922;
}

.fleet-tab.active {
  color: #fff;
  border-bottom: 3px solid #2563eb;
  background: #151922;
}

/* Fleet Content Area */
.fleet-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  padding: 16px 18px;
}

/* Fleet Split Layout */
.fleet-split {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Left column: search + list */
.fleet-col-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  min-height: 0;
}

.fleet-search {
  height: 40px;
  flex-shrink: 0;
  font-size: 14px;
}

.fleet-item-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Fleet Item Card */
.fleet-item-card {
  background: #111827;
  border: 1px solid #1f2a37;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: 0.15s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fleet-item-card:hover {
  background: #1a2435;
  border-color: #2d3f55;
}

.fleet-item-card.selected {
  background: #1e3a5f;
  border-color: #2563eb;
}

.fleet-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fleet-item-title {
  font-weight: 700;
  font-size: 14px;
  color: #e6e6e6;
}

.fleet-item-sub {
  font-size: 12px;
  color: #9ca3af;
}

.fleet-item-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
}

.fleet-badge-green {
  background: #14532d;
  color: #22c55e;
}

.fleet-badge-red {
  background: #450a0a;
  color: #ef4444;
}

.fleet-badge-gray {
  background: #1f2937;
  color: #9ca3af;
}

/* Right column: details */
.fleet-col-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  min-height: 0;
}

/* Fleet Placeholder */
.fleet-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4b5563;
  font-size: 16px;
  flex-direction: column;
  gap: 10px;
  min-height: 300px;
}

.fleet-placeholder-icon {
  font-size: 48px;
  opacity: 0.3;
}

/* Fleet Stat Mini Cards (5 cards per entity) */
.fleet-mini-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  flex-shrink: 0;
}

.fleet-mini-card {
  background: #1a1f2e;
  border: 1px solid #2d3748;
  border-radius: 12px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fleet-mc-icon {
  font-size: 18px;
  opacity: 0.8;
}

.fleet-mc-label {
  font-size: 10px;
  color: #6b7280;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.fleet-mc-value {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}

.fleet-mc-sub {
  font-size: 11px;
  color: #9ca3af;
}

/* Score Badge */
.fleet-score-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1a1f2e;
  border: 1px solid #2d3748;
  border-radius: 12px;
  padding: 14px 18px;
  flex-shrink: 0;
}

.fleet-score-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  flex-shrink: 0;
}

.fleet-score-good {
  background: #14532d;
  color: #22c55e;
  border: 3px solid #22c55e;
}

.fleet-score-ok {
  background: #451a03;
  color: #f97316;
  border: 3px solid #f97316;
}

.fleet-score-bad {
  background: #450a0a;
  color: #ef4444;
  border: 3px solid #ef4444;
}

.fleet-score-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fleet-score-title {
  font-weight: 700;
  font-size: 15px;
  color: #e6e6e6;
}

.fleet-score-sub {
  font-size: 12px;
  color: #9ca3af;
}

/* Fleet Map */
.fleet-map-box {
  background: #1a1f2e;
  border: 1px solid #2d3748;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
}

.fleet-map-header {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #9ca3af;
  border-bottom: 1px solid #2d3748;
}

#fleet_map {
  height: 260px;
  background: #0f1419;
}

/* Fleet Register Tab */
.fleet-register-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-width: 900px;
}

.fleet-form-box {
  background: #111827;
  border: 1px solid #1f2a37;
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fleet-form-box .input-dark {
  margin: 0;
}

.fleet-form-title {
  font-size: 16px;
  font-weight: 700;
  color: #e6e6e6;
  margin-bottom: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid #1f2a37;
}

/* Fleet History Tab */
.fleet-history-sub-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.fleet-htab {
  height: 36px;
  padding: 0 16px;
  background: #111827;
  border: 1px solid #1f2a37;
  border-radius: 8px;
  color: #9ca3af;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: auto;
  transition: 0.2s;
}

.fleet-htab:hover {
  background: #1a2435;
  color: #e6e6e6;
}

.fleet-htab.active {
  background: #1e3a5f;
  border-color: #2563eb;
  color: #fff;
}

.fleet-history-area {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.fleet-hist-sub {
  display: none;
  flex-direction: column;
  gap: 10px;
}

.fleet-hist-sub.active {
  display: flex;
}

/* Fleet vehicle picker in history */
.fleet-vehicle-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.fleet-vpick {
  padding: 6px 12px;
  background: #111827;
  border: 1px solid #1f2a37;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  color: #9ca3af;
  transition: 0.15s;
  width: auto;
}

.fleet-vpick:hover {
  background: #1a2435;
  color: #e6e6e6;
}

.fleet-vpick.selected {
  background: #1e3a5f;
  border-color: #2563eb;
  color: #fff;
}

/* Fleet history result entries */
.fleet-hist-entry {
  background: #111827;
  border: 1px solid #1f2a37;
  border-radius: 10px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.6;
}

.fleet-hist-entry b {
  color: #e6e6e6;
}

.fleet-hist-meta {
  font-size: 11px;
  color: #6b7280;
  margin-top: 4px;
}

/* Fleet Section Title */
.fleet-section-title {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding-bottom: 6px;
  border-bottom: 1px solid #1f2228;
  margin-bottom: 8px;
}

/* Very small mobile */
@media (max-width: 480px) {
  .home-cards {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  
  .gcard {
    min-width: 100px;
    padding: 10px;
  }
  
  .gvalue {
    font-size: 16px;
  }
  
  .gicon {
    font-size: 16px;
  }
  
  .gtitle {
    font-size: 8px;
  }
  
  .map-area h2 {
    font-size: 1rem;
  }
}
