/* ============================================
   CAR CUSTOMIZER - NFS Unbound Style
   ============================================ */

/* Section principale */
#car-customizer {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100dvh;
  background: #000;
  overflow: hidden;
  z-index: 10;
}

/* Canvas 3D */
#car-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Overlay néon ambiant */
.customizer-ambient {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(152, 25, 20, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(255, 0, 60, 0.08) 0%, transparent 40%);
}

/* Ligne néon au sol (déco) */
.customizer-neon-line {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #981914, #ff0000, #981914, transparent);
  box-shadow: 0 0 20px rgba(152, 25, 20, 0.6), 0 0 60px rgba(152, 25, 20, 0.3);
  z-index: 2;
}

/* Titre section */
.customizer-title {
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  text-align: center;
  pointer-events: none;
}

.customizer-title h2 {
  font-size: var(--fs-3xl);
  font-weight: 900;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, #fff, #981914);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}

.customizer-title p {
  font-size: var(--fs-sm);
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 8px;
}

/* ============================================
   HUD - Specs Display (coin bas-gauche)
   ============================================ */
.hud-specs {
  position: absolute;
  bottom: 40px;
  left: 40px;
  z-index: 10;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(152, 25, 20, 0.3);
  border-radius: 16px;
  padding: 24px;
  min-width: 260px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.hud-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(152, 25, 20, 0.2);
}

.hud-car-name {
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fff;
}

.hud-car-badge {
  font-size: var(--fs-2xs);
  font-weight: 600;
  padding: 3px 8px;
  background: linear-gradient(135deg, #981914, #d42a2a);
  border-radius: 20px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.hud-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-stat-label {
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

.hud-stat-value {
  font-size: var(--fs-lg);
  font-weight: 800;
  color: #fff;
  line-height: 1;
  transition: color 0.3s, text-shadow 0.3s;
}

.hud-stat-value .hud-unit {
  font-size: var(--fs-2xs);
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
  margin-left: 2px;
}

.hud-stat-value.updated {
  color: #ff3030;
  text-shadow: 0 0 12px rgba(255, 0, 0, 0.6);
}

/* Barre grip/drift */
.hud-bar-container {
  grid-column: 1 / -1;
  margin-top: 4px;
}

.hud-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.hud-bar-label {
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

.hud-bar-value {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: #e03e32;
}

.hud-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.hud-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #981914, #ff0000);
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
}

/* ============================================
   TOOLBAR + TIROIR (bas du canvas)
   ============================================ */
.config-toolbar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(152, 25, 20, 0.3);
  border-radius: 16px;
  padding: 6px;
}

.config-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
  font-family: inherit;
}

.config-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.config-tab.active {
  color: #e03e32;
  background: rgba(152, 25, 20, 0.15);
}

.config-tab-icon {
  width: 22px;
  height: 22px;
}

.config-tab-label {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* Tiroir */
.config-drawer {
  position: absolute;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  width: min(700px, calc(100% - 40px));
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s, padding 0.3s;
  opacity: 0;
  background: rgba(8, 8, 8, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(152, 25, 20, 0.3);
  border-radius: 16px;
  padding: 0 20px;
}

.config-drawer.open {
  max-height: 300px;
  opacity: 1;
  padding: 20px;
}

.config-drawer-content {
  display: none;
}

.config-drawer-content.active {
  display: block;
}

.drawer-title {
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #e03e32;
  margin-bottom: 14px;
}

/* Séparateur dans la toolbar */
.config-toolbar-separator {
  width: 1px;
  align-self: stretch;
  margin: 6px 4px;
  background: rgba(255, 255, 255, 0.12);
}

/* Boutons ronds (download + discord) dans la toolbar */
.ffd-action-round {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s, border-color 0.2s;
  text-decoration: none;
  color: #fff;
  font-family: inherit;
  align-self: center;
}

.ffd-action-round--download {
  background: linear-gradient(135deg, #981914, #c02a22);
  border-color: rgba(152, 25, 20, 0.5);
}

.ffd-action-round--download:hover {
  transform: scale(1.1);
  box-shadow: 0 0 16px rgba(152, 25, 20, 0.5);
}

.ffd-action-round--download:focus-visible {
  outline: 3px solid #e03e32;
  outline-offset: 2px;
}

.ffd-action-round--download:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ffd-action-round--discord {
  background: linear-gradient(135deg, #5865f2, #7289da);
  border-color: rgba(88, 101, 242, 0.5);
}

.ffd-action-round--discord:hover {
  transform: scale(1.1);
  box-shadow: 0 0 16px rgba(88, 101, 242, 0.5);
  text-decoration: none;
}

.ffd-action-round--discord:focus-visible {
  outline: 3px solid #7289da;
  outline-offset: 2px;
}

/* Grille 2x2 pour boutons */
.config-options--grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}


/* Sélecteur de couleur */
.color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
}

.color-swatch:hover {
  transform: scale(1.15);
  border-color: rgba(255, 255, 255, 0.5);
}

.color-swatch.active {
  border-color: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.3);
}

.color-swatch.active::after {
  content: '';
  position: absolute;
  inset: -5px;
  border: 1px solid rgba(152, 25, 20, 0.6);
  border-radius: 50%;
}

/* Boutons de sélection (jantes, spoiler, kit) */
.config-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Variante horizontale (ambiance : 3 boutons en ligne) */
.config-options--env {
  flex-direction: row;
}

.config-options--env .config-btn {
  flex: 1;
  text-align: center;
}

.config-btn {
  background: #0a0a0a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 14px;
  color: rgba(255, 255, 255, 0.85);
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  text-align: left;
  font-family: inherit;
}

.config-btn:hover {
  background: #1e0806;
  border-color: rgba(152, 25, 20, 0.5);
  color: #fff;
}

.config-btn.active {
  background: #280806;
  border-color: #981914;
  color: #fff;
  box-shadow: 0 0 15px rgba(152, 25, 20, 0.2);
}

.config-btn-name {
  display: block;
  font-weight: 600;
  color: #fff;
}

.config-btn-desc {
  display: block;
  font-size: var(--fs-2xs);
  color: #e0e0e0;
  margin-top: 2px;
}

/* Slider custom */
.config-slider-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.config-slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.config-slider-label {
  font-size: var(--fs-xs);
  color: rgba(255, 255, 255, 0.85);
}

.config-slider-value {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: #e03e32;
}

.config-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  outline: none;
}

.config-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: linear-gradient(135deg, #981914, #ff0000);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(152, 25, 20, 0.6);
  transition: transform 0.2s;
}

.config-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.config-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: linear-gradient(135deg, #981914, #ff0000);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 10px rgba(152, 25, 20, 0.6);
}

/* Loader pendant chargement du modèle */
.customizer-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.9);
  z-index: 50;
  transition: opacity 0.6s;
}

.customizer-loader.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader-ring {
  width: 60px;
  height: 60px;
  border: 3px solid rgba(152, 25, 20, 0.2);
  border-top-color: #981914;
  border-radius: 50%;
  animation: loaderSpin 1s linear infinite;
}

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

.loader-text {
  margin-top: 20px;
  font-size: var(--fs-xs);
  letter-spacing: 3px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

.loader-progress {
  width: 200px;
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  margin-top: 12px;
  overflow: hidden;
}

.loader-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #981914, #ff0000);
  transition: width 0.3s;
}

/* ============================================
   NO-JS FALLBACK
   ============================================ */

/* Sans JS : cacher le loader, le canvas, la toolbar, le HUD */
.no-js .customizer-loader,
.no-js #car-canvas,
.no-js .customizer-ambient,
.no-js .customizer-neon-line,
.no-js .config-toolbar,
.no-js .config-drawer,
.no-js .hud-specs,
.no-js .hud-gauge {
  display: none !important;
}

/* Message noscript affiché dans le configurateur */
.no-js-configurator {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  color: #f5f5f5;
  z-index: 20;
}

.no-js .no-js-configurator {
  display: flex;
}

.no-js-configurator h3 {
  font-size: 1.5rem;
  margin-bottom: 12px;
  color: #fff;
}

.no-js-configurator p {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.6);
  max-width: 500px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.no-js-configurator a {
  display: inline-block;
  padding: 12px 28px;
  background: #981914;
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  transition: background 0.2s;
}

.no-js-configurator a:hover {
  background: #b52e2e;
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Desktop : fullscreen sticky sous le header (140px), overlay absolu */
@media (min-width: 1025px) {
  #car-customizer {
    top: 140px;
    height: calc(100dvh - 140px);
  }

  .customizer-title {
    top: 20px;
  }
}

/* Tablette */
@media (max-width: 1024px) {
  #car-customizer {
    min-height: auto;
    display: flex;
    flex-direction: column;
  }

  #car-canvas {
    height: 50vh;
    min-height: 350px;
  }

  .customizer-title h2 {
    font-size: var(--fs-2xl);
    letter-spacing: 4px;
  }

  .hud-specs {
    position: relative;
    bottom: auto;
    left: auto;
    margin: 0 20px;
    order: 2;
  }

  .customizer-ambient {
    display: none;
  }

  .config-toolbar {
    position: relative;
    bottom: auto;
    left: auto;
    transform: none;
    order: 3;
    margin: 10px 20px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .config-drawer {
    position: relative;
    bottom: auto;
    left: auto;
    transform: none;
    width: auto;
    order: 4;
    margin: 0 20px 20px;
    border-radius: 12px;
  }
}

/* Mobile */
@media (max-width: 767px) {
  #car-canvas {
    height: 40vh;
    min-height: 280px;
  }

  .customizer-title {
    top: 20px;
  }

  .customizer-title h2 {
    font-size: var(--fs-lg);
    letter-spacing: 3px;
  }

  .customizer-title p {
    font-size: var(--fs-2xs);
  }

  .hud-specs {
    margin: 0 15px;
    padding: 18px;
    min-width: auto;
    border-radius: 12px;
  }

  .hud-stat-value {
    font-size: var(--fs-md);
  }

  .config-tab {
    padding: 8px 10px;
  }

  .config-tab-label {
    display: none;
  }

  .color-swatch {
    width: 28px;
    height: 28px;
  }
}

/* Petit mobile */
@media (max-width: 480px) {
  #car-canvas {
    height: 35vh;
    min-height: 240px;
  }

  .customizer-title h2 {
    font-size: var(--fs-md);
  }

  .hud-specs {
    padding: 14px;
  }

  .hud-grid {
    gap: 10px 14px;
  }

  .hud-stat-value {
    font-size: var(--fs-base);
  }

  .config-tab {
    padding: 6px 8px;
  }

  .config-tab-icon {
    width: 18px;
    height: 18px;
  }
}

/* ── FFD Download & Discord buttons ──────── */
/* FFD MODEL DOWNLOAD BUTTON */
.ffd-download-btn,
.ffd-discord-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
  text-decoration: none;
  text-align: center;
}

.ffd-download-btn {
  background: linear-gradient(135deg, #981914, #c02a22);
}

.ffd-download-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(152, 25, 20, 0.4);
}

.ffd-download-btn:focus-visible {
  outline: 3px solid #e03e32;
  outline-offset: 2px;
}

.ffd-download-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ffd-discord-btn {
  background: linear-gradient(135deg, #5865f2, #7289da);
}

.ffd-discord-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(88, 101, 242, 0.4);
  text-decoration: none;
}

.ffd-discord-btn:focus-visible {
  outline: 3px solid #7289da;
  outline-offset: 2px;
}

.ffd-download-hint {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  margin-top: 6px;
  min-height: 16px;
}

.ffd-download-hint a {
  color: #e03e32;
  text-decoration: underline;
  cursor: pointer;
}

/* ── PDF Generation Overlay ──────────────── */
.ffd-pdf-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

.ffd-pdf-overlay__box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 48px;
  background: #0a0a0a;
  border: 1px solid rgba(152, 25, 20, 0.3);
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6), 0 0 60px rgba(152, 25, 20, 0.15);
}

.ffd-pdf-overlay__spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: #e03e32;
  border-radius: 50%;
  animation: ffd-spin 0.8s linear infinite;
}

@keyframes ffd-spin {
  to { transform: rotate(360deg); }
}

.ffd-pdf-overlay__text {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
}
