/* ========================================
   UNIVERSAL MODAL COMPONENT
   ======================================== */

.universal-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: transparent;
  z-index: 1000;
  padding: 0;
  border: none;
  border-radius: 0;
  animation: fadeIn 0.2s ease-in-out;
}

.universal-modal[open] {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.universal-modal::backdrop {
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.modal-content {
  position: relative;
  margin: auto;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  animation: slideUp 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Header */
.modal-header {
  padding: 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ssa-gris);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: #6b7280;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.modal-close-btn:hover {
  background-color: var(--ssa-blanc);
  color: var(--ssa-jaune);
}

/* Body */
.modal-body {
  padding: 20px 20px 0 20px;
  flex: 1;
  overflow-y: auto;
}

/* Modale des événements publics - padding-bottom pour éviter que le texte soit coupé */
#home-event-modal .modal-body {
  padding-bottom: 25px;
}

/* Espacement entre les lignes de détails dans la modale des événements publics */
#home-event-modal .modal-body p {
  margin-bottom: 5px;
}

.modal-body form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 5px 0;
}

.form-group label {
  font-weight: 500;
  color: var(--ssa-gris);
  font-size: 0.95rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--ssa-jaune);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

/* Footer */
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background-color: #f9fafb;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.btn-danger,
.btn-secondary {
  background-color: #ef4444;
  color: white;
}

.btn-danger:hover,
.btn-secondary:hover {
  background-color: #dc2626;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Modal Footer */
.modal-footer-actions {
  padding: 20px;
}


/* Responsive */
@media (max-width: 980px) {
  .universal-modal {
    left: 17px;
    top: 17px;
    overflow: hidden;
  }

  .modal-content {
    width: 95%;
    max-height: 85vh;
  }

  .modal-header {
    padding: 16px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-footer {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  .modal-header h2 {
    font-size: 1.25rem;
  }
}

/* Scrollbar styling */
.modal-content::-webkit-scrollbar {
  width: 8px;
}

.modal-content::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.modal-content::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: #b5b894;
}

/* Messages */
.modal-error-message,
.modal-success-message {
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 16px;
  font-weight: 500;
}

.modal-error-message {
  /* Red banner style */
  background-color: #b91c1c; /* strong red */
  color: #fff;
  border-left: none;
  width: 100%;
  margin: 0 0 16px 0;
  padding: 14px 18px;
  border-radius: 6px 6px 4px 4px;
  box-shadow: 0 2px 6px rgba(185, 28, 28, 0.15);
}

/* Backwards-compatibility: map legacy alert classes to the same banner style */
.alert,
.alert-error,
.alert.alert-error {
  display: block;
  background-color: #b91c1c;
  color: #fff;
  width: 100%;
  margin: 0 0 16px 0;
  padding: 14px 18px;
  border-radius: 6px 6px 4px 4px;
  box-shadow: 0 2px 6px rgba(185, 28, 28, 0.15);
  font-weight: 600;
}

.modal-success-message {
  background-color: #dcfce7;
  color: #15803d;
  border-left: 4px solid #22c55e;
}

.modal-error-message p,
.modal-success-message p {
  margin: 0;
}

/* Field-level error messages shown under inputs */
.field-error {
  color: #b91c1c; /* red matching banner */
  margin-top: 6px;
  margin-bottom: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.field-error.client-error {
  /* small visual difference for client-generated messages */
  opacity: 0.95;
}



/* Progress bar for uploads/conversion inside modals */
.modal-progress-container {
  margin-bottom: 12px;
}

.modal-progress {
  background: #eef2ff;
  border-radius: 6px;
  height: 10px;
  overflow: hidden;
}

.modal-progress-bar {
  background: linear-gradient(90deg, #60a5fa, #3b82f6);
  height: 100%;
  width: 0%;
  transition: width 150ms linear;
}

.modal-progress-text {
  font-size: 0.85rem;
  color: #374151;
  margin-top: 6px;
}