/* ============================================
   THEME TOKENS
   ============================================ */
:root {
  --clr-primary:    #0e7490;
  --clr-primary-h:  #0c5e75;
  --clr-primary-bg: #ecfeff;
  --clr-primary-50: #ecfeff;
  --clr-primary-200:#a5f3fc;
  --clr-primary-300:#67e8f9;
  --clr-primary-400:#22d3ee;
  --clr-primary-500:#06b6d4;
  --clr-primary-600:#0891b2;
  --clr-primary-700:#0e7490;

  --clr-text:       #1e293b;
  --clr-text-soft:  #64748b;
  --clr-text-mute:  #94a3b8;

  --clr-bg:         #fafafa;
  --clr-surface:    #ffffff;
  --clr-border:     #e2e8f0;
  --clr-border-h:   #cbd5e1;

  --clr-surface-0:   #ffffff;
  --clr-surface-50:  #f8fafc;
  --clr-surface-100: #f1f5f9;
  --clr-surface-200: #e2e8f0;
  --clr-surface-300: #cbd5e1;
  --clr-surface-400: #94a3b8;
  --clr-surface-500: #64748b;
  --clr-surface-600: #475569;
  --clr-surface-800: #1e293b;
  --clr-surface-900: #0f172a;

  --ff-display: Georgia, 'Times New Roman', serif;
  --ff-body:    -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  --radius:    6px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 0.15s;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--ff-body);
  color: var(--clr-text);
  background: var(--clr-bg);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: var(--space-xl) 0;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   LAYOUT
   ============================================ */
.container {
  width: 100%;
  max-width: 580px;
  padding: var(--space-md);
}

/* ============================================
   CARD
   ============================================ */
.card {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
}

.card-header {
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--clr-border);
}

.card-header h1 {
  font-family: var(--ff-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--clr-text);
  margin: 0;
  text-align: center;
}

.card-header p {
  color: var(--clr-text-soft);
  font-size: 0.875rem;
  margin-top: 4px;
  text-align: center;
}

/* ============================================
   FORM
   ============================================ */
#form-config {
  padding: var(--space-lg);
}

.form-group {
  margin-bottom: var(--space-lg);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--clr-text);
  margin-bottom: 6px;
}

/* ============================================
   INPUTS & SELECT
   Bordure visible au repos, focus avec ring
   ============================================ */
input[type="text"],
input[type="number"],
select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--clr-text);
  background: var(--clr-surface);
  border: 1px solid var(--clr-border-h);
  border-radius: var(--radius);
  transition: border-color var(--dur), box-shadow var(--dur);
}

input:hover, select:hover {
  border-color: var(--clr-text-mute);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.12);
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 36px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* ============================================
   RADIOS PILL (Masculin / Féminin, etc.)
   Sélection nettement visible
   ============================================ */
.radio-group {
  display: flex;
  gap: var(--space-sm);
  padding-top: 2px;
}

.radio-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  padding: 10px 14px;
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--clr-text-soft);
  flex: 1;
  transition: border-color var(--dur), background var(--dur), color var(--dur);
}

.radio-label:hover {
  border-color: var(--clr-border-h);
  background: var(--clr-bg);
  color: var(--clr-text);
}

.radio-label:has(input:checked) {
  border-color: var(--clr-primary);
  background: var(--clr-primary-bg);
  color: var(--clr-primary-h);
  font-weight: 600;
}

.radio-label input[type="radio"] {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--clr-border-h);
  border-radius: 50%;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color var(--dur), background var(--dur);
}

.radio-label input[type="radio"]:checked {
  border-color: var(--clr-primary);
  background: var(--clr-primary);
}

.radio-label input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 5px; height: 5px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* ============================================
   TOGGLE (Distance / Niveau, vol oiseau / voiture)
   Contraste actif / inactif marqué
   ============================================ */
.toggle-container {
  display: flex;
  background: #f1f5f9;
  padding: 4px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius);
  margin-top: 6px;
  gap: 2px;
}

.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-label {
  flex: 1;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--ff-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--clr-text-mute);
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: color var(--dur), background var(--dur);
}

.toggle-label:hover {
  color: var(--clr-text);
  background: rgba(255, 255, 255, 0.6);
}

.toggle-input:checked + .toggle-label {
  background: var(--clr-surface);
  color: var(--clr-primary);
  font-weight: 600;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.06),
    0 0 0 1px var(--clr-border);
}

.toggle-input:focus-visible + .toggle-label {
  outline: 2px solid var(--clr-primary);
  outline-offset: 2px;
}

/* ============================================
   DROP ZONE
   Pointillé épaissi, hover marqué
   ============================================ */
.drop-zone {
  position: relative;
  border: 2px dashed var(--clr-border-h);
  border-radius: var(--radius);
  padding: var(--space-lg);
  text-align: center;
  background: var(--clr-bg);
  cursor: pointer;
  transition: border-color var(--dur), background var(--dur);
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--clr-primary);
  background: var(--clr-primary-bg);
}

.file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.drop-zone-content {
  pointer-events: none;
}

.drop-zone p {
  font-size: 0.875rem;
  color: var(--clr-text-soft);
}

.drop-zone p strong {
  color: var(--clr-primary);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.file-limit {
  font-size: 0.78rem;
  color: var(--clr-text-mute);
  margin-top: 4px;
}

/* ============================================
   BOUTON PRIMAIRE
   ============================================ */
.btn-primary {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--clr-primary);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--dur);
}

.btn-primary:hover {
  background: var(--clr-primary-h);
}

/* ============================================
   FILE NOTICE
   ============================================ */
.file-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--clr-primary-bg);
  border: 1px solid var(--clr-primary-200);
  border-radius: var(--radius);
  font-size: 0.78rem;
  color: #155e75;
  line-height: 1.5;
}

.file-notice svg {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--clr-primary);
}

.file-notice code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  background: #cffafe;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.74rem;
}

.file-notice a {
  color: var(--clr-primary);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.file-notice a:hover {
  color: var(--clr-primary-h);
}

.file-notice-warning {
  background: #fef3c7;
  border-color: #fde68a;
  color: #78350f;
}

.file-notice-warning svg {
  color: #b45309;
}

.file-notice-warning strong {
  color: #7c2d12;
}

/* ============================================
   LOADER
   ============================================ */
.spinner {
  width: 36px;
  height: 36px;
  border: 2.5px solid #e5e5e5;
  border-top-color: var(--clr-primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

.loader-label {
  font-size: 0.875rem;
  color: var(--clr-text-soft);
}

.dots span {
  animation: blink 1.2s infinite;
  opacity: 0;
}

.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0; }
  40%           { opacity: 1; }
}

/* ============================================
   BOUTON FLOTTANT (numérotation)
   ============================================ */
.btn-floating {
  position: fixed;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: var(--clr-surface);
  color: var(--clr-text);
  border: 1px solid var(--clr-border-h);
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: border-color var(--dur), background var(--dur), color var(--dur);
  z-index: 100;
  font-family: inherit;
}

.btn-floating:hover {
  border-color: var(--clr-primary);
  background: var(--clr-primary-bg);
  color: var(--clr-primary-h);
}

.btn-floating svg {
  color: var(--clr-text-soft);
  transition: color var(--dur);
}

.btn-floating:hover svg {
  color: var(--clr-primary);
}

@media (max-width: 600px) {
  .btn-floating span {
    display: none;
  }
  .btn-floating {
    padding: 9px;
    border-radius: 50%;
  }
}

/* ============================================
   MODALES
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: min(420px, 100%);
  align-items: center;
  text-align: center;
}

.modal-icon {
margin-left: auto;
  margin-right: auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  background: var(--clr-primary-bg);
  color: var(--clr-primary);
}

.modal-icon--info  { background: var(--clr-primary-bg); color: var(--clr-primary); }
.modal-icon--warn  { background: #fef3c7;               color: #b45309; }
.modal-icon--error { background: #fee2e2;               color: #dc2626; }

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--clr-text);
  margin: 0 0 6px;
}

.modal-message {
  font-size: 0.875rem;
  color: var(--clr-text-soft);
  line-height: 1.5;
  margin: 0 0 20px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
  transition: background var(--dur), border-color var(--dur);
}

.modal-btn--cancel {
  background: transparent;
  color: var(--clr-text-soft);
  border-color: var(--clr-border);
}

.modal-btn--cancel:hover {
  background: var(--clr-bg);
  border-color: var(--clr-border-h);
}

.modal-btn--confirm {
  background: var(--clr-primary);
  color: #fff;
}

.modal-btn--confirm:hover {
  background: var(--clr-primary-h);
}

.modal-btn--confirm-error {
  background: #dc2626;
  color: #fff;
}

.modal-btn--confirm-error:hover {
  background: #b91c1c;
}

/* ============================================
   TOAST
   ============================================ */
.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid var(--clr-border);
  background: var(--clr-surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  animation: toastIn 0.3s var(--ease-out) forwards;
  max-width: 360px;
}

.toast svg {
  flex-shrink: 0;
}

.toast--success { background: #f0fdf4; color: #15803d; border-color: #a6f4c5; }
.toast--error   { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.toast--warn    { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.toast--info    { background: var(--clr-primary-bg); color: var(--clr-primary-h); border-color: var(--clr-primary-200); }

.toast.leaving { animation: toastOut 0.25s var(--ease-out) forwards; }

@keyframes toastIn  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to   { opacity: 0; transform: translateX(20px); } }

/* ============================================
   POOL CARDS & EDITION (page niveau)
   ============================================ */
.pool-card {
  cursor: pointer;
}

.pool-card--active {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 2px rgba(14, 116, 144, 0.15);
}

.pool-card--active .pool-card-head {
  background: var(--clr-primary-bg);
}

.pool-team-row.clickable {
  cursor: crosshair;
}

.pool-team-row.clickable:hover {
  background: #eaf3de;
}

.pool-team-row.selected {
  background: #c0dd97;
  outline: 1.5px solid #3b6d11;
  outline-offset: -1.5px;
}

.edit-overlay {
  margin-top: 9px;
  position: absolute;
  inset: -8px;
  border-radius: var(--radius-lg);
  border: 2px dashed #97c459;
  background: rgba(99, 153, 34, 0.03);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur);
}

.edit-overlay.visible { opacity: 1; }

.badge-edit {
  font-size: 11px;
  font-weight: 500;
  background: #eaf3de;
  color: #3b6d11;
  border: 1px solid #97c459;
  border-radius: 4px;
  padding: 3px 8px;
  opacity: 0;
  transition: opacity var(--dur);
  pointer-events: none;
}

.badge-edit.visible { opacity: 1; }

.edit-hint {
  font-size: 12px;
  color: var(--clr-text-mute);
  min-height: 18px;
  padding-left: 4px;
}

#btn-switch.active {
  border: 1px solid #3b6d11;
  background: #eaf3de;
  color: #3b6d11;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
  .sidebar { position: static; }
  .ts-label { display: none; }
}

@media (max-width: 540px) {
  .container { padding: var(--space-md); }
  .card-header { padding: var(--space-md) var(--space-md) var(--space-sm); }
  .card-header h1 { font-size: 1.25rem; }
  #form-config { padding: var(--space-md); }
  .form-row { grid-template-columns: 1fr; gap: var(--space-md); }

  .dashboard { padding: var(--space-sm); gap: var(--space-sm); }
  #map { height: 280px; }
  .pools-grid { grid-template-columns: 1fr; padding: var(--space-sm); }
  .topbar-brand { display: none; }

  .toast-container {
    top: auto;
    bottom: var(--space-md);
    left: var(--space-sm);
    right: var(--space-sm);
  }
  .toast { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}