/*
 * Auth pages: login, forgotPassword, cambiaPassword (reset+change), accessoNegato.
 *
 * Pagine pubbliche / pre-dashboard, hanno layout proprio (niente sidebar/navbar).
 * Token visivi allineati a static/css/common.css per coerenza con la dashboard.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --auth-primary: #dc2626;
    --auth-primary-dark: #b91c1c;
    --auth-gradient: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    --auth-bg: #f9fafb;
    --auth-card: rgba(255, 255, 255, 0.08);
    --auth-card-border: rgba(255, 255, 255, 0.18);
    --auth-text: #1f2937;
    --auth-muted: #6b7280;
    --auth-success: #10b981;
    --auth-error: #ef4444;
    --auth-warning: #f59e0b;
    --auth-info: #3b82f6;
    --auth-radius: 18px;
    --auth-radius-sm: 12px;
    --auth-shadow: 0 25px 50px -12px rgba(185, 28, 28, 0.35);
    --auth-shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { min-height: 100%; }

body.auth {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--auth-text);
    background: var(--auth-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(circle at 18% 22%, rgba(220, 38, 38, 0.07) 0%, transparent 55%),
        radial-gradient(circle at 82% 78%, rgba(185, 28, 28, 0.07) 0%, transparent 55%),
        var(--auth-bg);
}

input, button, select, textarea {
    font-family: inherit;
    font-size: 16px; /* evita zoom iOS */
}

a { color: inherit; }

/* ===== Card principale ===== */
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--auth-gradient);
    border-radius: var(--auth-radius);
    padding: 40px 32px;
    box-shadow: var(--auth-shadow);
    color: #fff;
    position: relative;
    animation: auth-in 0.5s cubic-bezier(.2,.8,.2,1);
}

.auth-card.wide { max-width: 520px; }

@keyframes auth-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.auth-header { text-align: center; margin-bottom: 28px; }

.auth-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #fff 0%, #f3f4f6 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}
.auth-logo i { font-size: 30px; color: var(--auth-primary); }

.auth-title {
    font-size: clamp(1.4rem, 3vw, 1.75rem);
    font-weight: 700;
    letter-spacing: -0.01em;
}
.auth-subtitle {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.78);
    margin-top: 6px;
}

/* ===== Form ===== */
.auth-form { display: flex; flex-direction: column; gap: 18px; }

.field { position: relative; }

.field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.field .control {
    position: relative;
    display: flex;
    align-items: center;
}

.field .control i.input-icon {
    position: absolute;
    left: 16px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 15px;
    pointer-events: none;
}

.field input {
    width: 100%;
    padding: 14px 16px 14px 46px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--auth-radius-sm);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
}

.field input::placeholder { color: rgba(255, 255, 255, 0.55); }

.field input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.14);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
}

.field .toggle-pwd {
    position: absolute;
    right: 12px;
    background: none;
    border: 0;
    color: rgba(255, 255, 255, 0.65);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
}
.field .toggle-pwd:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

.field .help { font-size: 0.8rem; color: rgba(255, 255, 255, 0.7); margin-top: 6px; }

.field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: -4px;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.9rem;
    user-select: none;
}
.checkbox input { accent-color: #fff; width: 16px; height: 16px; }

.link {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.link:hover { color: #fff; text-decoration: underline; }

/* ===== Bottoni ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    border-radius: var(--auth-radius-sm);
    border: 0;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
    text-decoration: none;
}
.btn-primary {
    background: #fff;
    color: var(--auth-primary-dark);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.65; cursor: not-allowed; transform: none; }

.btn-ghost {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.18);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.14); }

.btn-block { width: 100%; }

/* spinner inline */
.btn .spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.15);
    border-top-color: var(--auth-primary-dark);
    border-radius: 50%;
    display: none;
    animation: auth-spin 0.7s linear infinite;
}
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading .label { opacity: 0.6; }

@keyframes auth-spin { to { transform: rotate(360deg); } }

/* ===== Flash ===== */
.flash-stack { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }

.flash {
    background: rgba(255, 255, 255, 0.95);
    color: var(--auth-text);
    border-radius: var(--auth-radius-sm);
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: var(--auth-shadow-soft);
    border-left: 4px solid var(--auth-info);
    font-size: 0.92rem;
}
.flash.error   { border-left-color: var(--auth-error); }
.flash.success { border-left-color: var(--auth-success); }
.flash.warning { border-left-color: var(--auth-warning); }
.flash i { margin-top: 2px; }
.flash.error i   { color: var(--auth-error); }
.flash.success i { color: var(--auth-success); }
.flash.warning i { color: var(--auth-warning); }
.flash.info i    { color: var(--auth-info); }

/* ===== Footer ===== */
.auth-footer {
    margin-top: 26px;
    text-align: center;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.85rem;
}
.auth-footer a { color: #fff; text-decoration: none; font-weight: 600; }
.auth-footer a:hover { text-decoration: underline; }
.auth-footer .divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.15);
    margin: 18px 0;
}

/* ===== Pagine "messaggio" (forgot success, accesso negato) ===== */
.message-card {
    text-align: center;
}
.message-card .auth-logo i { font-size: 34px; }
.message-card.danger { background: linear-gradient(135deg, #dc2626 0%, #7f1d1d 100%); }
.message-card .auth-title { margin-top: 4px; }
.message-card p {
    margin-top: 12px;
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* ===== Password requirements ===== */
.pwd-rules {
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.85);
}
.pwd-rules ul { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.pwd-rules li { display: flex; align-items: center; gap: 6px; }
.pwd-rules li::before {
    content: '\f111'; /* circle */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 8px;
    color: rgba(255, 255, 255, 0.45);
}
.pwd-rules li.ok { color: #fff; }
.pwd-rules li.ok::before { content: '\f00c'; color: #d1fae5; font-size: 11px; }

/* ===== Responsive ===== */
@media (max-width: 480px) {
    body.auth { padding: 16px; }
    .auth-card { padding: 32px 22px; border-radius: 16px; }
    .pwd-rules ul { grid-template-columns: 1fr; }
    .field-row { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-card { animation: none; }
    .btn { transition: none; }
}
