/* ========================================
   COMPONENTS — boutons, bouton ✕, pastilles, badges, alertes, icône d'état, ligne de prix, compteur,
   boîte de confirmation
   Les cartes vivent dans cards.css, les champs et .custom-select dans forms.css.
   Un seul système de noms, BEM : bloc, bloc__element, bloc--variante.
   ======================================== */

/* ---------- Boutons ----------
   <a class="btn btn--primary">…</a>   variantes : --primary (orange), --dark (marine),
   --outline, --outline-clair (sur photo), --ghost, --danger ; tailles : --sm, --lg ;
   --block (pleine largeur) ; chevron : --precedent (avant le libellé), --suivant (après).
   En pilule, comme dans la maquette Kley Connect. */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 12px 24px;
    border: 1.5px solid transparent;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--color-text);
    font-size: var(--font-size-md);
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease),
                box-shadow 0.2s var(--ease), color 0.2s var(--ease), transform 0.1s var(--ease);
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

/* Texte blanc sur l'orange profond (4,5:1) : sur l'orange de la maquette, il tomberait à 3,3:1 */
.btn--primary {
    background-color: var(--color-primary-strong);
    color: var(--color-on-primary);
    box-shadow: 0 4px 12px rgba(180, 95, 30, 0.25);
}

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

.btn--dark {
    background-color: var(--color-dark);
    color: var(--color-on-dark);
}

.btn--dark:hover {
    background-color: var(--color-dark-hover);
}

.btn--outline {
    background-color: var(--color-bg);
    border-color: var(--color-text);
    color: var(--color-text);
}

.btn--outline:hover {
    background-color: var(--color-surface);
}

/* Contour blanc, posé sur une photo assombrie (boutons du hero) */
.btn--outline-clair {
    background-color: rgba(20, 33, 61, 0.35);
    border-color: var(--color-on-dark);
    color: var(--color-on-dark);
}

.btn--outline-clair:hover {
    background-color: rgba(20, 33, 61, 0.6);
}

.btn--ghost {
    background-color: transparent;
    color: var(--color-text);
}

.btn--ghost:hover {
    background-color: var(--color-surface);
}

/* Chevron avant (« Précédent », mois précédent) ou après (« Suivant ») le libellé */
.btn--precedent::before,
.btn--suivant::after {
    content: "";
    flex-shrink: 0;
    width: 12px;
    height: 12px;
    background: currentColor;
    -webkit-mask: var(--icone-chevron-gauche) center / contain no-repeat;
    mask: var(--icone-chevron-gauche) center / contain no-repeat;
}

.btn--suivant::after {
    -webkit-mask-image: var(--icone-chevron-droite);
    mask-image: var(--icone-chevron-droite);
}

/* Formulaire parti (main.js, envoi unique) : le bouton cliqué attend la page suivante */
.btn.is-envoi {
    opacity: 0.6;
    cursor: progress;
    pointer-events: none;
}

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

.btn--danger:hover {
    background-color: var(--state-danger-bg);
}

.btn--sm {
    min-height: 36px;
    padding: 8px 16px;
    font-size: var(--font-size-sm);
}

.btn--lg {
    min-height: 56px;
    padding: 16px 32px;
    font-size: 17px;
}

.btn--block {
    display: flex;
    width: 100%;
}

/* Cible tactile ≥ 44px même pour les petits boutons */
@media (max-width: 767px) {
    .btn--sm {
        min-height: 44px;
    }
}

/* Groupe de boutons côte à côte (un <form> d'un seul bouton s'y range comme un lien) */
.actions-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

/* ---------- Pastilles (filtres, choix) ----------
   <button class="chip [chip--active]">Nice</button> */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 16px;
    border: 1px solid var(--color-surface-2);
    border-radius: var(--radius-pill);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: var(--font-size-sm);
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.chip:hover {
    border-color: var(--color-text);
}

.chip--active,
.chip[aria-pressed="true"] {
    border-color: var(--color-dark);
    background: var(--color-dark);
    color: var(--color-on-dark);
}

@media (max-width: 767px) {
    .chip {
        min-height: 44px;
    }
}

/* ---------- Badges de statut ----------
   <span class="badge badge--success">Payée</span> ; variantes --success, --warning,
   --danger, --info, --neutral. Le statut d'un objet passe par
   components/badge_statut.html, qui tient la correspondance statut → variante. */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
}

.badge--success {
    background: var(--state-success-bg);
    color: var(--state-success-fg);
}

.badge--warning {
    background: var(--state-warning-bg);
    color: var(--state-warning-fg);
}

.badge--danger {
    background: var(--state-danger-bg);
    color: var(--state-danger-fg);
}

.badge--info {
    background: var(--state-info-bg);
    color: var(--state-info-fg);
}

.badge--neutral {
    background: var(--state-neutral-bg);
    color: var(--state-neutral-fg);
}

/* ---------- Alertes et messages Django ----------
   <div class="alert alert--error">…</div> ; variantes --success, --error, --warning, --info.
   Les messages Django passent par components/messages.html (alert--{{ message.level_tag }}). */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 24px;
    padding: 14px 18px;
    border: 1px solid var(--color-surface-2);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: var(--font-size-sm);
    line-height: 1.5;
}

.alert--success {
    background: var(--state-success-bg);
    border-color: var(--state-success-border);
    color: var(--state-success-fg);
}

.alert--error {
    background: var(--state-danger-bg);
    border-color: var(--state-danger-border);
    color: var(--state-danger-fg);
}

.alert--warning {
    background: var(--state-warning-bg);
    border-color: var(--state-warning-border);
    color: var(--state-warning-fg);
}

.alert--info {
    background: var(--state-info-bg);
    border-color: var(--state-info-border);
    color: var(--state-info-fg);
}

/* ---------- Icône d'état (pages de confirmation) ----------
   <span class="status-icon status-icon--success [status-icon--lg]" aria-hidden="true">svg</span>
   variantes : --primary (orange : message envoyé, inscription reçue), --success,
   --wait, --error ; --lg : 72px au lieu de 64px. Centrée par le text-align du parent. */
.status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
    border-radius: 50%;
    background: var(--color-surface);
    color: var(--color-text);
}

.status-icon--lg {
    width: 72px;
    height: 72px;
    margin-bottom: 24px;
}

.status-icon--success {
    background: var(--state-success-bg);
    color: var(--state-success-fg);
}

.status-icon--wait {
    background: var(--state-warning-bg);
    color: var(--state-warning-fg);
}

.status-icon--error {
    background: var(--state-danger-bg);
    color: var(--state-danger-fg);
}

/* ---------- Ligne de prix (fiche logement, tunnel de réservation) ----------
   <div class="price-row [price-row--discount|--total]"><span>Libellé</span><span>Montant</span></div> */
.price-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 6px 0;
    font-size: var(--font-size-base);
}

.price-row[hidden] {
    display: none;
}

.price-row--discount {
    color: var(--state-success-fg);
}

.price-row--total {
    margin-top: 16px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
    font-weight: 800;
}

/* Bouton rond − / + d'un compteur, le seul du site (voyageurs : recherche, fiche,
   réservation ; capacité d'un bien). En butée : aria-disabled, qui garde le focus clavier
   (disabled le ferait tomber sur la page). Masqué sans JS : il ne ferait rien. */
.counter-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--color-border-strong);
    border-radius: 50%;
    background: var(--color-bg);
    color: var(--color-text-light);
    cursor: pointer;
    transition: border-color 0.15s var(--ease), color 0.15s var(--ease);
}

/* Zone tactile de 44 px autour du disque de 32 px */
.counter-btn::before {
    content: "";
    position: absolute;
    inset: -6px;
}

.counter-btn:hover:not([aria-disabled="true"]) {
    border-color: var(--color-text);
    color: var(--color-text);
}

.counter-btn[aria-disabled="true"] {
    opacity: 0.35;
    cursor: not-allowed;
}

.counter-btn:focus-visible {
    outline: 2px solid var(--color-text);
    outline-offset: 2px;
}

html:not(.js) .counter-btn {
    display: none;
}

/* ---------- Boîte de confirmation ----------
   components/dialogue.html, ouverte par dialogue.js à la place du confirm() natif.
   <dialog> en showModal() : au-dessus de tout (top layer), fond par ::backdrop. */
.dialogue {
    width: min(440px, calc(100vw - 2 * var(--page-gutter)));
    max-width: none;
    padding: 0;
    margin: auto;
    border: 0;
    border-radius: var(--radius-2xl);
    background: var(--color-bg);
    color: var(--color-text);
    box-shadow: var(--shadow-float);
}

.dialogue[open] {
    animation: dialogueEntree 0.2s var(--ease);
}

@keyframes dialogueEntree {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
}

.dialogue::backdrop {
    background: var(--color-overlay);
}

.dialogue__boite {
    padding: 28px 24px 24px;
}

.dialogue__texte {
    margin: 0 0 24px;
    font-size: var(--font-size-base);
    line-height: 1.5;
}

.dialogue__actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 12px;
}

@media (max-width: 479px) {
    .dialogue__actions .btn {
        flex: 1 1 0;
    }
}

/* Icône « lien externe » après le texte d'un lien en nouvel onglet
   (components/nouvel_onglet.html) */
.lien-externe {
    display: inline-block;
    flex-shrink: 0;
    margin-left: 4px;
    vertical-align: -1px;
    opacity: 0.7;
}

/* ---------- Lien de retour ----------
   components/lien_retour.html : chevron (--icone-chevron-gauche, base.css) puis libellé ;
   --icone : chevron seul dans un rond de 44 px, le libellé en nom accessible. */
.lien-retour {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    color: var(--color-text-light);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-decoration: none;
}

.lien-retour::before {
    content: "";
    flex-shrink: 0;
    width: 12px;
    height: 12px;
    background: currentColor;
    -webkit-mask: var(--icone-chevron-gauche) center / contain no-repeat;
    mask: var(--icone-chevron-gauche) center / contain no-repeat;
}

.lien-retour:hover {
    color: var(--color-text);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.lien-retour--icone {
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: var(--color-text);
    transition: background-color 0.15s var(--ease);
}

.lien-retour--icone::before {
    width: 16px;
    height: 16px;
}

.lien-retour--icone:hover {
    background: var(--color-surface);
}

/* ---------- Bouton ✕ de fermeture ----------
   components/bouton_fermer.html : le même pour toutes les couches. Chaque couche ne garde
   que son placement (classe en plus) ; --sombre sur fond noir (visionneuse). */
.btn-fermer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--color-text);
    cursor: pointer;
    transition: background-color 0.2s var(--ease);
}

.btn-fermer:hover {
    background: var(--color-surface);
}

.btn-fermer:focus-visible {
    outline: 2px solid var(--color-text);
    outline-offset: 2px;
}

.btn-fermer--sombre {
    background: rgba(255, 255, 255, 0.15);
    color: var(--color-on-dark);
}

.btn-fermer--sombre:hover {
    background: rgba(255, 255, 255, 0.3);
}

.btn-fermer--sombre:focus-visible {
    outline-color: var(--color-on-dark);
}

/* ---------- Bascule (contrôle segmenté de liens) ----------
   <nav class="bascule"><a class="bascule__option bascule__option--active" aria-current="page">…</a>…</nav>
   Deux pages sœurs (inscription propriétaire / conciergerie) : l'option active en orange plein. */
.bascule {
    display: grid;
    grid-auto-columns: minmax(0, 1fr);
    grid-auto-flow: column;
    padding: 0;
    border: 1.5px solid var(--color-dark);
    border-radius: var(--radius-pill);
    background: var(--color-bg);
    overflow: hidden;
}

.bascule__option {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 14px;
    border-radius: var(--radius-pill);
    color: var(--color-text);
    font-size: var(--font-size-md);
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
    transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.bascule__option:hover {
    background: var(--color-surface);
}

.bascule__option--active,
.bascule__option--active:hover {
    background: var(--color-primary-strong);
    color: var(--color-on-primary);
}

/* ---------- Étiquette d'accent ----------
   Petite pastille orange pleine (zone d'une conciergerie sur sa carte) */
.etiquette {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: var(--color-primary-strong);
    color: var(--color-on-primary);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

/* Puce grise d'un service, d'un équipement */
.puce {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: var(--radius-pill);
    background: var(--color-surface-2);
    color: var(--color-text);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
}
