/* =========================
   1. BASE GLOBALE
========================= */
*,
*::before,
*::after {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

body {
  margin: 0;
  background: linear-gradient(135deg, #f5f5f5 0%, #ffffff 100%);
  display: flex;
  min-height: 100vh;
}

/* =========================
   2. SIDEBAR
========================= */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 220px;
  height: 100vh;
  background: linear-gradient(180deg, #111 0%, #1a1a1a 100%);
  color: white;
  padding: 24px;
  border-top-right-radius: 25px;
  border-bottom-right-radius: 25px;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
  overflow-y: auto;
  z-index: 100;
}

.sidebar h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 32px;
  letter-spacing: -0.5px;
}

.sidebar a {
  display: block;
  color: #e0e0e0;
  text-decoration: none;
  font-size: 15px;
  padding: 10px 12px;
  margin: 12px 0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar a:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  padding-left: 16px;
}

/* =========================
   3. MAIN CONTENT
========================= */
.content {
  margin-left: 240px;
  padding: 40px;
  width: 100%;
  max-width: 1600px;
  flex: 1;
}

.section {
  display: none;
  animation: fadeIn 0.5s ease-out;
}

.section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Titres de section */
#cars h1,
#infos h1,
#settings h1,
#chat h1 {
  font-size: 32px;
  font-weight: 700;
  color: #111;
  margin-bottom: 28px;
  letter-spacing: -0.5px;
}

/* =========================
   4. GRILLE DE VOITURES
========================= */
.cars-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  justify-content: flex-start;
}

.cars-grid > .empty-message {
  width: 100%;
  text-align: center;
  color: #999;
  margin-top: 40px;
  font-style: italic;
  font-size: 16px;
}

/* =========================
   5. CARTE VOITURE
========================= */
.car-card {
  position: relative;
  width: 320px;
  height: 240px;
  background: #ddd center / cover no-repeat;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.car-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
}

.car-inner {
  height: 100%;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
}

.car-info-box {
  background: rgba(17, 17, 17, 0.85);
  color: white;
  padding: 14px;
  border-radius: 12px;
  backdrop-filter: blur(8px);
}

.car-info-box h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: white;
}

.car-info-box p {
  margin: 4px 0;
  font-size: 14px;
  color: #e0e0e0;
}

/* Bouton + Ajouter */
.add-car-card {
  background: linear-gradient(135deg, #f5f5f5 0%, #eeeeee 100%);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #ddd;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.add-car-card:hover {
  background: linear-gradient(135deg, #eeeeee 0%, #e0e0e0 100%);
  transform: scale(1.02);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  border-color: #bbb;
}

.add-car-plus {
  font-size: 48px;
  color: #999;
  font-weight: 300;
  transition: color 0.3s ease;
}

.add-car-card:hover .add-car-plus {
  color: #666;
}

/* Gear Menu */
.gear-container {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
}

.gear-btn {
  width: 32px;
  height: 32px;
  cursor: pointer;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
  transition: transform 0.3s ease;
}

.gear-btn:hover {
  transform: rotate(90deg) scale(1.1);
}

.dropdown-menu {
  display: none;
  position: absolute;
  top: 40px;
  right: 0;
  min-width: 130px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  z-index: 10;
}

.gear-container:hover .dropdown-menu,
.dropdown-menu:hover {
  display: block;
}

.dropdown-edit,
.dropdown-delete {
  display: block;
  padding: 10px 14px;
  font-size: 14px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.dropdown-edit { color: #007bff; }
.dropdown-edit:hover { background: #f5f5f5; }
.dropdown-delete { color: #d32f2f; }
.dropdown-delete:hover { background: #fff5f5; }

/* =========================
   6. POPUPS MODALES
========================= */
#popup,
#create-popup,
#popup-delete {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  justify-content: center;
  align-items: center;
  z-index: 9999;
  padding: 20px;
  overflow-y: auto;
  animation: fadeInOverlay 0.3s ease-out;
}

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.popup-content {
  background: white;
  border-radius: 20px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.22);
  overflow: hidden;
  animation: popupSlideUp 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes popupSlideUp {
  from { opacity: 0; transform: translateY(40px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.popup-content h2 {
  margin: 0;
  padding: 24px 28px 0;
  font-size: 24px;
  font-weight: 700;
  color: #111;
  text-align: center;
}

.popup-body {
  padding: 0 28px 24px;
  max-height: 70vh;
  overflow-y: auto;
}

.popup-body label {
  display: block;
  margin-bottom: 16px;
  font-weight: 500;
  color: #333;
  font-size: 14.5px;
}

.popup-body input[type="text"],
.popup-body input[type="number"],
.popup-body input[type="file"],
.popup-body select {
  width: 100%;
  padding: 12px 14px;
  margin-top: 6px;
  border: 1.5px solid #e0e0e0;
  border-radius: 12px;
  font-size: 15px;
  background: #fdfdfd;
  transition: all 0.25s ease;
}

.popup-body input:focus,
.popup-body select:focus {
  outline: none;
  border-color: #007bff;
  background: white;
  box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.12);
}

.popup-footer {
  display: flex;
  gap: 12px;
  padding: 20px 28px;
  background: #f9f9f9;
  border-top: 1px solid #eee;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.popup-footer button {
  flex: 1;
  min-width: 110px;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 14.5px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.popup-footer button[type="submit"] {
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  border: none;
}

.popup-footer button[type="submit"]:hover {
  background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 123, 255, 0.25);
}

.popup-footer button[type="button"] {
  background: #f1f1f1;
  color: #555;
  border: 1.5px solid #ddd;
}

.popup-footer button[type="button"]:hover {
  background: #e8e8e8;
  border-color: #ccc;
  transform: translateY(-1px);
}

#btn-reorder {
  background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
  color: white;
  font-size: 13px;
  padding: 8px 12px;
  margin: 8px 0 16px;
  border-radius: 10px;
}

/* Suppression */
#popup-delete .popup-content h2 { color: #d32f2f; }
#popup-delete .popup-footer button[type="submit"] {
  background: linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%);
}
#popup-delete .popup-footer button[type="submit"]:hover {
  background: linear-gradient(135deg, #b71c1c 0%, #9a0007 100%);
  box-shadow: 0 8px 20px rgba(211, 47, 47, 0.3);
}

/* Images existantes */
#existing-images {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 12px 0;
  padding: 8px 0;
}

.image-thumb {
  position: relative;
  width: 96px;
  height: 96px;
  border: 2px solid #eee;
  border-radius: 14px;
  overflow: hidden;
  background: #f9f9f9;
  cursor: grab;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.25s ease;
}

.image-thumb:hover {
  border-color: #007bff;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 123, 255, 0.18);
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-thumb .delete-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(220, 38, 38, 0.95);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(2px);
}

.image-thumb .delete-btn:hover {
  background: #dc2626;
  transform: scale(1.15);
}

.image-thumb.dragging {
  opacity: 0.6;
  border-style: dashed;
  border-color: #007bff;
  transform: rotate(3deg);
}

.order-badge {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 8px;
  min-width: 18px;
  text-align: center;
}

/* =========================
   7. INFOS UTILISATEUR
========================= */
.label {
  font-weight: 600;
  display: inline-block;
  width: 200px;
  color: #333;
}

.value {
  color: #666;
  font-style: italic;
}

.easter-egg {
  color: #ffb300;
  font-weight: 700;
}

.role {
  margin-top: 20px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #f5f5f5 0%, #eeeeee 100%);
  display: inline-block;
  border-radius: 8px;
  font-weight: 600;
  border-left: 4px solid #007bff;
}

.footer {
  margin-top: 60px;
  text-align: center;
  font-size: 13px;
  color: #999;
  font-weight: 500;
}

/* =========================
   8. RESPONSIVE (≤768px)
========================= */
@media (max-width: 768px) {
  body { flex-direction: column; }

  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    padding: 16px;
    text-align: center;
    border-radius: 0;
  }

  .sidebar h2 { font-size: 20px; margin-bottom: 16px; }
  .sidebar a { display: inline-block; margin: 6px 8px; font-size: 14px; padding: 8px 12px; }

  .content { margin-left: 0; padding: 20px; }

  #cars h1,
  #infos h1,
  #settings h1,
  #chat h1 { font-size: 24px; margin-bottom: 20px; }

  .cars-grid { flex-direction: column; gap: 16px; }
  .car-card, .add-car-card { width: 100%; min-width: 100%; }

  .car-info-box h2 { font-size: 18px; }
  .car-info-box p { font-size: 13px; }

  input, select, button { font-size: 16px; }
  button { padding: 12px; width: 100%; margin: 10px 0; }

  .gear-container { top: 8px; right: 8px; }
  .dropdown-menu { min-width: 100px; font-size: 13px; }

  .image-thumb { width: 80px; height: 80px; }
  .order-badge { font-size: 11px; padding: 1px 4px; }

  /* Popups en bas */
  #popup,
  #create-popup,
  #popup-delete {
    align-items: flex-end;
    padding: 0;
  }

  .popup-content {
    max-width: 100%;
    border-radius: 24px 24px 0 0;
    animation: mobilePopupUp 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  @keyframes mobilePopupUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  .popup-content h2 { padding: 20px 20px 0; font-size: 22px; }
  .popup-body { padding: 0 20px 20px; max-height: 65vh; }
  .popup-footer { padding: 16px 20px; flex-direction: column; }
  .popup-footer button { width: 100%; padding: 14px; font-size: 15px; }

  .popup-handle {
    width: 40px;
    height: 5px;
    background: #ddd;
    border-radius: 3px;
    margin: 12px auto;
  }
}