/* =========================================================
   VARIABLES — CHARTE LIKEWATT
========================================================= */
:root {
  --blue: #003B58;
  --blue-dark: #002C43;
  --green: #9DCF56;
  --green-dark: #7FB43F;
  --bg: #F6FAFD;
  --card: #FFFFFF;
  --text: #0F172A;
  --muted: #64748B;
  --border: #E5E7EB;
}

/* =========================================================
   RESET
========================================================= */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* =========================================================
   HEADER / NAV
========================================================= */
.topbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 24px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.header-title {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--blue);
}

.nav {
  display: flex;
  gap: 16px;
}

.nav-link {
  text-decoration: none;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 20px;
  border-radius: 999px;
  transition: all 0.2s ease;
}

.nav-link:hover {
  background: rgba(0,59,88,0.08);
  color: var(--blue);
}

.nav-link.active {
  background: var(--green);
  color: #0F172A;
}

/* =========================================================
   LAYOUT
========================================================= */
.app-container {
  max-width: 1280px;
  margin: 32px auto;
  padding: 0 24px;
}

/* =========================================================
   PAGE HEADER
========================================================= */
.page-header {
  text-align: center;
  margin-bottom: 32px;
}

.page-header h1 {
  margin: 0;
  font-size: 2.2rem;
}

.subtitle {
  margin-top: 6px;
  color: var(--muted);
}

/* =========================================================
   CARDS
========================================================= */
.card {
  background: var(--card);
  border-radius: 22px;
  padding: 28px;
  margin-bottom: 32px;
  box-shadow: 0 16px 32px rgba(0,0,0,0.10);
}

/* =========================================================
   FORM GRID
========================================================= */
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

@media (max-width: 900px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}

input,
select {
  width: 100%;
  padding: 11px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  background: #ffffff;
}

select[multiple] {
  min-height: 150px;
}

/* =========================================================
   BOUTONS — VERSION VISIBLE & FORTE
========================================================= */

/* BASE */
button,
.btn {
  appearance: none;
  border-radius: 999px;
  padding: 12px 26px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

/* ACTION PRINCIPALE (AFFICHER / COMPARER) */
.btn-primary,
button {
  background: linear-gradient(135deg, #9DCF56, #BFE88A);
  color: #0F172A;
  box-shadow: 0 8px 20px rgba(157,207,86,0.45);
}

.btn-primary:hover,
button:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(157,207,86,0.55);
}

/* ACTION SECONDAIRE (AJOUTER / NAVIGATION) */
.btn-secondary {
  background: var(--blue);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(0,59,88,0.35);
}

.btn-secondary:hover {
  background: var(--blue-dark);
  transform: translateY(-2px);
}

/* EXPORT / CSV */
.btn-outline {
  background: #ffffff;
  border: 2px solid var(--green);
  color: var(--blue);
}

.btn-outline:hover {
  background: rgba(157,207,86,0.15);
}

/* =========================================================
   ACTION ROWS
========================================================= */
.actions-row {
  display: flex;
  gap: 14px;
  margin-top: 18px;
  flex-wrap: wrap;
}

/* =========================================================
   SELECTION BOX
========================================================= */
.selection-box {
  margin-top: 18px;
  padding: 16px;
  background: #F8FAFC;
  border-radius: 16px;
  font-size: 0.9rem;
}

/* =========================================================
   RESULT AREA
========================================================= */
.result-area {
  margin-top: 20px;
  padding: 20px;
  background: #F1F8E6;
  border-radius: 18px;
  color: var(--muted);
  min-height: 130px;
}

/* =========================================================
   DASHBOARD — BOUTONS DE NAVIGATION (UNIFIÉS)
========================================================= */

.btn-dashboard {
  display: inline-block;
  margin-top: 12px;
  padding: 14px 30px;
  border-radius: 999px;
  background: linear-gradient(135deg, #003B58, #005F8C);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 10px 26px rgba(0,59,88,0.35);
  transition: all 0.25s ease;
}

.btn-dashboard:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, #002C43, #003B58);
  box-shadow: 0 16px 34px rgba(0,59,88,0.45);
}

/* =========================================================
   ANALYSE — AJUSTEMENTS VISUELS
========================================================= */

.selection-box ul {
  margin-top: 10px;
  padding-left: 18px;
}

.selection-box li {
  margin-bottom: 6px;
  color: var(--text);
  font-size: 0.9rem;
}

.result-area table {
  width: 100%;
  border-collapse: collapse;
}

.result-area th,
.result-area td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.result-area th {
  text-align: left;
  font-weight: 700;
  color: var(--blue);
}

.result-area tr:last-child td {
  border-bottom: none;
}

/* ===== Analyse comparative layout (comme ta capture) ===== */

.app-container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.hero {
  text-align: center;
  padding: 22px 0 10px;
}

.hero h1 {
  font-size: 44px;
  margin: 0;
  letter-spacing: 0.3px;
}

.subtitle {
  margin: 8px 0 0;
  opacity: 0.75;
}

.card {
  background: #fff;
  border-radius: 18px;
  padding: 26px 26px 22px;
  margin-top: 18px;
  box-shadow: 0 18px 50px rgba(16, 24, 40, 0.08);
  border: 1px solid rgba(16, 24, 40, 0.06);
}

.card-title {
  font-size: 28px;
  margin: 0 0 18px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
  align-items: start;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  opacity: 0.85;
}

.input, .select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(16, 24, 40, 0.14);
  background: #fff;
  padding: 12px 14px;
  outline: none;
}

.select {
  padding: 10px;
  min-height: 210px;
}

.btn-row {
  display: flex;
  gap: 14px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.btn {
  border: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 700;
  transition: transform 0.05s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn:active { transform: translateY(1px); }

.btn-green {
  background: #b7e66a;
  box-shadow: 0 10px 28px rgba(183, 230, 106, 0.35);
}

.btn-blue {
  background: #0b3a52;
  color: #fff;
  box-shadow: 0 10px 28px rgba(11, 58, 82, 0.25);
}

.btn-outline {
  background: #fff;
  border: 2px solid rgba(11, 58, 82, 0.35);
  color: #0b3a52;
}

.section-title {
  margin: 20px 0 10px;
  font-size: 22px;
}

.pre {
  background: #f6fafc;
  border: 1px solid rgba(16, 24, 40, 0.08);
  border-radius: 14px;
  padding: 14px;
  min-height: 70px;
  overflow: auto;
}

.selection-box {
  background: #fff;
  border: 1px solid rgba(16, 24, 40, 0.12);
  border-radius: 14px;
  padding: 12px 14px;
  min-height: 46px;
}

.selection-list {
  margin: 0;
  padding-left: 18px;
}

@media (max-width: 980px) {
  .grid-3 { grid-template-columns: 1fr; }
  .select { min-height: 180px; }
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.result-box {
  overflow-x: auto;
}

.compare-list {
  margin-top: 10px;
}

.compare-item {
  padding: 8px 12px;
  border-radius: 8px;
  background: #f5f7fa;
  margin-bottom: 6px;
}

.compare-actions {
  display: flex;
  gap: 12px;
  margin-top: 15px;
}

/* =========================
   FORM GRID (SCÉNARIO)
========================= */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 16px;
  margin-top: 12px;
}

select[multiple] {
  min-height: 160px;
}

/* =========================
   BOUTONS
========================= */

.btn-primary {
  background: linear-gradient(135deg, #b7e26f, #9fdc56);
  border: none;
  padding: 10px 18px;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary {
  background: #003b58;
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
}

/* =========================
   SCENARIO LAYOUT
========================= */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.buttons-row {
  display: flex;
  gap: 16px;
  margin-top: 12px;
}

select[multiple] {
  min-height: 180px;
}

/* =========================
   BOUTONS
========================= */

.btn-primary {
  background: linear-gradient(135deg, #b7e26f, #9fdc56);
  border: none;
  padding: 10px 22px;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary {
  background: #003b58;
  color: #fff;
  border: none;
  padding: 10px 22px;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
}


/* =========================================================
   SCÉNARIO — LAYOUT PROPRE & STABLE
========================================================= */

.scenario .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.scenario .form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scenario .form-group.full {
  grid-column: 1 / -1;
}

/* Boutons Scénario */
.scenario .scenario-actions {
  display: flex;
  gap: 16px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.scenario .scenario-actions button {
  min-width: 200px;
}

/* Sélecteurs */
.scenario select[multiple] {
  min-height: 180px;
}

/* Résultats */
.scenario .result-box {
  background: #F1F8E6;
  border-radius: 18px;
  padding: 20px;
  min-height: 120px;
}

/* Comparaison */
.scenario .compare-box {
  background: #F8FAFC;
  border-radius: 16px;
  padding: 16px;
  min-height: 60px;
}

/* FIX CLIC (OBLIGATOIRE) */
.scenario .card {
  position: relative;
  overflow: visible;
}

.scenario .card button {
  position: relative;
  z-index: 10;
  pointer-events: auto;
}

/* =========================================================
   FIX CLIC — SCÉNARIO (BOUTONS BLOQUÉS)
   OBLIGATOIRE POUR COMPARAISON
========================================================= */

/* On s'assure que la zone Scénario autorise les clics */
.app-container.scenario {
  position: relative;
  z-index: 1;
}

/* Les cartes ne doivent PAS bloquer les clics */
.app-container.scenario .card {
  position: relative;
  overflow: visible;
  z-index: 1;
}

/* Les boutons doivent être AU-DESSUS de tout */
.app-container.scenario button,
.app-container.scenario .btn-primary,
.app-container.scenario .btn-secondary {
  position: relative;
  z-index: 50;
  pointer-events: auto;
}

.loading-bar {
  height: 6px;
  width: 100%;
  background: linear-gradient(90deg, #9adf5c, #3cb371);
  animation: loading 1s infinite linear;
  margin-bottom: 10px;
}

@keyframes loading {
  0% { background-position: 0% }
  100% { background-position: 100% }
}
/* =========================================================
   LOADING BAR (Analyse globale & Carte)
========================================================= */

.loading-wrapper {
  margin-top: 16px;
}

.loading-text {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.loading-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
  position: relative;
}

.loading-bar::after {
  content: "";
  position: absolute;
  left: -40%;
  top: 0;
  height: 100%;
  width: 40%;
  background: linear-gradient(
    135deg,
    var(--green),
    #c9f29a
  );
  animation: loading-slide 1.2s infinite ease-in-out;
}

@keyframes loading-slide {
  from { left: -40%; }
  to   { left: 100%; }
}

/* =========================================================
   MAP CONTAINER FIX
========================================================= */

#map {
  width: 100%;
  height: 420px;
  border-radius: 18px;
  overflow: hidden;
  background: #e5e7eb;
}

/* =========================================================
   MAP ACTIONS
========================================================= */

.map-actions {
  display: flex;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
/* =========================
   LEAFLET MAP FIX (CRITIQUE)
========================= */

#map {
  height: 500px !important;
  min-height: 500px !important;
  width: 100%;
  border-radius: 16px;
  background: #e5e7eb;
}

.leaflet-container {
  height: 100% !important;
  width: 100% !important;
}

.map-container {
  height: 420px;
  border-radius: 14px;
  overflow: hidden;
  background: #e5e7eb;
}

.loading-box {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.loading-box.hidden {
  display: none;
}

.loading-bar {
  width: 160px;
  height: 6px;
  background: linear-gradient(
    90deg,
    #b7e66b 25%,
    #e5e7eb 37%,
    #b7e66b 63%
  );
  background-size: 400% 100%;
  animation: loading 1.2s infinite;
  border-radius: 4px;
}

@keyframes loading {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}
/* =========================================================
   TABLES – ANTI DÉBORDEMENT
========================================================= */

.result-area {
  overflow-x: auto;
  max-width: 100%;
}

.result-area table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.result-area th,
.result-area td {
  padding: 8px 10px;
  vertical-align: top;
  word-break: break-word;
  white-space: pre-wrap;
  font-size: 13px;
}

.result-area td {
  max-width: 400px;
}

/* Scroll horizontal discret */
.result-area::-webkit-scrollbar {
  height: 8px;
}

.result-area::-webkit-scrollbar-thumb {
  background-color: #cfd8dc;
  border-radius: 4px;
}

/* =========================================================
BOUTONS RÉSULTATS NON CLIQUABLES
========================================================= */

#btnLoadResults,
#btnShowResults,
#btnAddResultsCompare,
#btnCompareResults,
#btnExportResultsCSV {
  position: relative !important;
  z-index: 9999 !important;
  pointer-events: auto !important;
}

/* On s'assure que les cartes Résultats ne bloquent pas */
section.card {
  overflow: visible !important;
}

/* Supprime tout overlay invisible */
section.card::before,
section.card::after {
  display: none !important;
  pointer-events: none !important;
}
/* =========================================================
   LOADER ANALYSE GLOBALE
========================================================= */

.global-loader {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-size: 14px;
  color: #003b58;
}

.global-loader .spinner {
  width: 48px;
  height: 48px;
  border: 5px solid #cfd8dc;
  border-top-color: #9dcf56;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =========================================================
   LOADER CARTE
========================================================= */

.map-loader {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.85);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-size: 14px;
  color: #003b58;
}

.map-loader .spinner {
  width: 42px;
  height: 42px;
  border: 5px solid #cfd8dc;
  border-top-color: #9dcf56;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 10px;
}

/* =========================================================
   ANALYSE — HARMONISATION VISUELLE
   (alignée avec Scénario / Résultats)
========================================================= */

/* Grille identique aux autres pages */
.analyse .form-grid {
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* Sélecteurs multiples cohérents */
.analyse select[multiple] {
  min-height: 180px;
}

/* Boutons même style que partout */
.analyse .btn-primary {
  background: linear-gradient(135deg, #9DCF56, #BFE88A);
  color: #0F172A;
  box-shadow: 0 8px 20px rgba(157,207,86,0.45);
}

.analyse .btn-secondary {
  background: #003B58;
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(0,59,88,0.35);
}

/* Zone résultats comme Résultats & Scénario */
.analyse .result-area {
  background: #F1F8E6;
  border-radius: 18px;
  padding: 20px;
  min-height: 130px;
  color: var(--muted);
}

/* Tableau Analyse aligné */
.analyse .result-area table {
  width: 100%;
  border-collapse: collapse;
}

.analyse .result-area th,
.analyse .result-area td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.analyse .result-area th {
  color: var(--blue);
  font-weight: 700;
}
