/* ============================================================
   Réservation d'espaces — Design system partagé
   Direction : "plan d'architecte" — cohérent avec le sujet (gestion
   de salles/plans). Chargé par toutes les pages ; ne pas renommer
   les classes/ids consommés par le JS de chaque page.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Couleurs de marque — encre "blueprint" */
  --color-navy-900: #0b2035;
  --color-navy-800: #123049;
  --color-navy-700: #1a4361;
  --color-accent: #0f9b8e;
  --color-accent-hover: #0c7d73;
  --color-accent-soft: #e2f5f3;

  /* Neutres */
  --color-bg: #f5f6f4;
  --color-surface: #ffffff;
  --color-border: #e1e5e2;
  --gray-50: #f7f8f6;
  --gray-100: #eff1ee;
  --gray-200: #e0e3df;
  --gray-300: #cbd0cb;
  --gray-500: #667069;
  --gray-700: #38423c;
  --gray-900: #14201a;

  /* Statuts */
  --color-free: #15803d;
  --color-free-bg: #dcfce7;
  --color-free-fill: #4ade80;
  --color-busy: #b91c1c;
  --color-busy-bg: #fee2e2;
  --color-busy-fill: #f87171;
  --color-soon: #b45309;
  --color-soon-bg: #fef3c7;
  --color-soon-fill: #fbbf24;
  --color-danger: #dc2626;
  --color-danger-hover: #b91c1c;

  /* Typo */
  --font-display: 'Space Grotesk', var(--font-sans);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 16px;
  --text-lg: 19px;
  --text-xl: 23px;

  /* Espacements */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Rayons / ombres */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(11, 32, 53, 0.06), 0 1px 3px rgba(11, 32, 53, 0.08);
  --shadow-md: 0 4px 14px rgba(11, 32, 53, 0.10), 0 2px 4px rgba(11, 32, 53, 0.06);
  --shadow-lg: 0 12px 32px rgba(11, 32, 53, 0.16);

  /* Signature — grille "plan technique" utilisée derrière les visualisations de salles */
  --blueprint-grid:
    linear-gradient(var(--color-border) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-border) 1px, transparent 1px);
  --blueprint-grid-size: 24px 24px;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  margin: 0;
  background: var(--color-bg);
  color: var(--gray-900);
  font-size: var(--text-base);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}
h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }

a { color: var(--color-accent); }

/* --- Boutons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background-color .15s ease, box-shadow .15s ease, transform .05s ease, opacity .15s ease;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; pointer-events: none; }
.btn-block { width: 100%; }

.btn-primary { background: var(--color-accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--color-accent-hover); }

.btn-secondary { background: var(--gray-100); color: var(--gray-900); }
.btn-secondary:hover { background: var(--gray-200); }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: var(--color-danger-hover); }

.btn-sm { padding: 6px 12px; font-size: var(--text-sm); border-radius: var(--radius-sm); }

/* --- Cartes --- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-lg);
}

/* --- Champs de formulaire --- */
label {
  display: block;
  margin-top: var(--space-md);
  margin-bottom: var(--space-xs);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-700);
}

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=datetime-local], input[type=color],
select, textarea {
  font-family: inherit;
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  background: var(--color-surface);
  color: var(--gray-900);
  transition: border-color .15s ease, box-shadow .15s ease;
  box-sizing: border-box;
}

input[type=color] { padding: 3px; height: 38px; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

/* --- Badges de statut --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.badge-free { background: var(--color-free-bg); color: var(--color-free); }
.badge-free::before { background: var(--color-free); }
.badge-busy { background: var(--color-busy-bg); color: var(--color-busy); }
.badge-busy::before { background: var(--color-busy); }
.badge-soon { background: var(--color-soon-bg); color: var(--color-soon); }
.badge-soon::before { background: var(--color-soon); }
/* Distinct de badge-soon (dot plein "Bientôt réservé") par une texture hachurée plutôt
   qu'une couleur différente, pour rester cohérent avec le hachurage utilisé ailleurs
   (plan SVG, calendrier) pour représenter "en attente de paiement". */
.badge-pending { background: var(--color-soon-bg); color: var(--color-soon); }
.badge-pending::before {
  border-radius: 2px;
  background-image: repeating-linear-gradient(45deg, var(--color-soon) 0 2px, transparent 2px 4px);
}

/* --- Statuts sur le plan SVG (index.html + admin-plan.html) --- */
.unit-shape {
  stroke: rgba(11, 32, 53, 0.3);
  stroke-width: 1.5;
  filter: drop-shadow(0 2px 4px rgba(11, 32, 53, 0.15));
  transition: opacity .15s ease, filter .15s ease, transform .1s ease;
}
.unit-shape:hover { filter: drop-shadow(0 4px 10px rgba(11, 32, 53, 0.22)); }
.unit-label {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  fill: var(--gray-900);
  pointer-events: none;
  text-anchor: middle;
}
.status-free { fill: var(--color-free-fill); }
.status-busy { fill: var(--color-busy-fill); }
.status-soon { fill: var(--color-soon-fill); }
/* "Occupé, mais par une réservation en attente de paiement" — hachurage plutôt que
   couleur pleine (voir pattern #pendingHatch défini dans le SVG de chaque zone,
   index.html), pour rester distinguable de status-busy (réservation confirmée). */
.status-pending { fill: url(#pendingHatch); }

/* --- Toile "plan technique" — signature visuelle derrière les plans de salles ---
   Appliquer .blueprint-canvas au conteneur qui entoure le SVG du plan
   (voir #plan-container dans index.html / admin-plan.html). */
.blueprint-canvas {
  position: relative;
  border-radius: var(--radius-lg);
  background-color: var(--color-surface);
  background-image: var(--blueprint-grid);
  background-size: var(--blueprint-grid-size);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.blueprint-canvas::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
}
/* Zone avec illustration de fond (zones.image_url) : la grille "plan technique" et
   son cadre pointillé n'ont plus de raison d'être, l'image les remplace. */
.blueprint-canvas.has-image { background-image: none; }
.blueprint-canvas.has-image::before { display: none; }

/* --- Salles par-dessus une illustration de fond (index.html, zone avec image_url
   uniquement — voir renderZone). Remplissage semi-transparent pour laisser voir
   l'image, le statut reste porté par un contour net dans la couleur du statut plutôt
   que par un aplat plein. Zones sans image_url : comportement inchangé (.unit-shape
   de base ci-dessus, fill plein). --- */
.unit-shape.on-image { fill-opacity: 0.4; stroke-width: 2.5; }
.unit-shape.status-free.on-image { stroke: var(--color-free); }
.unit-shape.status-busy.on-image { stroke: var(--color-busy); }
.unit-shape.status-soon.on-image { stroke: var(--color-soon); }
.unit-shape.status-pending.on-image { fill-opacity: 0.55; stroke: var(--color-soon); }
/* Halo blanc translucide derrière le nom de salle, pour rester lisible par-dessus
   une illustration dont le contraste n'est pas contrôlé (contrairement à un aplat
   de statut uni). Technique CSS "stroke as text outline", pas de rect à dimensionner. */
.unit-label.on-image {
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 3px;
  stroke-linejoin: round;
}

/* --- Badge de statut en bas de salle (zone avec illustration uniquement — voir
   statusBadgeSVG dans index.html). Mêmes couleurs que .badge (légende en haut de
   page), en plus grand pour rester lisible par-dessus l'illustration. --- */
.unit-status-badge-bg { pointer-events: none; }
.unit-status-badge-bg.status-free { fill: var(--color-free-bg); }
.unit-status-badge-bg.status-busy { fill: var(--color-busy-bg); }
.unit-status-badge-bg.status-soon, .unit-status-badge-bg.status-pending { fill: var(--color-soon-bg); }
.unit-status-badge-text {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  text-anchor: middle;
  pointer-events: none;
}
.unit-status-badge-text.status-free { fill: var(--color-free); }
.unit-status-badge-text.status-busy { fill: var(--color-busy); }
.unit-status-badge-text.status-soon, .unit-status-badge-text.status-pending { fill: var(--color-soon); }

/* --- Plaque semi-opaque derrière le nom de salle, pour rester lisible
   par-dessus la texture de sol / le mobilier, quel que soit le statut. --- */
.unit-label-plaque {
  fill: rgba(255, 255, 255, 0.82);
  pointer-events: none;
}

/* --- App shell (sidebar de navigation, injectée par js/nav.js) --- */
.app-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 220px;
  background: var(--color-navy-900);
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 22px 22px;
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: var(--space-lg) var(--space-md);
  z-index: 100;
}
.app-sidebar-brand {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  margin-bottom: var(--space-lg);
  padding: 0 var(--space-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}
.app-sidebar-brand::before {
  content: "";
  width: 18px;
  height: 18px;
  flex: none;
  background-color: var(--color-accent);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Crect x='3' y='3' width='18' height='18' rx='1.5'/%3E%3Cpath d='M3 9h18M9 9v12'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Crect x='3' y='3' width='18' height='18' rx='1.5'/%3E%3Cpath d='M3 9h18M9 9v12'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
}
.app-sidebar-links { list-style: none; margin: 0; padding: 0; flex: 1; }
.app-sidebar-links li { margin-bottom: 2px; }
.app-sidebar-links a {
  display: block;
  padding: 10px 12px;
  border-left: 2px solid transparent;
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.app-sidebar-links a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.app-sidebar-links a.active {
  background: rgba(15, 155, 142, 0.16);
  color: #fff;
  border-left-color: var(--color-accent);
  font-weight: 600;
}
.app-sidebar-links .nav-section-label {
  display: block;
  padding: var(--space-md) 12px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.4);
}
.app-sidebar-user {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: var(--space-md);
}
.app-sidebar-user-name { font-size: var(--text-sm); font-weight: 600; }
.app-sidebar-user-role {
  font-size: var(--text-xs);
  color: rgba(255, 255, 255, 0.55);
  text-transform: capitalize;
  margin-bottom: var(--space-sm);
}
.app-sidebar-user .btn { margin-top: var(--space-xs); }

body.has-sidebar { padding-left: 220px; }

@media (max-width: 780px) {
  .app-sidebar { position: static; width: auto; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .app-sidebar-links { display: flex; flex: none; }
  .app-sidebar-user { border-top: none; padding-top: 0; }
  body.has-sidebar { padding-left: 0; }
}

/* --- Tables (admin-users.html) --- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; font-size: var(--text-base); border-bottom: 1px solid var(--color-border); }
th { background: var(--gray-50); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .03em; color: var(--gray-500); }
tr:last-child td { border-bottom: none; }

.muted { color: var(--gray-500); }

/* --- Toasts (confirmations/erreurs, voir js/toast.js) --- */
.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-width: 360px;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: 600;
  color: #fff;
  white-space: pre-line;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.visible { opacity: 1; transform: translateX(0); }
.toast-success { background: var(--color-free); }
.toast-error { background: var(--color-danger); }
