/* ===== Design tokens (Charte UI) ===== */
:root {
  --color-primary: #007bff;
  --color-primary-600: #0056b3;
  --color-text: #333;
  --color-muted: #666;
  --color-bg: #f8f9fa;
  --color-card: #fff;
  --color-border: #e0e0e0;
  --color-border-soft: #dfe3e8;
  --shadow-1: 0 4px 12px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --radius-sm: 6px;
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --top-nav-h: 64px; /* hauteur approximative du header */
}

/* ===== Styles de base ===== */
body {
  font-family: 'Arial', sans-serif;
  background-color: var(--color-bg);
  margin: 0;
  /* Remove top padding so the sticky top-nav sits flush at the top */
  padding: 0 16px 16px;
  color: var(--color-text);
}

.container {
  background-color: var(--color-card);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  width: 100%;
  box-sizing: border-box;
  margin-top: calc(var(--top-nav-h) + var(--space-6)); /* clear fixed top-nav */
}
@media (max-width: 700px) { .container { padding: 16px; } }

/* Container width variants (responsive) */
.container-narrow { max-width: 100%; margin-left: auto; margin-right: auto; }
.container-wide { max-width: 100%; margin-left: auto; margin-right: auto; }
.container-xl { max-width: 100%; margin-left: auto; margin-right: auto; }
.container-fluid { max-width: none; width: 100%; margin-left: auto; margin-right: auto; }

@media (min-width: 768px) {
  .container-narrow { max-width: 720px; }
  .container-wide { max-width: 960px; }
  .container-xl { max-width: 1100px; }
}
@media (min-width: 1280px) {
  .container-wide { max-width: 1100px; }
}
@media (min-width: 1440px) {
  .container-xl { max-width: 1280px; }
}

h1, .main-title {
  text-align: center;
  font-size: 32px;
  color: var(--color-primary);
  margin-bottom: 24px;
}

.subtitle {
  font-size: 16px;
  color: #666;
}

/* ===== Formulaire ===== */
.form-group {
  margin-bottom: 0; /* Ajoute ou ajuste si besoin */
}

label {
  display: block;
  font-weight: bold;
  margin-bottom: 8px;
  color: #444;
}

.form-input, input[type="text"] {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
  transition: border-color 0.3s ease;
  box-sizing: border-box;
}
.form-input:focus, input[type="text"]:focus {
  border-color: #007bff;
  outline: none;
}

/* Ensure consistent width for tel/email like text inputs */
input[type="tel"], input[type="email"] {
  width: 100%;
  box-sizing: border-box;
}

/* Inline two-column rows that wrap nicely on narrow screens */
.inline-row { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-row > label { flex: 1 1 240px; min-width: 200px; }

/* ===== Boutons ===== */
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

button:hover, .btn:hover {
  filter: brightness(0.95);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.12);
}

button:active, .btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0,0,0,0.13);
}

/* Couleurs de bouton contextuelles */
.btn-primary {
  background-color: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background-color: var(--color-primary-600); }

.btn-secondary { background-color: #6c757d; color: #fff; }
.btn-secondary:hover { background-color: #5a6268; }

/* Outline variant: transparent background, colored border/text */
.btn-outline-secondary {
  background-color: transparent;
  color: #6c757d;
  border: 1px solid #6c757d;
}
.btn-outline-secondary:hover {
  background-color: rgba(108, 117, 125, 0.08);
  color: #5a6268;
  border-color: #5a6268;
}

.btn-success, button[type="submit"] { background-color: #28a745; color: #fff; }
.btn-success:hover, button[type="submit"]:hover { background-color: #218838; }

.btn-info { background-color: #17a2b8; color: #fff; }
.btn-info:hover { background-color: #138496; }

.btn-danger { background-color: #dc3545; color: #fff; }
.btn-danger:hover { background-color: #c82333; }

button#clear-marker { background-color: #dc3545; }
button#clear-marker:hover { background-color: #c82333; }

button#check-eligibility { background-color: #ffc107; color: #333; }
button#check-eligibility:hover { background-color: #e0a800; }

/* Disabled state: grisé + curseur interdit */
button[disabled], .btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  filter: none; /* neutralise l'effet hover */
  transform: none;
  box-shadow: none;
}

button i { font-size: 14px; }

.centered-btn {
  display: block;
  margin: 0 auto;
}

/* ===== Loader et messages ===== */
.loader-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(255,255,255,0.7);
  display: flex; justify-content: center; align-items: center;
  z-index: 9999;
}
.loader-spinner {
  border: 8px solid #f3f3f3;
  border-top: 8px solid #007bff;
  border-radius: 50%;
  width: 60px; height: 60px;
  animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg);} 100% {transform: rotate(360deg);} }
.loader { display: none; text-align: center; font-size: 14px; color: #007bff; margin-top: 10px; }
.error-message { text-align: center; font-size: 16px; color: #dc3545; margin-top: 10px; }

/* Small inline spinner for buttons */
.btn-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

/* ===== Carte ===== */
#map {
  height: clamp(480px, 70vh, 800px);
  width: 100%;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  margin-top: 20px;
  margin-bottom: 20px;
}

/* ===== Offres et Détails ===== */
.offer {
  margin-bottom: 20px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background-color: #fff;
  overflow: hidden;
  transition: box-shadow 0.3s ease;
}
.offer:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.11);}
.offer-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 15px; background-color: #f8f9fa; border-bottom: 1px solid #e0e0e0; cursor: pointer;
}
.offer-name { font-weight: bold; font-size: 18px; color: #007bff; }
.offer-speed { font-size: 16px; color: #666; }
.toggle-details-btn {
  background-color: #007bff; color: #fff; border: none; padding: 8px 16px;
  border-radius: 4px; cursor: pointer; font-size: 14px;
  transition: background-color 0.3s ease;
}
.toggle-details-btn:hover { background-color: #0056b3; }
.offer-details {
  height: 0; overflow: hidden; transition: height 0.5s ease; padding: 0 15px;
  background-color: #f8f9fa; border-top: 1px solid #e0e0e0;
}
.offer-details.open { height: auto; padding: 15px; }
.offer-zone { font-weight: bold; color: #555; margin-left: 10px; }

table {
  width: 100%; border-collapse: collapse; margin-top: 10px;
}
th, td { padding: 12px; text-align: left; border-bottom: 1px solid #e0e0e0; }
th { background-color: var(--color-primary); color: #fff; font-weight: bold; }
tr:hover { background-color: #f1f1f1; }

/* Reusable table component */
.table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.table-auto { table-layout: auto; }
.table th, .table td { padding: 12px; border-bottom: 1px solid #e0e0e0; text-align: left; }
.table thead th { background-color: var(--color-primary); color: #fff; font-weight: 600; }
.table-hover tbody tr:hover { background-color: #f5f7fb; }
.table-striped tbody tr:nth-child(even) { background-color: #fafbfc; }
.table-compact th, .table-compact td { padding: 8px; }
.table-sticky thead th { position: sticky; top: 0; z-index: 1; }

/* Make wide tables scroll horizontally on narrow screens */
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive table { min-width: 960px; }

/* Column sizing helpers for admin offer lists */
col.col-code { width: 35%; }
/* col-op removed */
col.col-zone { width: 7%; }
col.col-num { width: 6%; }
col.col-price { width: 20%; }
col.col-check { width: 6%; }

/* Admin offer list details - avoid overlap and keep content readable */
#admin-offer-list-items th, #admin-offer-list-items td { vertical-align: middle; }

.nowrap { white-space: nowrap; }
.break-anywhere { overflow-wrap: anywhere; word-break: break-word; }
.text-right { text-align: right; }

/* Utilities */
/* Spacing */
.mt-0 { margin-top: var(--space-0) !important; }
.mt-1 { margin-top: var(--space-1) !important; }
.mt-2 { margin-top: var(--space-2) !important; }
.mt-3 { margin-top: var(--space-3) !important; }
.mt-4 { margin-top: var(--space-4) !important; }
.mt-5 { margin-top: var(--space-5) !important; }
.mt-6 { margin-top: var(--space-6) !important; }
.mt-7 { margin-top: var(--space-7) !important; }
.mt-8 { margin-top: var(--space-8) !important; }
.mb-0 { margin-bottom: var(--space-0) !important; }
.mb-1 { margin-bottom: var(--space-1) !important; }
.mb-2 { margin-bottom: var(--space-2) !important; }
.mb-3 { margin-bottom: var(--space-3) !important; }
.mb-4 { margin-bottom: var(--space-4) !important; }
.mb-5 { margin-bottom: var(--space-5) !important; }
.ml-1 { margin-left: var(--space-1) !important; }
.ml-2 { margin-left: var(--space-2) !important; }
.fw-600 { font-weight: 600; }

/* Layout */
.row { display: flex; }
.col { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.flex-1 { flex: 1 1 auto; }
.min-w-0 { min-width: 0; }
.min-w-260 { min-width: 260px; }
.w-100 { width: 100%; }

/* Text & misc */
.text-center { text-align: center; }
.text-muted { color: var(--color-muted); }
.text-success { color: #2e7d32; }
.mono { font-family: monospace; }
.break-all { word-break: break-all; }
.label-inline { display: flex; align-items: center; gap: 6px; }
.button-bar { display: flex; gap: var(--space-2); }
.textarea-code { width: 100%; min-height: 360px; font-family: monospace; }

/* Grid helpers */
.grid-1 { display: grid; grid-template-columns: 1fr; gap: var(--space-2); }

/* Utilities: margins */
.mt-0 { margin-top: var(--space-0) !important; }
.mt-1 { margin-top: var(--space-1) !important; }
.mt-2 { margin-top: var(--space-2) !important; }
.mt-3 { margin-top: var(--space-3) !important; }
.mt-4 { margin-top: var(--space-4) !important; }
.mt-5 { margin-top: var(--space-5) !important; }
.mt-6 { margin-top: var(--space-6) !important; }
.mt-7 { margin-top: var(--space-7) !important; }
.mt-8 { margin-top: var(--space-8) !important; }

/* ===== Onglets ===== */
.tabs {
  display: flex; justify-content: center; margin-bottom: 20px;
}
.tab-button {
  padding: 10px 20px; margin: 0 5px; border: 1px solid #ccc;
  background-color: #f0f0f0; color: #333; cursor: pointer; border-radius: 5px;
  transition: background-color 0.3s ease, color 0.3s ease;
}
.tab-button.active {
  background-color: #007bff; color: white; border-color: #007bff;
}
.tab-button:hover { background-color: #ddd; color: #000; }

/* ===== Opérateurs (checkboxes) ===== */
.operator-selection { margin: 20px 0; }
.operator-selection label { display: block; margin: 10px 0; }
.operator-selection input { margin-right: 10px; }

/* ===== Résumé & Summary Box ===== */
.card, .summary { background: var(--color-card); padding: 16px 18px; border-radius: var(--radius); margin-bottom: 20px; box-shadow: 0 2px 6px rgba(0,0,0,0.05); border: 1px solid var(--color-border); }
.summary p { margin: 0 0 5px 0; }

/* ===== Flex et Responsive Layouts ===== */
.main-flex { display: flex; gap: 32px; flex-wrap: wrap; width: 100%; }
.main-left { flex: 2 1 350px; }
.main-right { flex: 1 1 260px; min-width: 260px; max-width: 400px; }

.top-form-row {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
  align-items: center;    
  width: 100%;
  flex-wrap: wrap;
}

.form-left {
  flex: 1 1 320px;
  min-width: 220px;
  display: flex;
  align-items: center;    
}

.form-right {
  flex: 1 1 220px;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ===== Historique ===== */
.history-list { list-style: none; margin: 0; padding: 0; }
.history-item { cursor: pointer; padding: 12px 8px; border-bottom: 1px solid #eee; }
.history-item:hover { background: #f5f5f5; }
.history-header { display: flex; justify-content: space-between; align-items: center; }
.history-meta { font-size: 12px; color: #666; display: flex; gap: 12px; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .main-flex { flex-direction: column; gap: 0;}
  .main-left, .main-right { max-width: 100%; width: 100%; }
  .form-right { align-items: stretch; }
}
/* Make left panel fluid and right panel fixed on wide screens */
@media (min-width: 900px) {
  /* Desktop layout: two equal halves; left capped, right centered in its half */
  .top-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: flex-start; }
  .form-left { max-width: 45vw; min-width: 0; display: block; justify-self: stretch; }
  .form-left > * { width: 100%; }
  .form-right { min-width: 320px; justify-self: center; }
}
@media (max-width: 700px) {
  .top-form-row { flex-direction: column; gap: 12px; }
  .form-right { align-items: stretch; }
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}

.summary-title {
  font-weight: bold;
  color: #333;
  margin-right: 10px;
}

.summary-coords {
  color: #666;
  margin-left: 10px;
  font-size: 15px;
}

.operator-selection {
  margin: 20px 0;
}

.operator-category {
  font-weight: bold;
  margin-right: 8px;
}

.operator-list {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  align-items: center;
}

.operator-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 4px;
  font-size: 16px;
  font-weight: 500;
}

/* Optionnel : ajuste la largeur sur mobile */
@media (max-width: 700px) {
  .operator-list {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* Nouveau layout horizontal pour le champ d’adresse */
.row-address {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  gap: 12px;
}


.address-label {
  min-width: 170px;
  font-weight: bold;
  color: #444;
  text-align: right;
  margin-bottom: 0;
  margin-right: 8px;
  flex-shrink: 0;
}

.address-input-wrapper {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
}

.address-input {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
  transition: border-color 0.3s ease;
  box-sizing: border-box;
}

/* ===== Login Page ===== */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: linear-gradient(135deg, #2c3e50, #3498db);
}

.login-form {
  background: #fff;
  padding: 40px 30px;
  border-radius: 8px;
  width: 320px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-form h2 {
  margin: 0 0 16px;
  text-align: center;
  color: #333;
}

/* Login branding */
.login-brand { text-align: center; margin: 0 0 8px; }
.login-logo { max-width: 160px; height: auto; display: block; margin: 0 auto 6px; }
.login-subtitle { font-size: 18px; font-weight: 600; color: #2c3e50; }

.input-group {
  position: relative;
}

.input-group i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
}

.input-group input {
  width: 100%;
  padding: 12px 12px 12px 40px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
  box-sizing: border-box;
}

.login-form button {
  padding: 12px;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  background: #3498db;
  color: #fff;
  cursor: pointer;
  transition: background 0.3s ease;
}

.login-form button:hover {
  background: #2980b9;
}

.login-error {
  color: #e74c3c;
  text-align: center;
}

/* ===== Avatar menu (global) ===== */
/* Top navigation bar */
.top-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 20px;
  background: #fafbfc; /* fond grisé léger */
  border-bottom: 1px solid #e6e6e6;
}
.top-nav-left { display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 700; color: #2c3e50; letter-spacing: 0.4px; }
.brand-logo { height: 28px; width: auto; display: block; }
.top-nav-center { display: flex; align-items: center; gap: 10px; flex: 1; }
.top-nav-center { position: relative; }
.menu-label { color: #555; margin-right: 4px; }
/* Reset generic button styling within top nav to avoid "big buttons" */
.top-nav button { background: transparent; border: none; padding: 6px 10px; border-radius: 0; box-shadow: none; transform: none; font-size: 16px; color: #2c3e50; font-weight: 400; }
.top-nav button:hover { filter: none; transform: none; box-shadow: none; background: transparent; color: #1f2d3d; }

/* Trigger button looks like a small text pill */
.menu-button { cursor: pointer; color: #2c3e50; padding: 8px 12px; font-size: 16px; font-weight: 400; }
.menu-button:hover { background: transparent; color: #1f2d3d; }
.menu-dropdown {
  position: absolute; left: 0; top: calc(100% + 8px); min-width: 260px; z-index: 1100;
  background: #fff; border: 1px solid #dfe3e8; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08); padding: 6px;
  display: flex; flex-direction: column;
}
.menu-item { background: transparent; border: none; text-align: left; padding: 10px 12px; cursor: pointer; border-radius: 6px; }
.menu-item:hover { background: #f5f7fb; }
.menu-item + .menu-item { border-top: 1px solid #f0f2f5; }
.top-nav-right { position: relative; display: flex; align-items: center; gap: 10px; }
.gear-button { background: transparent; border: none; border-radius: 0; width: 48px; height: 44px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: #2c3e50; }
.gear-button:hover { background: transparent; color: #1f2d3d; }
.gear-icon { width: 26px; height: 26px; display: block; }
.gear-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; z-index: 1100;
  background: #fff; border: 1px solid #dfe3e8; border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  padding: 6px; display: flex; flex-direction: column;
}
.gear-item { background: transparent; border: none; text-align: left; padding: 10px 12px; cursor: pointer; border-radius: 6px; }
.gear-item:hover { background: #f5f7fb; }

/* ===== Badges & masked prices ===== */
.badge {
  display: inline-block;
  padding: 2px 6px;
  font-size: 12px;
  border-radius: 8px;
  line-height: 1;
}
.badge-masked {
  background-color: #f0ad4e; /* amber */
  color: #fff;
  margin-left: 6px;
}
.badge-status { padding: 4px 8px; border-radius: 999px; font-weight: 600; font-size: 12px; }
.badge-status-brouillon { background-color: #6c757d; color: #fff; }
.badge-status-envoye { background-color: #0d6efd; color: #fff; }
.badge-status-valide { background-color: #28a745; color: #fff; }
.badge-status-livre { background-color: #5a5f63; color: #fff; }
.masked-price { letter-spacing: 1px; }
.badge-compact { padding: 2px 6px; font-size: 0.8em; }

/* Bootstrap-like helpers for badge background/text colors */
.bg-success { background-color: #28a745 !important; color: #fff !important; }
.bg-danger { background-color: #dc3545 !important; color: #fff !important; }
.bg-secondary { background-color: #6c757d !important; color: #fff !important; }
.bg-light { background-color: #f8f9fa !important; color: #212529 !important; border: 1px solid #e9ecef; }
.text-dark { color: #212529 !important; }

/* ===== Modal (generic) ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
}
.modal-container {
  background: #fff; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  width: min(560px, 92vw); padding: 16px;
}
.modal-content h3 { margin-top: 0; color: #2c3e50; }
.modal-summary { display: grid; grid-template-columns: 1fr; gap: 6px; margin-bottom: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
