/* ==========================================================================
   Login (redesign) — foglio di stile isolato, usato solo da login-new.php
   Non tocca app.css di produzione: pagina di test indipendente.
   ========================================================================== */

:root {
    --bg: #f6f4ee;
    --surface: #ffffff;
    --surface-alt: #f6f4ee;
    --border: #e4ddcf;
    --border-strong: #d2c8b4;
    --text: #24211b;
    --text-muted: #6b6558;
    --text-faint: #96907f;

    --ink: #123b56;

    --primary: #1c6fa8;
    --primary-ink: #0f2e44;
    --accent-soft: rgba(28, 111, 168, 0.08);
    --focus-ring: rgba(28, 111, 168, 0.16);

    --success: #1f7a52;
    --success-bg: #e8f3ec;
    --danger: #a3324f;
    --danger-bg: #f6e9ed;

    --shadow-sm: 0 1px 2px rgba(36, 33, 27, 0.05);
    --shadow-md: 0 10px 24px -12px rgba(18, 59, 86, 0.18);

    --radius-sm: 7px;
    --radius: 13px;

    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #14181b;
    --surface: #1b2124;
    --surface-alt: #20272b;
    --border: #2c3438;
    --border-strong: #3a4448;
    --text: #eae7e0;
    --text-muted: #a3aab0;
    --text-faint: #6d757a;

    --ink: #d7e9f4;

    --primary: #4f9bd6;
    --primary-ink: #dceaf5;
    --accent-soft: rgba(79, 155, 214, 0.1);
    --focus-ring: rgba(79, 155, 214, 0.22);

    --success: #4bbd8c;
    --success-bg: rgba(75, 189, 140, 0.12);
    --danger: #d8788f;
    --danger-bg: rgba(216, 120, 143, 0.12);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 26px -12px rgba(0, 0, 0, 0.5);

    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #14181b;
        --surface: #1b2124;
        --surface-alt: #20272b;
        --border: #2c3438;
        --border-strong: #3a4448;
        --text: #eae7e0;
        --text-muted: #a3aab0;
        --text-faint: #6d757a;

        --ink: #d7e9f4;

        --primary: #4f9bd6;
        --primary-ink: #dceaf5;
        --accent-soft: rgba(79, 155, 214, 0.1);
        --focus-ring: rgba(79, 155, 214, 0.22);

        --success: #4bbd8c;
        --success-bg: rgba(75, 189, 140, 0.12);
        --danger: #d8788f;
        --danger-bg: rgba(216, 120, 143, 0.12);

        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body.login-new-body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.login-page {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    overflow: hidden;
}

/* brand watermark — il marchio IRIS per intero (fumetto + fiore), in
   filigrana dietro la card: dà peso al brand senza gareggiare col testo. */
.login-watermark {
    position: absolute;
    right: -8%;
    bottom: -14%;
    width: 780px;
    height: 780px;
    opacity: 0.07;
    color: var(--ink);
    pointer-events: none;
}

@media (max-width: 640px) {
    .login-watermark { width: 460px; height: 460px; }
}

.theme-toggle {
    position: absolute;
    top: 22px;
    right: 22px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-faint);
    z-index: 2;
}

.theme-toggle:hover { color: var(--primary); border-color: var(--border-strong); }
.theme-toggle svg { width: 15px; height: 15px; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.login-wrap {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
}

.login-brand-row {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
}

.login-brand-row .brand-logo { height: 100px; width: auto; display: block; }
.login-brand-row .logo-dark { display: none; }
:root[data-theme="dark"] .login-brand-row .logo-light { display: none; }
:root[data-theme="dark"] .login-brand-row .logo-dark { display: block; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .login-brand-row .logo-light { display: none; }
    :root:not([data-theme="light"]) .login-brand-row .logo-dark { display: block; }
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 34px 32px 28px;
}

.login-card h1 {
    font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.005em;
    color: var(--text);
    margin: 0 0 6px;
}

.login-card p.lede {
    margin: 0 0 24px;
    color: var(--text-muted);
    font-size: 13.5px;
}

.login-alert {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border-left: 3px solid transparent;
    font-size: 13px;
    margin-bottom: 18px;
}

.login-alert svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 2px; }
.login-alert.error { background: var(--danger-bg); color: var(--danger); border-left-color: var(--danger); }
.login-alert.success { background: var(--success-bg); color: var(--success); border-left-color: var(--success); }

.login-field {
    margin-bottom: 16px;
}

.login-field-control {
    position: relative;
}

.login-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.login-field input {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
    outline: none;
    padding: 10px 38px 10px 12px;
    font-size: 14.5px;
    color: var(--text);
    font-family: inherit;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.login-field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
    background: var(--surface);
}

.login-field.has-error input { border-color: var(--danger); }

.login-field-toggle {
    position: absolute;
    right: 6px;
    top: 5px;
    border: none;
    background: transparent;
    color: var(--text-faint);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 6px;
}

.login-field-toggle:hover { color: var(--primary); }
.login-field-toggle svg { width: 16px; height: 16px; }
.login-field-toggle .icon-eye-off { display: none; }

.login-field-hint {
    font-size: 11.5px;
    color: var(--text-faint);
    margin-top: 5px;
    min-height: 14px;
}

.login-field-hint.show-caps { color: #9a6a17; }

.login-field-error-msg {
    font-size: 11.5px;
    color: var(--danger);
    margin-top: 5px;
    display: none;
}

.login-field.has-error .login-field-error-msg { display: block; }

.login-row-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 2px 0 20px;
    font-size: 12.5px;
    gap: 10px;
}

.login-check {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    color: var(--text-muted);
    user-select: none;
    white-space: nowrap;
}

.login-check input {
    width: 14px;
    height: 14px;
    accent-color: var(--primary);
    cursor: pointer;
}

.login-forgot {
    color: var(--text-faint);
    text-align: right;
}

.login-submit {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary-ink, var(--ink));
    background: var(--ink);
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.12s ease;
}

:root[data-theme="dark"] .login-submit { background: var(--primary); color: #0e1720; }

.login-submit:hover { opacity: 0.92; }
.login-submit:active { opacity: 0.86; }

.login-submit.is-loading { pointer-events: none; opacity: 0.75; }
.login-submit .spinner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    display: none;
    animation: spin 0.7s linear infinite;
}

.login-submit.is-loading .spinner { display: inline-block; }

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

.login-demo-toggle {
    display: block;
    width: 100%;
    text-align: center;
    background: none;
    border: none;
    color: var(--text-faint);
    font-size: 12px;
    padding: 16px 0 2px;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: var(--border-strong);
    text-underline-offset: 3px;
}

.login-demo-toggle:hover { color: var(--primary); }

.login-demo-panel {
    display: none;
    margin-top: 10px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.login-demo-panel.is-open { display: block; }

.login-demo-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    font-size: 12.5px;
}

.login-demo-row .role { color: var(--text-muted); font-weight: 600; }
.login-demo-row .cred { color: var(--text-faint); font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 11.5px; }

.login-demo-row button {
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 9px;
    border-radius: 6px;
    cursor: pointer;
}

.login-demo-row button:hover { border-color: var(--primary); color: var(--primary); }

.login-foot {
    margin-top: 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-faint);
}

.login-foot a {
    color: var(--text-muted);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.login-foot a svg { width: 13px; height: 13px; }
.login-foot a:hover { color: var(--primary); }
