/* Reset basique */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #f4f6f8;
}

/* Layout principal */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* Sidebar à gauche */
.sidebar {
  width: 360px;
  min-width: 300px;
  height: 100%;
  background-color: #ffffff;
  border-right: 1px solid #e2e8f0;
  overflow-y: auto;
  padding: 16px;
  z-index: 1000;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

.logout-button {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  margin-bottom: 14px;
  padding: 7px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  background: #ffffff;
  color: #475569;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  transition: border-color 160ms ease, color 160ms ease;
}

.logout-button:hover {
  border-color: #3b82f6;
  color: #1e293b;
}

.logout-button:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.25);
  outline-offset: 2px;
}

.vehicle-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Cartes des véhicules */
.vehicle-card {
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.vehicle-card:hover {
  background-color: #ffffff;
  border-color: #3b82f6;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.12);
  transform: translateY(-2px);
}

/* En-tête des cartes */
.vehicle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.vehicle-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: #1e293b;
}

.vehicle-title i {
  margin-right: 6px;
  color: #475569;
}

/* Badges de statut */
.status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
}

.status-active {
  background-color: #dcfce7;
  color: #15803d;
}

.status-stopped {
  background-color: #fef3c7;
  color: #b45309;
}

.status-maintenance {
  background-color: #fee2e2;
  color: #b91c1c;
}

/* Informations véhicule */
.vehicle-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: #64748b;
}

.vehicle-info i {
  width: 16px;
  color: #94a3b8;
}

/* Zone Carte (OpenStreetMap) */
.map-container {
  flex: 1;
  height: 100%;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
}

/* Page de connexion */
.login-page {
  min-height: 100vh;
  height: auto;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eaf0ee;
  color: #17332f;
}

.login-panel {
  width: min(100%, 440px);
  padding: 40px;
  background: #ffffff;
  border: 1px solid #d5e0dc;
  border-top: 4px solid #19745f;
  box-shadow: 0 18px 48px rgba(23, 51, 47, 0.1);
  animation: login-enter 350ms ease-out both;
}

.login-brand {
  margin-bottom: 32px;
  color: #19745f;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-panel h1 {
  margin-bottom: 8px;
  color: #17332f;
  font-size: 1.8rem;
}

.login-description {
  margin-bottom: 28px;
  color: #61716d;
  font-size: 0.95rem;
}

.login-form {
  display: grid;
  gap: 18px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: #29423e;
  font-size: 0.9rem;
  font-weight: 600;
}

.login-form input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #c8d5d1;
  border-radius: 4px;
  background: #fbfcfc;
  color: #17332f;
  font: inherit;
}

.password-field {
  position: relative;
  display: block;
}

.password-control {
  display: grid;
  gap: 7px;
}

.password-field input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #61716d;
  cursor: pointer;
}

.password-toggle:hover {
  background: #edf3f1;
  color: #17332f;
}

.password-toggle:focus-visible {
  outline: 3px solid rgba(25, 116, 95, 0.25);
}

.login-form input:focus {
  outline: 3px solid rgba(25, 116, 95, 0.18);
  border-color: #19745f;
}

.login-form > button {
  min-height: 48px;
  margin-top: 4px;
  border: 0;
  border-radius: 4px;
  background: #19745f;
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition: background-color 160ms ease;
}

.login-form > button:hover {
  background: #125846;
}

.login-form > button:focus-visible {
  outline: 3px solid rgba(25, 116, 95, 0.35);
  outline-offset: 3px;
}

.login-error {
  min-height: 1.25em;
  color: #ae3434;
  font-size: 0.9rem;
}

@keyframes login-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
  .login-page { padding: 16px; }
  .login-panel { padding: 28px 22px; }
}

/* Adaptabilité Mobile */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column-reverse;
  }
  
  .sidebar {
    width: 100%;
    height: 40vh;
  }
  
  .map-container {
    height: 60vh;
  }
}

/* Interface de suivi connectée */
.app-container {
  background: #edf2ef;
}

.sidebar {
  display: flex;
  flex-direction: column;
  width: 355px;
  min-width: 320px;
  padding: 0;
  border-right: 1px solid #d7dfda;
  box-shadow: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #e7ece8;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.header-actions .refresh-button { flex: 1; }

.header-actions .logout-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 0 0 132px;
  width: 132px;
  min-width: 132px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid #d7e1db;
  background: #fff;
  color: #365d4e;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
}

.header-actions .logout-button:hover { background: #edf5f0; }

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  min-width: 38px;
  margin: 0;
  padding: 0;
  border-radius: 3px;
  color: #5e7069;
}

.sidebar-tools {
  padding: 18px 16px 13px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid #dbe3de;
  background: #f9fbf9;
  color: #81918a;
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: #203b33;
  font: inherit;
  font-size: 0.85rem;
}

.search-field:focus-within {
  border-color: #438b75;
  outline: 2px solid rgba(67, 139, 117, 0.16);
}

.fleet-summary {
  display: flex;
  gap: 28px;
  padding: 17px 2px 4px;
}

.fleet-summary div {
  display: grid;
  gap: 2px;
}

.fleet-summary strong {
  color: #203a33;
  font-size: 1.15rem;
}

.fleet-summary span {
  color: #74847d;
  font-size: 0.75rem;
}

.vehicle-list {
  flex: 1;
  gap: 0;
  overflow-y: auto;
  padding: 0 12px;
}

.vehicle-card {
  display: block;
  width: 100%;
  padding: 14px 9px;
  border: 0;
  border-top: 1px solid #e7ece8;
  border-radius: 0;
  background: #fff;
  text-align: left;
  transform: none;
}

.vehicle-card:hover {
  border-color: #cddbd3;
  background: #f6faf7;
  box-shadow: none;
}

.vehicle-card.is-selected {
  background: #edf5f0;
  box-shadow: inset 3px 0 #18735c;
}

.vehicle-card-top {
  display: flex;
  align-items: center;
  gap: 9px;
}

.vehicle-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  background: #edf4f0;
  color: #347863;
}

.vehicle-title {
  min-width: 0;
  overflow: hidden;
  color: #253d35;
  font-size: 0.87rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  flex: 0 0 auto;
  padding: 3px 6px;
  border-radius: 2px;
  font-size: 0.65rem;
}

.status-active {
  background: #e3f2e9;
  color: #26714c;
}

.status-outside {
  background: #fae9e2;
  color: #a94c33;
}

.vehicle-details {
  display: grid;
  gap: 6px;
  margin: 10px 0 0 39px;
  color: #718079;
  font-size: 0.74rem;
}

.vehicle-details span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.vehicle-details i {
  width: 12px;
  color: #91a099;
}

.empty-state {
  padding: 22px 10px;
  color: #718079;
  font-size: 0.85rem;
  line-height: 1.5;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 9px 17px;
  border-top: 1px solid #e7ece8;
  color: #708078;
  font-size: 0.72rem;
}

.service-indicator,
.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #d49a38;
}

.service-indicator.is-online { background: #25835f; }
.service-indicator.is-offline { background: #c6533d; }

.map-container {
  min-width: 0;
  background: #e9efeb;
}

#map {
  position: absolute;
  inset: 0;
}

.refresh-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid #d7e1db;
  border-radius: 3px;
  background: #fff;
  color: #365d4e;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
}

.refresh-button:hover { background: #edf5f0; }
.refresh-button:disabled { cursor: wait; opacity: 0.7; }
.refresh-button.is-loading i { animation: spin 850ms linear infinite; }

.map-legend {
  position: absolute;
  z-index: 500;
  right: 16px;
  bottom: 17px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid #dce4df;
  background: rgba(255, 255, 255, 0.96);
  color: #52665d;
  font-size: 0.72rem;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot.in-zone { background: #17816b; }
.legend-dot.out-zone { background: #d05b3f; }
.legend-line { width: 14px; height: 2px; background: #247c78; }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 768px) {
  .app-container { flex-direction: column-reverse; }
  .sidebar {
    width: 100%;
    min-width: 0;
    height: 43vh;
    min-height: 230px;
    border-top: 1px solid #d7dfda;
    border-right: 0;
  }
  .sidebar-header { padding: 12px 16px; }
  .sidebar-tools { padding: 10px 14px 7px; }
  .fleet-summary { gap: 20px; padding-top: 10px; }
  .vehicle-list { padding: 0 10px; }
  .map-container { width: 100%; height: 57vh; min-height: 260px; }
  .map-legend { right: 10px; bottom: 10px; gap: 8px 12px; }
  .sidebar-footer { min-height: 38px; }
}

@media (max-width: 420px) {
  .map-legend { left: 10px; right: 10px; justify-content: center; font-size: 0.65rem; }
}