
:root {
  --primary: #c92a2a;
  --primary-hover: #b02525;
  --bg-app: #f1f3f5;
  --bg-card: #ffffff;
  --text-main: #212529;
  --text-muted: #868e96;
  --border: #dee2e6;
  
  /* Couleurs de statut des sièges */
  --seat-libre: #2b8a3e;     /* Vert */
  --seat-payante: #e03131;   /* Rouge */
  --seat-elus: #1971c2;      /* Bleu */
  --seat-invite: #f08c00;    /* Orange */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header & Menu Bar */
#top-bar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

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

.brand-icon {
  display: flex;
  align-items: center;
}
.brand-logo-img {
  height: 44px;
  width: auto;
  max-width: 90px;
  object-fit: contain;
  border-radius: 4px;
}

.brand-info {
  display: flex;
  flex-direction: column;
}
.brand-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
  line-height: 1.2;
}
.brand-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.menu-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.btn {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease-in-out;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-menu {
  background: #f8f9fa;
  border-color: #ced4da;
  color: #343a40;
}
.btn-menu:hover:not(:disabled) {
  background: #e9ecef;
}

.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #ffffff;
  min-width: 170px;
  box-shadow: 0 8px 16px rgba(0,0,0,0.12);
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 6px 0;
  z-index: 100;
}
.dropdown.open .dropdown-content {
  display: block;
}
.dropdown-content button {
  width: 100%;
  padding: 10px 16px;
  text-align: left;
  border: none;
  background: none;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.dropdown-content button:hover {
  background: #f1f3f5;
  color: var(--primary);
}

.history-actions {
  display: flex;
  gap: 6px;
}
.btn-tool {
  background: #f8f9fa;
  border-color: #ced4da;
  color: #495057;
  font-size: 13px;
  padding: 6px 10px;
}
.btn-tool:hover:not(:disabled) {
  background: #e9ecef;
}

.save-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.indicator-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ced4da;
  transition: background-color 0.3s;
}
.indicator-dot.saved {
  background: #40c057;
}
.indicator-dot.saving {
  background: #fab005;
}
.indicator-dot.error {
  background: #fa5252;
}

/* Zone du plan (Adaptatif plein écran PC & Tablette) */
#plan-container {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
  width: 100vw;
  height: calc(100vh - 60px);
  box-sizing: border-box;
  transition: opacity 0.3s;
}

#plan-container.locked {
  filter: grayscale(85%) opacity(40%);
  pointer-events: none;
}

#svg-wrapper {
  /* Adapte automatiquement la taille selon la dimension limitante (hauteur ou largeur) */
  width: 100%;
  height: 100%;
  max-width: min(calc((100vh - 80px) * 1024 / 871), 100%);
  max-height: min(calc((100vw - 20px) * 871 / 1024), 100%);
  aspect-ratio: 1024 / 871;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: auto;
}

#salle-svg {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: block;
  box-shadow: 0 6px 22px rgba(0,0,0,0.12);
  border-radius: 10px;
  background: #ffffff;
}

/* Sièges interactifs */
.seat-rect {
  cursor: pointer;
  transition: transform 0.15s, stroke-width 0.15s, filter 0.15s;
  stroke: #ffffff;
  stroke-width: 1.5;
}
.seat-rect:hover {
  stroke: #212529;
  stroke-width: 2.5;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25));
}
.seat-rect.active-selected {
  stroke: #ff922b !important;
  stroke-width: 3.5 !important;
}

.seat-rect.st-libre { fill: var(--seat-libre); }
.seat-rect.st-payante { fill: var(--seat-payante); }
.seat-rect.st-elus { fill: var(--seat-elus); }
.seat-rect.st-invite { fill: var(--seat-invite); }

.seat-text {
  pointer-events: none;
  font-family: -apple-system, sans-serif;
  font-size: 10px;
  font-weight: bold;
  fill: #ffffff;
  text-anchor: middle;
  dominant-baseline: central;
}

/* Overlay de verrouillage */
#lock-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  justify-content: center;
  align-items: center;
  background: rgba(241, 243, 245, 0.4);
  z-index: 40;
  pointer-events: auto !important;
}
#plan-container.locked #lock-overlay {
  display: flex;
}

.lock-card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.12);
  padding: 30px;
  text-align: center;
  max-width: 440px;
  border: 1px solid var(--border);
}
.lock-icon {
  font-size: 36px;
  margin-bottom: 12px;
}
.lock-card h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: #343a40;
}
.lock-card p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 20px;
}
.lock-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* Tooltip */
.tooltip {
  position: fixed;
  background: rgba(33, 37, 41, 0.95);
  color: #ffffff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  pointer-events: none;
  z-index: 1000;
  display: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  white-space: nowrap;
  transform: translate(-50%, -125%);
}

/* Popup de modification de siège */
.popup-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 500;
  justify-content: center;
  align-items: center;
}
.popup-backdrop.active {
  display: flex;
}
.popup-box {
  background: #ffffff;
  width: 90%;
  max-width: 380px;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.2);
  overflow: hidden;
  animation: popIn 0.2s ease-out;
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.popup-header {
  padding: 16px 20px;
  background: #f8f9fa;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.seat-badge {
  background: var(--primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  padding: 3px 8px;
  border-radius: 4px;
  margin-right: 6px;
}
.seat-subtext {
  font-size: 13px;
  color: var(--text-muted);
}
.close-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
}
.close-btn:hover {
  color: #000;
}

.popup-body {
  padding: 20px;
}
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: block;
}

.status-radios {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.status-option {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.status-option:hover {
  background: #f8f9fa;
}
.status-option input {
  margin-right: 10px;
}
.radio-disc {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-right: 8px;
}
.color-libre { background: var(--seat-libre); }
.color-payante { background: var(--seat-payante); }
.color-elus { background: var(--seat-elus); }
.color-invite { background: var(--seat-invite); }

.radio-text {
  font-size: 13px;
  font-weight: 500;
}

.occupant-section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.occupant-section.hidden {
  display: none;
}

.form-group {
  margin-bottom: 12px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  color: #495057;
}
.form-group input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(201, 42, 42, 0.15);
}

.popup-footer, .modal-footer {
  padding: 12px 20px;
  background: #f8f9fa;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}
.btn-secondary {
  background: #e9ecef;
  color: #495057;
  border-color: #ced4da;
}
.btn-secondary:hover:not(:disabled) {
  background: #dee2e6;
}
.btn-block {
  width: 100%;
  justify-content: center;
  padding: 10px;
}

/* Dashboard vertical compact en bas à droite (libère les rangées P et Q) */
#bottom-dashboard {
  position: fixed;
  bottom: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.14);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column-reverse; /* Affichage de bas en haut */
  padding: 6px 10px;
  gap: 5px;
  z-index: 60;
  min-width: 125px;
  pointer-events: auto;
}

.counter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
}
.stat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-libre { background: var(--seat-libre); }
.dot-payante { background: var(--seat-payante); }
.dot-elus { background: var(--seat-elus); }
.dot-invite { background: var(--seat-invite); }

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: #495057;
  flex: 1;
}
.stat-val {
  font-size: 13px;
  font-weight: 700;
  color: #212529;
  text-align: right;
  min-width: 16px;
}

.counter-separator-h {
  width: 100%;
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

.item-total {
  flex-direction: column;
  align-items: stretch;
  gap: 1px;
  padding-bottom: 2px;
}
.total-title {
  font-size: 9px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.5px;
}
.total-amount {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
  text-align: right;
}
.total-sub {
  font-size: 9px;
  color: var(--text-muted);
  text-align: right;
}

/* Modales générales (Login, Nouveau, Ouvrir) */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 900;
  justify-content: center;
  align-items: center;
}
.modal-backdrop.active {
  display: flex;
}
.modal-box {
  background: #ffffff;
  width: 90%;
  max-width: 440px;
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(0,0,0,0.25);
  padding: 24px;
  position: relative;
}
.modal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}
.modal-header h2 {
  font-size: 18px;
  color: #212529;
}
.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.form-row {
  display: flex;
  gap: 10px;
}
.form-row .col {
  flex: 1;
}

.error-msg {
  display: none;
  color: #e03131;
  font-size: 12px;
  margin-bottom: 12px;
  font-weight: 600;
}

.events-list-container {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 16px;
}
.event-item-row {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s;
}
.event-item-row:last-child {
  border-bottom: none;
}
.event-item-row:hover {
  background: #f8f9fa;
}
.event-item-title {
  font-weight: 600;
  font-size: 14px;
}
.event-item-details {
  font-size: 12px;
  color: var(--text-muted);
}
.event-item-price {
  font-weight: 700;
  color: var(--primary);
}

/* Style spécifique pour les places PMR / Handicapées */
.seat-rect.seat-pmr {
  stroke-dasharray: 2 1;
}
.seat-text.text-pmr {
  font-size: 13px;
  font-weight: 900;
}

/* Ajustement pour le label Q1 et PMR */
.seat-text.text-q1 {
  font-size: 11px !important;
  font-weight: 900 !important;
  letter-spacing: 0.5px;
}
.session-alert {
  background: #fff3bf;
  color: #d9480f;
  border: 1px solid #ffe066;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: 12px;
  display: none;
  text-align: center;
}

/* Actions & bouton de suppression dans la liste des événements */
.event-item-main {
  flex: 1;
  min-width: 0;
  padding-right: 12px;
}
.event-item-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.btn-delete-event {
  background: #fff5f5;
  border: 1px solid #ffc9c9;
  color: #e03131;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
}
.btn-delete-event:hover {
  background: #ffe3e3;
  border-color: #ffa8a8;
  color: #c92a2a;
  transform: scale(1.08);
}
.btn-delete-event:active {
  transform: scale(0.95);
}

/* Modale de confirmation de suppression */
.delete-confirm-box {
  max-width: 420px !important;
  text-align: center;
  padding: 24px 22px 22px 22px !important;
  animation: popIn 0.2s ease-out;
}
.delete-icon-circle {
  width: 54px;
  height: 54px;
  background: #fff5f5;
  border: 2px solid #ffc9c9;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px auto;
}
.delete-title {
  font-size: 19px;
  font-weight: 700;
  color: #212529;
  margin-bottom: 6px;
}
.delete-event-target {
  font-size: 14px;
  font-weight: 600;
  color: #c92a2a;
  background: #fff5f5;
  border: 1px solid #ffc9c9;
  padding: 6px 14px;
  border-radius: 6px;
  display: inline-block;
  margin: 6px 0 14px 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.delete-warning-text {
  font-size: 13px;
  color: #495057;
  line-height: 1.5;
  margin-bottom: 22px;
}
.delete-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}
.btn-danger-solid {
  background: #e03131;
  color: #ffffff;
  border: 1px solid #c92a2a;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-danger-solid:hover {
  background: #c92a2a;
}
