/* ===== Variables ===== */
:root {
  --navy: #1a2332;
  --navy-light: #243044;
  --navy-dark: #121a27;
  --blue: #3b82f6;
  --blue-hover: #2563eb;
  --blue-light: #dbeafe;
  --green: #22c55e;
  --orange: #f59e0b;
  --red: #ef4444;
  --sidebar-width: 250px;
  --topbar-height: 60px;

  /* Grayscale */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Transition */
  --transition: 0.2s ease;
}

/* ===== Base ===== */
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--gray-100);
  margin: 0;
  min-height: 100vh;
  color: var(--gray-800);
  font-size: 0.925rem;
}

.font-mono {
  font-family: 'JetBrains Mono', monospace;
}

a {
  transition: color var(--transition);
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-dark) 100%);
  color: #fff;
  z-index: 1000;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
  color: #fff;
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-brand i {
  color: var(--blue);
}

.sidebar-nav {
  padding: 0.5rem 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  margin: 0.1rem 0.75rem;
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition);
}

.sidebar-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-link.active {
  color: #fff;
  background: var(--blue);
  font-weight: 600;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}

.sidebar-link.disabled {
  color: rgba(255, 255, 255, 0.25);
  cursor: not-allowed;
  font-size: 0.8rem;
}

.sidebar-divider {
  border-color: rgba(255, 255, 255, 0.06);
  margin: 0.5rem 1.25rem;
}

.sidebar-section-title {
  display: block;
  padding: 0.5rem 1.25rem 0.25rem;
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

/* ===== Main wrapper ===== */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--topbar-height);
  padding: 0 1.25rem;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: var(--shadow-sm);
}

/* Section title in topbar */
.topbar-section {
  min-width: 0;
}

.topbar-section-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--blue-light);
  color: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.topbar-section-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--gray-800);
  line-height: 1.2;
}

.topbar-section-sub {
  font-size: 0.7rem;
  color: var(--gray-400);
  line-height: 1.2;
}

/* Contextual stats pills */
.topbar-pills {
  border-left: 1px solid var(--gray-200);
  padding-left: 0.75rem;
}

.topbar-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  font-size: 0.72rem;
  white-space: nowrap;
}

.topbar-pill-value {
  font-weight: 700;
  color: var(--navy);
  font-family: 'JetBrains Mono', monospace;
}

.topbar-pill-label {
  color: var(--gray-500);
}

/* Search */
.topbar-search {
  flex: 0 1 360px;
  position: relative;
}

/* Right actions */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Icon button (bell) */
.topbar-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-600);
  font-size: 1.05rem;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.topbar-icon-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
  color: var(--gray-800);
}

.topbar-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--red);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  line-height: 1;
}

/* User button */
.topbar-user-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  background: #fff;
  cursor: pointer;
  transition: all var(--transition);
}

.topbar-user-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 100%);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topbar-user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-800);
  line-height: 1.2;
}

.topbar-user-role {
  font-size: 0.65rem;
  color: var(--gray-400);
  line-height: 1.2;
}

/* ===== Notification dropdown ===== */
.notification-dropdown {
  width: 360px;
  max-height: 420px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
}

.notification-dropdown .dropdown-header {
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  padding: 0.6rem 1rem;
}

.notification-dropdown .dropdown-item {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--gray-50);
  transition: background var(--transition);
}

.notification-dropdown .dropdown-item:hover {
  background: var(--gray-50);
}

/* ===== Search dropdown ===== */
.search-results-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 1050;
  display: none;
}

.search-results-dropdown:not(:empty) {
  display: block;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--gray-50);
  transition: background var(--transition);
}

.search-result-item:hover {
  background: var(--gray-50);
}

.search-result-item .immat {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 0.85rem;
}

/* ===== Breadcrumbs ===== */
.breadcrumb-bar {
  padding: 0.5rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.8rem;
}

.breadcrumb-bar .breadcrumb {
  margin: 0;
  padding: 0;
  background: transparent;
}

.breadcrumb-bar .breadcrumb-item a {
  color: var(--gray-500);
  text-decoration: none;
}

.breadcrumb-bar .breadcrumb-item a:hover {
  color: var(--blue);
}

.breadcrumb-bar .breadcrumb-item.active {
  color: var(--gray-700);
  font-weight: 500;
}

/* ===== Main content ===== */
.main-content {
  padding: 1.5rem;
}

/* ===== Cards ===== */
.card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}

/* ===== Stat cards ===== */
.stat-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}

.stat-card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--gray-500);
  font-weight: 500;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ===== Vehicle header ===== */
.vehicle-header {
  background: var(--navy) !important;
  color: #fff !important;
  border: none;
}

/* ===== Immatriculation plate ===== */
.plaque {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: #fff;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.plaque-lg {
  font-size: 1.4rem;
  padding: 0.4rem 1rem;
}

/* ===== Alert badges ===== */
.badge-expire { background-color: var(--red) !important; color: #fff; }
.badge-urgent { background-color: var(--red) !important; color: #fff; }
.badge-proche { background-color: var(--orange) !important; color: #fff; }
.badge-prevoir { background-color: var(--green) !important; color: #fff; }
.badge-ok { background-color: var(--gray-300) !important; color: var(--gray-700); }

/* Pulse animation for urgent badges */
@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.badge-expire, .badge-urgent {
  animation: badge-pulse 2s ease-in-out infinite;
}

/* ===== Tables ===== */
.table {
  font-size: 0.875rem;
}

.table thead th {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gray-500);
  border-bottom: 2px solid var(--gray-300);
  padding: 0.6rem 0.75rem;
  white-space: nowrap;
}

.table tbody td {
  padding: 0.6rem 0.75rem;
  vertical-align: middle;
}

.table-hover tbody tr {
  cursor: pointer;
  transition: background var(--transition);
}

.table-hover tbody tr:hover {
  background: var(--gray-50) !important;
}

/* Fuel type left border */
.fuel-diesel { border-left: 3px solid var(--blue); }
.fuel-essence { border-left: 3px solid var(--green); }
.fuel-electrique { border-left: 3px solid var(--orange); }

/* ===== Sort links ===== */
.sort-link {
  text-decoration: none;
  color: var(--gray-500);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.sort-link:hover {
  color: var(--blue);
}

.sort-link i {
  font-size: 0.65rem;
}

/* ===== Tabs ===== */
.nav-tabs {
  border-bottom: 2px solid var(--gray-200);
}

.nav-tabs .nav-link {
  color: var(--gray-500);
  font-weight: 500;
  font-size: 0.875rem;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.6rem 1rem;
  margin-bottom: -2px;
  transition: all var(--transition);
}

.nav-tabs .nav-link:hover {
  color: var(--blue);
  border-bottom-color: var(--gray-300);
}

.nav-tabs .nav-link.active {
  color: var(--blue);
  font-weight: 600;
  border-bottom-color: var(--blue);
  background: transparent;
}

/* ===== Buttons ===== */
.btn {
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.875rem;
  transition: all var(--transition);
}

.btn-primary {
  box-shadow: 0 1px 3px rgba(59, 130, 246, 0.2);
}

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

.btn-success {
  box-shadow: 0 1px 3px rgba(34, 197, 94, 0.2);
}

.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(34, 197, 94, 0.3);
}

/* Loading state */
.btn-submit.is-loading {
  pointer-events: none;
  opacity: 0.7;
}

.btn-submit.is-loading .bi {
  display: none;
}

.btn-submit.is-loading::before {
  content: '';
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spinner 0.6s linear infinite;
  margin-right: 0.5rem;
  vertical-align: middle;
}

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

/* ===== Filter bar ===== */
.filter-bar {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

/* ===== Form custom ===== */
.form-control-custom {
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-300);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control-custom:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.15);
}

.form-select {
  border-radius: var(--radius-md);
}

/* ===== Alerts ===== */
.alert {
  border-radius: var(--radius-md);
  border: none;
  font-size: 0.875rem;
}

/* Auto-dismiss transition */
.alert.fade-out {
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

/* ===== Stat cards scroll row (mobile) ===== */
.stat-scroll-row {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 0.25rem;
}

.stat-scroll-row::-webkit-scrollbar {
  display: none;
}

.stat-scroll-row > .stat-scroll-item {
  flex: 0 0 auto;
  min-width: 180px;
}

/* ===== Responsive ===== */
@media (max-width: 767.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .hide-mobile {
    display: none !important;
  }
  .main-content {
    padding: 1rem;
  }
  .stat-card .stat-value {
    font-size: 1.3rem;
  }
  .table {
    font-size: 0.8rem;
  }
  .table thead th {
    font-size: 0.65rem;
  }
  .breadcrumb-bar {
    padding: 0.4rem 1rem;
  }
  /* Topbar mobile */
  .topbar {
    padding: 0 0.75rem;
    gap: 0.5rem;
  }
  .topbar-search {
    flex: 1 1 auto;
  }
  .topbar-user-btn {
    padding: 0.25rem;
    border: none;
  }
  .topbar-icon-btn {
    width: 34px;
    height: 34px;
    border: none;
  }
  /* Stat cards become scrollable on mobile */
  .row.g-3.stat-row-mobile {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0;
    padding-bottom: 0.25rem;
  }
  .row.g-3.stat-row-mobile::-webkit-scrollbar {
    display: none;
  }
  .row.g-3.stat-row-mobile > [class*="col-"] {
    flex: 0 0 200px;
    max-width: 200px;
  }
}

/* ===== Login page ===== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 50%, #0f1419 100%);
}

.login-card {
  background: #fff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 2.5rem;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo h2 {
  color: var(--navy);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.login-logo i {
  font-size: 2.5rem;
  color: var(--blue);
  display: block;
  margin-bottom: 0.5rem;
}

/* ===== List group refinements ===== */
.list-group-item {
  border-color: var(--gray-100);
  transition: background var(--transition);
}

.list-group-item-action:hover {
  background: var(--gray-50);
}

/* ===== Badge refinements ===== */
.badge {
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

/* ===== Scrollbar ===== */
.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

/* ===== Vehicle picker grid ===== */
.vehicule-picker-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  transition: all var(--transition);
  cursor: pointer;
  height: 100%;
}

.vehicule-picker-card:hover {
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green), var(--shadow-md);
  transform: translateY(-2px);
}

.vehicule-picker-card:hover .picker-btn {
  transform: scale(1.1);
}

.picker-btn {
  transition: transform var(--transition);
  pointer-events: none;
}

/* ===== Fuel dots ===== */
.fuel-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.fuel-dot-diesel, .fuel-dot-DIESEL { background: var(--blue); }
.fuel-dot-essence, .fuel-dot-ESSENCE, .fuel-dot-sp95, .fuel-dot-SP95, .fuel-dot-sp98, .fuel-dot-SP98 { background: var(--green); }
.fuel-dot-electrique, .fuel-dot-ELECTRIQUE { background: var(--orange); }
.fuel-dot-hybride, .fuel-dot-HYBRIDE { background: #8b5cf6; }
.fuel-dot-gpl, .fuel-dot-GPL { background: #ec4899; }

/* ===== Search action buttons ===== */
.search-actions {
  opacity: 0;
  transition: opacity var(--transition);
}

.search-result-item:hover .search-actions {
  opacity: 1;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

/* ===== Font weight utility ===== */
.fw-500 { font-weight: 500; }

/* ===== Tooltip ===== */
[data-bs-toggle="tooltip"] {
  cursor: pointer;
}
