/* ============================================================================
   RESET / BASE
============================================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: #f5f5f7;
  color: #0f172a;
}

/* ============================================================================
   APP LAYOUT (CARTE)
============================================================================ */

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* HEADER (front) */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
  position: sticky;
  top: 0;
  z-index: 40;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-title {
  display: flex;
  flex-direction: column;
}

.app-title-main {
  font-size: 15px;
  font-weight: 600;
}

.app-title-sub {
  font-size: 12px;
  color: #6b7280;
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-tag {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4f46e5;
}

.app-pill-link {
  text-decoration: none;
}

.app-pill {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  color: #374151;
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* MAIN LAYOUT : carte + panneau */

.app-main {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* Carte */

#map {
  flex: 2;
  min-width: 0;
  min-height: calc(100vh - 64px);
  position: relative;
  z-index: 1;
}

/* Panneau de droite */

#details-panel {
  flex: 1;
  min-width: 340px;
  max-width: 420px;
  background: #ffffff;
  border-left: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  gap: 10px;
  position: relative;
  z-index: 2;
}

/* Sections */

.panel-section {
  padding: 10px 0;
  border-bottom: 1px solid #e5e7eb;
}

.panel-section:last-of-type {
  border-bottom: none;
}

.panel-header-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
  margin-bottom: 4px;
}

.panel-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: #111827;
}

.panel-subline {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Chips */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #4b5563;
}

.chip-zone {
  background: #ecfdf3;
  color: #15803d;
  border-color: #bbf7d0;
}

/* ============================================================================
   RECHERCHE PANEL DROITE
============================================================================ */

.search-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-label {
  font-size: 12px;
  color: #4b5563;
}

#search-input {
  padding: 7px 9px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  font-size: 13px;
  outline: none;
  background: #f9fafb;
}

#search-input:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.15);
}

/* Résultats */

#search-results {
  position: relative;
  z-index: 20;
}

.search-results-list {
  list-style: none;
  padding: 4px 0;
  margin: 4px 0 0 0;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
  max-height: 220px;
  overflow-y: auto;
}

.search-result-item {
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}

.search-result-item:hover {
  background: #f3f4ff;
}

/* ============================================================================
   CRÉNEAUX – PANNEAU PUBLIC
============================================================================ */

.slots-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}

.slots-title {
  font-size: 14px;
  font-weight: 600;
}

.slots-legend {
  font-size: 11px;
  color: #6b7280;
}

/* Cartes de créneaux */

#slots-grid,
#opening-slots-grid {
  margin-top: 4px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  padding: 8px 10px;
}

/* Créneaux supplémentaires possibles : look différent */
#opening-slots-section {
  margin-top: 8px;
}

#opening-slots-grid {
  background: #fefcf5;
  border-style: dashed;
}

/* Grille des créneaux */

.slots-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  margin-bottom: 4px;
}

.slot-row {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 6px;
  align-items: center;
}

.slot-day {
  font-weight: 500;
  color: #4b5563;
}

.slot-intervals {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.slot-badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 11px;
}

.slot-empty {
  font-size: 12px;
  color: #9ca3af;
}

/* Infos complémentaires */

.info-block {
  margin-top: 8px;
  font-size: 12px;
  color: #4b5563;
  background: #f9fafb;
  border-radius: 8px;
  padding: 6px 8px;
  border: 1px solid #e5e7eb;
}

/* ============================================================================
   FORMULAIRE demande de créneau
============================================================================ */

.request-card {
  margin-top: 10px;
  border-radius: 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.request-title {
  font-size: 13px;
  font-weight: 600;
}

.request-subtitle {
  font-size: 11px;
  color: #6b7280;
}

.form-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.form-field {
  flex: 1;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-field label {
  font-size: 11px;
  color: #4b5563;
}

.form-field label span {
  color: #ef4444;
}

.form-field input,
.form-field textarea,
.form-field select {
  border-radius: 8px;
  border: 1px solid #d1d5db;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: #ffffff;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.18);
}

.form-field textarea {
  min-height: 60px;
  resize: vertical;
}

.request-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

/* Panel footer */

.panel-footer {
  margin-top: auto;
  padding-top: 8px;
  font-size: 11px;
  color: #9ca3af;
  border-top: 1px solid #e5e7eb;
}

/* ============================================================================
   BOUTONS
============================================================================ */

.btn {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #ffffff;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background 0.12s ease, box-shadow 0.12s ease,
    transform 0.05s ease, border-color 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}

.btn:hover {
  background: #f3f4ff;
  border-color: #c7d2fe;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.09);
}

.btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

.btn.primary {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  border-color: transparent;
  color: #ffffff;
}

.btn.primary:hover {
  background: linear-gradient(135deg, #4338ca, #4f46e5);
  box-shadow: 0 3px 10px rgba(79, 70, 229, 0.4);
}

.btn.danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.btn.danger:hover {
  background: #fee2e2;
}

.btn.subtle {
  background: #f9fafb;
  border-color: #e5e7eb;
  color: #4b5563;
}

.btn.subtle:hover {
  background: #eef2ff;
  border-color: #c7d2fe;
}

/* Espacement entre boutons voisins */
.btn + .btn {
  margin-left: 6px;
}

/* ============================================================================
   ADMIN LAYOUT
============================================================================ */

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-logo {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
  font-weight: 700;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-title {
  display: flex;
  flex-direction: column;
}

.admin-title-main {
  font-size: 15px;
  font-weight: 600;
}

.admin-title-sub {
  font-size: 12px;
  color: #6b7280;
}

.admin-header-right {
  font-size: 12px;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-pill {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4f46e5;
  text-decoration: none;
}

/* Tabs */

.admin-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  background: #f3f4f6;
  border-bottom: 1px solid #e5e7eb;
}

.admin-tab {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  color: #4b5563;
  background: transparent;
}

.admin-tab.active {
  background: #ffffff;
  color: #111827;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}

/* Container */

.admin-container {
  padding: 14px 16px 20px 16px;
  max-width: 1120px;
  margin: 0 auto 24px auto;
}

.admin-panel {
  background: #ffffff;
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  border: 1px solid #e5e7eb;
}

.admin-panel h2 {
  margin: 0 0 6px 0;
  font-size: 15px;
}

.admin-panel-subtitle {
  margin: 0;
  font-size: 12px;
  color: #6b7280;
}

.admin-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.admin-panel-footer {
  margin-top: 10px;
}

/* Zones / communes / slots – filtres */

.admin-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.admin-filter-row input[type="text"],
.admin-filter-row select {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  padding: 6px 10px;
  font-size: 12px;
  font-family: inherit;
  background: #f9fafb;
}

/* Hidden class */

.hidden {
  display: none;
}

/* Tables (zones + slots) */

.admin-table-wrapper {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  background: #ffffff;
}

.admin-panel table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.admin-panel th,
.admin-panel td {
  border-bottom: 1px solid #e5e7eb;
  padding: 6px 6px;
  text-align: left;
}

.admin-panel th {
  font-weight: 500;
  color: #4b5563;
  background: #f9fafb;
}

/* Templates boutons dans l’admin */

.admin-templates {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

/* ============================================================================
   ADMIN – COMMUNES (nouveau design)
============================================================================ */

#communes-results {
  margin-top: 8px;
}

.commune-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid #e5e7eb;
}

.commune-card-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.commune-card-title {
  font-weight: 600;
  font-size: 14px;
}

.commune-card-subtitle {
  font-size: 12px;
  color: #6b7280;
}

.commune-card-meta {
  font-size: 12px;
  color: #4b5563;
}

.commune-card-body {
  border-top: 1px solid #e5e7eb;
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.commune-field-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.commune-field-row > label {
  font-size: 12px;
  color: #4b5563;
}

.commune-field-row textarea,
.commune-field-row select {
  font-size: 13px;
  font-family: inherit;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  padding: 5px 7px;
}

.commune-slots-block {
  border-radius: 8px;
  background: #f9fafb;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.commune-slots-title {
  font-size: 13px;
  font-weight: 500;
}

.commune-slots-help {
  font-size: 11px;
  color: #6b7280;
}

.commune-slots-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.commune-slots-table th,
.commune-slots-table td {
  border-bottom: 1px solid #e5e7eb;
  padding: 4px;
  vertical-align: top;
}

.commune-card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.commune-card-actions .btn.primary {
  min-width: 160px;
}

/* ============================================================================
   ADMIN – COMMUNES (top controls)
============================================================================ */

#commune-search {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
}

#commune-zone-filter {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  padding: 4px 10px;
  font-size: 12px;
  font-family: inherit;
}

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

@media (max-width: 960px) {
  .app-main {
    flex-direction: column;
  }

  #map {
    min-height: 260px;
  }

  #details-panel {
    max-width: 100%;
    min-width: 0;
    border-left: none;
    border-top: 1px solid #e5e7eb;
  }

  .admin-container {
    padding: 10px;
  }

  .admin-panel {
    padding: 12px;
  }
}

/* ============================================================================
   LOGIN PAGE
============================================================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 12px;
  background: radial-gradient(
      circle at top left,
      rgba(79, 70, 229, 0.08),
      transparent 50%
    ),
    radial-gradient(
      circle at bottom right,
      rgba(34, 197, 94, 0.08),
      transparent 50%
    ),
    #f5f5f7;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: #ffffff;
  border-radius: 16px;
  padding: 18px 18px 20px 18px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
  border: 1px solid #e5e7eb;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.login-logo {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #ffffff;
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-title-block {
  display: flex;
  flex-direction: column;
}

.login-title {
  font-size: 15px;
  font-weight: 600;
}

.login-subtitle {
  font-size: 12px;
  color: #6b7280;
}

.login-error {
  font-size: 12px;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 6px 8px;
  margin-bottom: 10px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.login-field label {
  font-size: 12px;
  color: #4b5563;
}

.login-field input {
  border-radius: 8px;
  border: 1px solid #d1d5db;
  padding: 7px 9px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.login-field input:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 1px rgba(79, 70, 229, 0.2);
}

.login-submit {
  width: 100%;
  margin-top: 4px;
  justify-content: center;
}