/* Strapontin — components : formulaires, boutons, alertes, tableaux, badges, toasts, modales */

/* ── Composants formulaire ───────────────────────────────── */
.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}

input[type="file"] {
  max-width: 100%;
  width: 100%;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: 0.875rem;
  font-family: inherit;
  line-height: 1.5;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

input[type="number"] {
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--fg);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}

/* ── Boutons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  transition: opacity 0.15s;
}

.btn:hover {
  opacity: 0.85;
}
.btn:focus-visible,
.btn-texte:focus-visible,
.btn-icone:focus-visible,
.sidebar-nav a:focus-visible,
.bottom-nav-items a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
}

.btn-secondary {
  background: var(--accent);
  color: var(--accent-fg);
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: var(--danger-fg);
}

.btn-danger-outline {
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger-text);
}
.btn-danger-outline:hover {
  background: var(--danger-bg);
}

.btn-full {
  width: 100%;
}
.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}
.btn-xs {
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 500;
}

/* ── Bannière système overlay ────────────────────────────── */
.banniere-overlay {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  line-height: 1.5;
  border-bottom: 1px solid;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

@media (max-width: 1024px) {
  .banniere-overlay {
    left: 0;
    border-radius: 0;
    padding-top: max(0.625rem, env(safe-area-inset-top));
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  }
}

.banniere-icone {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.banniere-message {
  flex: 1;
  white-space: pre-wrap;
}

.banniere-fermer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem;
  background: transparent;
  border: none;
  border-radius: var(--radius);
  color: inherit;
  opacity: 0.6;
  flex-shrink: 0;
  cursor: pointer;
}

.banniere-fermer:hover {
  opacity: 1;
}

.banniere-progression {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: currentColor;
  opacity: 0.25;
  transform-origin: left;
  animation: reduire-progression var(--duree-banniere) linear forwards;
}

@keyframes reduire-progression {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

.banniere-slide-enter-active {
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
}

.banniere-slide-leave-active {
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

.banniere-slide-enter-from,
.banniere-slide-leave-to {
  transform: translateY(-100%);
  opacity: 0;
}

.banniere-overlay--info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.banniere-overlay--warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.banniere-overlay--error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.dark .banniere-overlay--info {
  background: #0c1a3a;
  border-color: #1e3a8a;
  color: #93c5fd;
}

.dark .banniere-overlay--warning {
  background: #1c1400;
  border-color: #78350f;
  color: #fcd34d;
}

.dark .banniere-overlay--error {
  background: #1c0a0a;
  border-color: #7f1d1d;
  color: #fca5a5;
}

/* ── Alertes ─────────────────────────────────────────────── */
.alerte {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  border-width: 1px;
  border-style: solid;
  position: relative;
}

.alerte-erreur {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-text);
}
.alerte-succes {
  background: var(--succes-bg);
  border-color: var(--succes-border);
  color: var(--succes-text);
}
.alerte-info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-text);
}
.alerte-avertissement {
  background: var(--avertissement-bg);
  border-color: var(--avertissement-border);
  color: var(--avertissement-text);
}

/* ── Tableau ─────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  text-align: left;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  color: var(--fg-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}
tr:hover td {
  background: var(--bg-muted);
}

/* ── Badge ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.375rem;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-nouveau {
  background: #eff6ff;
  color: #1d4ed8;
}
.badge-annule {
  background: #fef2f2;
  color: #991b1b;
}
.badge-reporte {
  background: #fffbeb;
  color: #92400e;
}
.badge-complet {
  background: #fff7ed;
  color: #c2410c;
}
.badge-tournee {
  background: #f0f9ff;
  color: #0369a1;
}

.dark .badge-nouveau {
  background: #1e3a8a;
  color: #93c5fd;
}
.dark .badge-annule {
  background: #7f1d1d;
  color: #fca5a5;
}
.dark .badge-reporte {
  background: #78350f;
  color: #fde68a;
}
.dark .badge-complet {
  background: #7c2d12;
  color: #fed7aa;
}
.dark .badge-tournee {
  background: #0c2d4a;
  color: #7dd3fc;
}
.badge-prevente {
  background: #fdf4ff;
  color: #7e22ce;
}
.dark .badge-prevente {
  background: #3b0764;
  color: #e9d5ff;
}

/* ── Utilitaires ─────────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mt-4 {
  margin-top: 1rem;
}
.text-muted {
  color: var(--fg-muted);
}
.text-sm {
  font-size: 0.875rem;
}
.texte-centre {
  text-align: center;
}
.cache {
  display: none;
}
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── En-tête de page ─────────────────────────────────────── */
.page-header {
  margin-bottom: 1.5rem;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  view-transition-name: titre-page;
}
.page-subtitle {
  font-size: 0.875rem;
  color: var(--fg-muted);
  margin-bottom: 0.25rem;
}

/* ── Chips (filtres) ─────────────────────────────────────── */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 1rem;
}
.chips a {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--border);
  color: var(--fg-muted);
  transition: all 0.15s;
}
.chips a:hover {
  border-color: var(--fg);
  color: var(--fg);
}
.chips a.actif {
  border-color: var(--fg);
  background: var(--fg);
  color: var(--bg);
}

/* ── État vide ───────────────────────────────────────────── */
.etat-vide {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.etat-vide-titre {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.etat-vide-texte {
  font-size: 0.875rem;
  color: var(--fg-muted);
}
.etat-vide-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ── Boutons texte ───────────────────────────────────────── */
.btn-texte {
  background: none;
  border: none;
  color: var(--fg-subtle);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  transition:
    background 0.15s,
    color 0.15s;
}
.btn-texte:hover {
  background: var(--accent);
  color: var(--fg);
}
.btn-texte.btn-sm {
  font-size: 0.75rem;
  padding: 0.125rem 0.375rem;
}

.btn-danger-texte {
  background: none;
  border: none;
  color: var(--fg-subtle);
  font-size: 0.8125rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius);
  transition:
    background 0.15s,
    color 0.15s;
}
.btn-danger-texte:hover {
  background: var(--danger-bg);
  color: var(--danger-text);
}

/* ── Formulaires spéciaux ────────────────────────────────── */
.form-recherche {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.form-recherche input {
  flex: 1;
  padding-left: 2.125rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 0.625rem center;
  background-size: 1rem;
}
.dark .form-recherche input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
}

.form-aide {
  font-size: 0.75rem;
  color: var(--fg-muted);
  margin-bottom: 1.5rem;
}
.form-aide-avertissement {
  color: var(--avertissement);
  font-weight: 500;
}

.form-inline {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  flex-wrap: wrap;
}
.form-inline input,
.form-inline select {
  flex: 1;
  min-width: 0;
}

.form-vertical {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.form-compact {
  max-width: 28rem;
}

.form-ajouter-direct {
  margin-top: 0.75rem;
}

.form-fichier {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.form-fichier__input {
  display: none;
}
.form-fichier__nom {
  font-size: 0.875rem;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.form-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.form-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.form-checkboxes label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: normal;
  cursor: pointer;
}
.form-checkboxes input[type="checkbox"],
.notif-grille__case input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  min-width: 1.25rem;
  border: 1.5px solid var(--border);
  border-radius: 0.25rem;
  background: var(--bg);
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
  vertical-align: middle;
}
.form-checkboxes input[type="checkbox"]:checked,
.notif-grille__case input[type="checkbox"]:checked {
  background: var(--primary);
  border-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='M3 8l3.5 3.5L13 5'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 75%;
}
.dark .form-checkboxes input[type="checkbox"]:checked,
.dark .notif-grille__case input[type="checkbox"]:checked {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%2309090b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='M3 8l3.5 3.5L13 5'/%3E%3C/svg%3E");
}
.form-checkboxes input[type="checkbox"]:disabled,
.notif-grille__case input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.form-checkboxes label:has(input:disabled) {
  cursor: not-allowed;
}

.notif-radio {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: normal;
  cursor: pointer;
}
.notif-radio input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.125rem;
  height: 1.125rem;
  min-width: 1.125rem;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
  position: relative;
}
.notif-radio input[type="radio"]:checked {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: inset 0 0 0 3px var(--bg);
}
.notif-radio input[type="radio"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.notif-radio:has(input:disabled) {
  cursor: not-allowed;
}

/* ── Section résultats (artistes, salles) ────────────────── */
.section-resultats {
  margin-bottom: 2rem;
}

.section-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--fg-muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.liste-cartes {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.carte-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  gap: 0.75rem;
  transition: background 0.15s;
}
.carte-item:hover {
  background: var(--bg-muted);
}

.carte-nom {
  font-weight: 500;
}
.carte-sous-titre {
  font-size: 0.75rem;
  color: var(--fg-muted);
  margin-top: 0.125rem;
}

/* ── Filtres (spectacles) ────────────────────────────────── */
.filtres-form {
  margin-bottom: 1.5rem;
}
.filtres-ligne {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.filtres-ligne input,
.filtres-ligne select {
  flex: 1;
  min-width: 8rem;
  max-width: 16rem;
}
.filtres-ligne input[type="number"] {
  max-width: 8rem;
}

/* ── Pagination ──────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
  font-size: 0.875rem;
  color: var(--fg-muted);
}

/* ── Actions cellule tableau ─────────────────────────────── */
.actions-cellule {
  vertical-align: middle;
  text-align: right;
  white-space: nowrap;
}
.actions-cellule > * {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
}
.actions-cellule > * + * {
  margin-left: 0.375rem;
}

/* ── Toggle switch ───────────────────────────────────────── */
.switch {
  display: inline-block;
  position: relative;
  width: 2.5rem;
  height: 1.5rem;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.switch-curseur {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 9999px;
  transition: background 0.2s;
  cursor: pointer;
}
.switch-curseur::before {
  content: "";
  position: absolute;
  left: 0.1875rem;
  top: 0.1875rem;
  width: 1.125rem;
  height: 1.125rem;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}
.switch input:checked + .switch-curseur {
  background: var(--primary);
}
.switch input:checked + .switch-curseur::before {
  transform: translateX(1rem);
}
.switch--succes input:checked + .switch-curseur {
  background: var(--succes);
}

/* ── Toasts (Popover API + @starting-style) ──────────────── */
[popover].alerte {
  position: fixed;
  inset: auto;
  bottom: calc(1.5rem + var(--indice-toast, 0) * 5.25rem);
  right: 1.5rem;
  left: auto;
  top: auto;
  width: min(22rem, calc(100vw - 3rem));
  margin: 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);

  transition:
    opacity 0.3s ease,
    transform 0.3s ease,
    display 0.3s allow-discrete,
    overlay 0.3s allow-discrete;
  opacity: 1;
  transform: translateY(0);

  @starting-style {
    opacity: 0;
    transform: translateY(0.75rem);
  }
}

[popover].alerte:not(:popover-open) {
  opacity: 0;
  transform: translateY(0.75rem);
}

.toast-fermer {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.125rem;
  line-height: 1;
  color: inherit;
  opacity: 0.5;
  padding: 0.25rem 0.375rem;
  border-radius: 0.25rem;
}

.toast-fermer:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.08);
}

.dark .toast-fermer:hover {
  background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 1024px) {
  [popover].alerte {
    right: 1rem;
    left: 1rem;
    width: auto;
    bottom: calc(var(--nav-h) + 0.75rem + var(--indice-toast, 0) * 5.25rem);
  }
}

/* ── Modale (dialog HTML natif) ──────────────────────────── */
dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  padding: 1.5rem;
  max-width: 32rem;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}
.dark dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}
.dialog-entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.dialog-titre {
  font-size: 1rem;
  font-weight: 600;
}
.btn-icone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem;
  border-radius: var(--radius);
  color: var(--fg-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}
.btn-icone:hover {
  background: var(--bg-muted);
  color: var(--fg);
}
.dialog-corps {
  font-size: 0.875rem;
  color: var(--fg-muted);
  margin-bottom: 0.75rem;
}
.dialog-lien {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.dialog-lien input {
  flex: 1;
  font-family: ui-monospace, monospace;
  font-size: 0.8125rem;
}
.dialog-pied {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}
