/* ═══════════════════════════════════════════════════════
   AGGIUNTA A style.css — Login modal, toast, auth UI
   ═══════════════════════════════════════════════════════ */

/* ── Pulsanti header: Login / Logout ─────────────────── */

/* ── Wrapper voce auth nella navbar ─────────────────── */
.nav-auth-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
}

.btn-login {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.55);
    color: #fff;
    padding: 7px 18px 7px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: 'Exo 2', sans-serif;
    letter-spacing: 0.3px;
    transition:
        background 0.22s ease,
        border-color 0.22s ease,
        box-shadow 0.22s ease,
        transform 0.18s ease;
    white-space: nowrap;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.btn-login:hover {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    transform: translateY(-1px);
}

.btn-login:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.14);
}

.btn-login-icon {
    display: flex;
    align-items: center;
    opacity: 0.9;
    flex-shrink: 0;
}

.btn-login-label {
    line-height: 1;
}

/* Mobile: pulsante login occupa tutta la riga */
@media (max-width: 767px) {
    .nav-auth-item {
        margin-left: 0;
        padding: 6px 0 2px;
        border-top: 1px solid rgba(255,255,255,0.15);
        width: 100%;
    }

    .btn-login {
        width: 100%;
        justify-content: center;
        padding: 10px 18px;
        border-radius: 8px;
        font-size: 0.95rem;
        background: rgba(255, 255, 255, 0.18);
        border-color: rgba(255, 255, 255, 0.5);
    }
}

.btn-logout {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.7);
    color: #fff;
    padding: 6px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
    white-space: nowrap;
}

.btn-logout:hover { background: rgba(255,80,80,0.25); border-color: #ff8080; transform: translateY(-1px); }

.user-info {
    color: rgba(255,255,255,0.85);
    font-size: 0.85rem;
    margin-right: 8px;
    vertical-align: middle;
}

/* ── Overlay modal ───────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ── Box del modal ───────────────────────────────────── */
.modal-box {
    background: #fff;
    border-radius: 16px;
    padding: 40px 36px 36px;
    width: 100%;
    max-width: 420px;
    position: relative;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
    transform: translateY(20px) scale(0.97);
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.visible .modal-box {
    transform: translateY(0) scale(1);
}

/* ── Chiudi ──────────────────────────────────────────── */
.modal-close {
    position: absolute;
    top: 14px;
    right: 18px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    line-height: 1;
    padding: 4px;
    border-radius: 50%;
    transition: color 0.2s, background 0.2s;
}
.modal-close:hover { color: #333; background: #f0f0f0; }

/* ── Header modal ────────────────────────────────────── */
.modal-header {
    text-align: center;
    margin-bottom: 28px;
}

.modal-logo {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, #1a6fc4, #0d4a8b);
    color: #fff;
    font-size: 1.4rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    box-shadow: 0 4px 16px rgba(26,111,196,0.35);
}

.modal-header h2 {
    margin: 0 0 6px;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1a1a2e;
}

.modal-subtitle {
    margin: 0;
    font-size: 0.82rem;
    color: #888;
    letter-spacing: 0.03em;
}

/* ── Campi form ──────────────────────────────────────── */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: #444;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #dde1e9;
    border-radius: 9px;
    font-size: 0.95rem;
    font-family: inherit;
    background: #f7f8fc;
    color: #1a1a2e;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    box-sizing: border-box;
    outline: none;
}

.form-group input:focus {
    border-color: #1a6fc4;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(26,111,196,0.12);
}

/* ── Campo password con toggle ───────────────────────── */
.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 42px;
}

.toggle-password {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 2px;
    opacity: 0.5;
    transition: opacity 0.2s;
}
.toggle-password:hover { opacity: 0.9; }

/* ── Messaggio di errore ─────────────────────────────── */
.login-error {
    min-height: 20px;
    font-size: 0.82rem;
    color: #d9534f;
    margin-bottom: 14px;
    text-align: center;
    font-weight: 500;
}

/* ── Pulsante submit ─────────────────────────────────── */
.btn-submit {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #1a6fc4, #0d4a8b);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    letter-spacing: 0.03em;
    transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 4px 14px rgba(26,111,196,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-submit:hover:not(:disabled) {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(26,111,196,0.4);
}

.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ── Spinner ─────────────────────────────────────────── */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Toast notifiche ─────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: #1a1a2e;
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 6px 24px rgba(0,0,0,0.22);
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    border-left: 4px solid #1a6fc4;
    max-width: 320px;
    pointer-events: auto;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success  { border-left-color: #28a745; }
.toast-warning  { border-left-color: #ffc107; }
.toast-info     { border-left-color: #1a6fc4; }
.toast-error    { border-left-color: #d9534f; }

/* ── Responsive modal ────────────────────────────────── */
@media (max-width: 480px) {
    .modal-box {
        margin: 16px;
        padding: 28px 20px 24px;
    }
}

/* ══════════════════════════════════════════════════════════
   MODAL ESTESO — form crea/modifica (task, progetti, ecc.)
   ══════════════════════════════════════════════════════════ */

/*
 * .modal-box--wide
 * Variante più larga del modal, usata per i form complessi
 * (crea progetto, crea task) che necessitano di più spazio.
 * Sovrascrive il max-width di default (420px → 560px).
 */
.modal-box--wide {
    max-width: 560px;
    padding:   0;           /* il padding è gestito dalle sezioni interne */
}

/*
 * Intestazione colorata del modal.
 * Striscia blu in cima con titolo bianco — identica allo stile
 * dell'header del drawer (task-drawer-header / proj-drawer-header).
 * La classe va applicata all'<h3> del modal tramite un wrapper <div>.
 *
 * Struttura HTML attesa:
 *   <div class="modal-box modal-box--wide">
 *     <button class="modal-close">×</button>
 *     <div class="modal-header-bar">
 *       <h3 class="modal-header-title" id="…">Nuovo progetto</h3>
 *     </div>
 *     <div class="modal-body">
 *       … campi form …
 *     </div>
 *     <div class="modal-footer">
 *       … pulsanti …
 *     </div>
 *   </div>
 */
.modal-header-bar {
    background:    var(--blue-deep, #0d2b5e);
    padding:       1.1rem 1.25rem 1rem;
    border-radius: 16px 16px 0 0;   /* arrotonda solo i due angoli superiori */
    flex-shrink:   0;
}

.modal-header-title {
    margin:      0;
    font-size:   1.05rem;
    font-weight: 700;
    color:       #fff;
}

/* Pulsante chiudi (×) posizionato in cima a destra sull'header colorato */
.modal-box--wide .modal-close {
    color: rgba(255, 255, 255, 0.75);
    top:   12px;
    right: 14px;
}
.modal-box--wide .modal-close:hover {
    color:      #fff;
    background: rgba(255, 255, 255, 0.15);
}

/*
 * .modal-body
 * Area scrollabile con padding uniforme che contiene i campi del form.
 * Separata da .modal-header-bar e .modal-footer per poter scorrere
 * il contenuto su viewport piccoli senza nascondere i pulsanti.
 */
.modal-body {
    padding:    1.5rem 1.5rem 0.5rem;
    overflow-y: auto;
    max-height: calc(80vh - 120px);  /* lascia spazio a header e footer */
}

/*
 * .modal-footer
 * Banda inferiore fissa con i pulsanti Annulla / Conferma.
 * Separata dal body da un bordo sottile.
 */
.modal-footer {
    padding:     0.85rem 1.5rem 1.25rem;
    border-top:  1px solid #eef0f3;
    display:     flex;
    align-items: center;
    justify-content: flex-end;
    gap:         0.75rem;
    flex-shrink: 0;
}

/*
 * Stile unificato per select nei form modal.
 * I campi <input> sono già stilizzati in .form-group input (sopra);
 * i <select> e <textarea> usavano lo stile nativo del browser.
 * Qui li allineiamo visivamente agli input per coerenza.
 */
.form-group select,
.form-group textarea {
    width:       100%;
    padding:     10px 14px;
    border:      1.5px solid #dde1e9;
    border-radius: 9px;
    font-size:   0.95rem;
    font-family: inherit;
    background:  #f7f8fc;
    color:       #1a1a2e;
    transition:  border-color 0.2s, box-shadow 0.2s, background 0.2s;
    box-sizing:  border-box;
    outline:     none;
    appearance:  none;           /* rimuove la freccia nativa su Safari/Chrome */
    -webkit-appearance: none;
}

/* select: aggiunge una freccia SVG custom a destra */
.form-group select {
    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='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat:   no-repeat;
    background-position: right 12px center;
    padding-right:       36px;   /* spazio per la freccia */
}

.form-group select:focus,
.form-group textarea:focus {
    border-color: #1a6fc4;
    background:   #fff;
    box-shadow:   0 0 0 3px rgba(26, 111, 196, 0.12);
}

/* textarea: non ha freccia, può essere ridimensionata verticalmente */
.form-group textarea {
    resize:     vertical;
    min-height: 90px;
    line-height: 1.55;
}

/*
 * .required — asterisco rosso accanto alle label obbligatorie.
 * Piccolo ma visibile; separato dalla label da mezzo spazio.
 */
.required {
    color:       #c62828;
    font-size:   0.85em;
    margin-left: 2px;
}

/*
 * .modal-actions — riga pulsanti (usata nei modal senza .modal-footer).
 * Mantiene la compatibilità con i modal esistenti che usano questa classe
 * anziché .modal-footer.
 */
.modal-actions {
    display:         flex;
    justify-content: flex-end;
    gap:             0.75rem;
    margin-top:      1.5rem;
    padding-top:     1rem;
    border-top:      1px solid #eef0f3;
}

/*
 * .btn-outline-icon — pulsante secondario con bordo (es. "⚙ Filtri").
 * Stile coerente con .btn-secondary ma più compatto e con bordo visibile.
 */
.btn-outline-icon {
    display:       inline-flex;
    align-items:   center;
    gap:           0.35rem;
    padding:       0.38rem 0.85rem;
    border:        1.5px solid var(--border, #ccc);
    border-radius: 6px;
    background:    #fff;
    color:         var(--text-mid, #555);
    font-size:     0.85rem;
    font-weight:   500;
    cursor:        pointer;
    transition:    border-color 0.15s, color 0.15s, background 0.15s;
    white-space:   nowrap;
}
.btn-outline-icon:hover {
    border-color: var(--blue-mid, #1565c0);
    color:        var(--blue-mid, #1565c0);
    background:   #f0f5ff;
}

/* ── Pulsante chiudi (×) nei modal password ──────────────────
   Sostituisce l'attributo style="" inline per conformità CSP nonce.
   Usato in modal-change-pwd su tutte le pagine autenticate.        */
.modal-pwd-close {
    position:   absolute;
    top:        1rem;
    right:      1rem;
    background: none;
    border:     none;
    font-size:  1.4rem;
    cursor:     pointer;
    color:      #999;
    line-height: 1;
    padding:    0;
    transition: color 0.15s;
}
.modal-pwd-close:hover { color: #333; }