/*
 * Pulsanti — ristrutturazione grafica 2026-10 (docs/restyling/01_DESIGN_SYSTEM.md §6).
 *
 * Una sola azione principale per vista: .btn-primary (blu cobalto, --c-action).
 * Il verde UISP è solo marchio: .btn-dark, storico, ora ha l'aspetto dell'azione principale.
 * Secondario = fondo chiaro con bordo a 3,7:1; tenue = solo testo; distruttivo = rosso.
 * Altezze: 36px con puntatore (.btn-sm), 44px base e su touch, 52px (.btn-lg) in gara,
 * 64px (.btn-xl) per voto e chiamata. Premuto: scale(.97) solo da puntatore.
 */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    min-height: var(--h-control);
    padding: 0 var(--s-4);
    font-family: var(--t-body);
    font-size: var(--t-16);
    font-weight: 600;
    line-height: 1.2;
    color: var(--c-ink);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-md);
    cursor: pointer;
    transition:
        transform var(--m-fast) var(--m-ease),
        background-color var(--m-base) ease,
        border-color var(--m-base) ease,
        color var(--m-base) ease;
    white-space: nowrap;
    text-decoration: none;
    text-align: center;
}

.btn:active:not(:disabled):not([aria-disabled="true"]) {
    transform: scale(0.97);
}

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

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

/* Principale: una per vista */
.btn-primary,
.btn-dark {
    background: var(--c-action);
    border-color: var(--c-action);
    color: var(--c-action-ink);
}

/* Secondario */
.btn-secondary,
.btn-outline {
    background: var(--c-surface);
    border-color: var(--c-line-strong);
    color: var(--c-ink);
}

/* Tenue: azioni minori nelle righe di tabella */
.btn-quiet {
    background: transparent;
    border-color: transparent;
    color: var(--c-action);
    padding: 0 var(--s-2);
}

.btn-ghost {
    background: transparent;
    color: var(--c-ink-muted);
}

/* Confermato e attenzione: azioni legate a uno stato, mai principali */
.btn-success {
    background: var(--c-success-soft);
    border-color: var(--c-success);
    color: var(--c-success);
}

.btn-warning {
    background: var(--c-caution-soft);
    border-color: var(--c-caution);
    color: var(--c-caution);
}

/* Distruttivo: contorno rosso nelle pagine, pieno solo dentro una conferma */
.btn-danger {
    background: var(--c-surface);
    border-color: var(--c-danger);
    color: var(--c-danger);
}

.btn-danger-solid,
.confirm-dialog .btn-danger {
    background: var(--c-danger);
    border-color: var(--c-danger);
    color: var(--c-danger-ink);
}

@media (hover: hover) and (pointer: fine) {
    .btn-primary:hover:not(:disabled),
    .btn-dark:hover:not(:disabled) {
        background: var(--c-action-hover);
        border-color: var(--c-action-hover);
        color: var(--c-action-ink);
    }

    .btn-secondary:hover:not(:disabled),
    .btn-outline:hover:not(:disabled) {
        background: var(--c-sunken);
        border-color: var(--c-ink-muted);
        color: var(--c-ink);
    }

    .btn-quiet:hover:not(:disabled) {
        text-decoration: underline;
        color: var(--c-action-hover);
    }

    .btn-ghost:hover:not(:disabled) {
        background: var(--c-sunken);
        color: var(--c-ink);
    }

    .btn-success:hover:not(:disabled) {
        background: var(--c-surface);
    }

    .btn-warning:hover:not(:disabled) {
        background: var(--c-surface);
    }

    .btn-danger:hover:not(:disabled) {
        background: var(--c-danger-soft);
        color: var(--c-danger);
    }

    .btn-danger-solid:hover:not(:disabled),
    .confirm-dialog .btn-danger:hover:not(:disabled) {
        background: var(--c-danger);
        color: var(--c-danger-ink);
        filter: brightness(0.92);
    }
}

/* Misure */
.btn-sm {
    min-height: var(--h-control-sm);
    padding: 0 var(--s-3);
    font-size: var(--t-14);
}

.btn-lg {
    min-height: var(--h-control-lg);
    padding: 0 var(--s-6);
    font-size: var(--t-18);
}

.btn-xl {
    min-height: var(--h-control-xl);
    padding: 0 var(--s-6);
    font-size: var(--t-18);
}

.btn-icon {
    width: var(--h-control);
    padding: 0;
}

.btn-icon.btn-sm {
    width: var(--h-control-sm);
    padding: 0;
}

/* Su touch nessun pulsante sotto 44px */
@media (pointer: coarse) {
    .btn-sm {
        min-height: var(--h-control);
    }

    .btn-icon.btn-sm {
        width: var(--h-control);
    }
}

.btn svg,
.btn .icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.btn-lg svg,
.btn-xl svg {
    width: 20px;
    height: 20px;
}

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

/* In caricamento la larghezza resta fissa: il testo lo cambia submit_guard.js */
.btn[aria-busy="true"] {
    cursor: progress;
}

@media (max-width: 599px) {
    .btn {
        white-space: normal;
    }
}

@media (prefers-reduced-motion: reduce) {
    .btn:active:not(:disabled):not([aria-disabled="true"]) {
        transform: none;
    }
}

@media print {
    .btn {
        display: none !important;
    }
}
