/* =====================================================================
   login.css - pagina di accesso (login.php di Leadflow)
   Pannello di presentazione a sinistra, card del form a destra.
   ===================================================================== */

@keyframes es-pop      { from { opacity: 0; transform: scale(.6) translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes es-bob      { 0%, 100% { translate: 0 0; } 50% { translate: 0 -8px; } }
@keyframes es-in-right { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes es-spin     { to { transform: rotate(360deg); } }
@keyframes es-draw     { to { stroke-dashoffset: 0; } }
@keyframes es-shake-a  { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-8px); } 40%, 60% { transform: translateX(8px); } }
@keyframes es-shake-b  { 10%, 90% { transform: translateX(-2px); } 20%, 80% { transform: translateX(4px); } 30%, 50%, 70% { transform: translateX(-8px); } 40%, 60% { transform: translateX(8px); } }
@keyframes es-out      { to { opacity: 0; transform: scale(.97); } }
@keyframes es-sheen    { from { transform: translateX(-120%); } to { transform: translateX(220%); } }

.es-up { animation: es-up .6s cubic-bezier(.2, .8, .2, 1) both; }

.login {
    min-height: 100vh;
    display: flex;
    flex-wrap: wrap;
    background: var(--es-bg);
    color: var(--es-ink);
}

.login.is-leaving { animation: es-out .45s ease forwards; }

/* ---- Pannello di presentazione ------------------------------------- */
.login-hero {
    flex: 1 1 480px;
    position: relative;
    overflow: hidden;
    background: var(--es-navy);
    color: #ffffff;
    padding: 40px 48px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 40px;
    min-height: 340px;
}

.login-brand {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.login-brand-name { font-weight: 800; font-size: 20px; line-height: 22px; letter-spacing: -.01em; }
.login-brand-sub  { font-weight: 500; font-size: 12px; opacity: .75; }

.login-tiles {
    position: absolute;
    /* Griglia larga 352px (4 x 76 + 3 x 16). Centrata nello spazio libero a destra del testo
       (che termina a 468px = padding 48 + testo 380 + respiro 40); se il pannello e' troppo
       stretto per contenerla, resta la posizione del template (sporge di 40px a destra). */
    left: min(calc((100% + 468px) / 2 - 176px), calc(100% - 312px));
    top: 90px;
    display: grid;
    grid-template-columns: repeat(4, 76px);
    gap: 16px;
}

.login-tile {
    height: 76px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, .07);
    animation: es-pop .7s cubic-bezier(.2, .9, .3, 1.2) both, es-bob 6s ease-in-out infinite;
}

.login-tile.t-slate  { background: #3f6283; }
.login-tile.t-orange { background: #c76a00; }
.login-tile.t-red    { background: #c0432a; }
.login-tile.t-amber  { background: var(--es-amber); }
.login-tile.t-teal   { background: #0d7f81; }
.login-tile.t-green  { background: #26834a; }
.login-tile.t-purple { background: #7d3a8c; }
.login-tile.t-blue   { background: var(--es-blue); }
.login-tile.t-gray   { background: #5f6775; }

/* Entrata a cascata + oscillazione sfasata, come nel template */
.login-tile:nth-child(1)  { animation-delay: .05s, 0s; }
.login-tile:nth-child(2)  { animation-delay: .12s, -1s; }
.login-tile:nth-child(3)  { animation-delay: .19s, -2.4s; }
.login-tile:nth-child(4)  { animation-delay: .26s, -3s; }
.login-tile:nth-child(5)  { animation-delay: .33s, -.6s; }
.login-tile:nth-child(6)  { animation-delay: .40s, -4.2s; }
.login-tile:nth-child(7)  { animation-delay: .47s, -1.8s; }
.login-tile:nth-child(8)  { animation-delay: .54s, -5s; }
.login-tile:nth-child(9)  { animation-delay: .61s, -2s; }
.login-tile:nth-child(10) { animation-delay: .68s, -3.6s; }
.login-tile:nth-child(11) { animation-delay: .75s, -.3s; }
.login-tile:nth-child(12) { animation-delay: .82s, -4.8s; }
.login-tile:nth-child(13) { animation-delay: .89s, -1.2s; }
.login-tile:nth-child(14) { animation-delay: .96s, -2.7s; }
.login-tile:nth-child(15) { animation-delay: 1.03s, -3.9s; }
.login-tile:nth-child(16) { animation-delay: 1.10s, -.9s; }

.login-claim { position: relative; z-index: 1; max-width: 380px; }

.login-title {
    margin: 0;
    font-size: 44px;
    line-height: 48px;
    font-weight: 800;
    letter-spacing: -.02em;
    animation-delay: .2s;
}

.login-lead {
    margin: 16px 0 0;
    font-size: 16px;
    line-height: 24px;
    color: #c9d4e6;
    animation-delay: .32s;
}

.login-chips {
    margin-top: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    animation-delay: .44s;
}

.login-chip {
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .1);
    font-size: 12px;
    font-weight: 600;
}

.login-host {
    position: relative;
    z-index: 1;
    font-size: 12px;
    color: #9fb0cc;
    animation-delay: .5s;
}

/* ---- Card del form ------------------------------------------------- */
.login-side {
    flex: 1 1 460px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    box-sizing: border-box;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border: 1px solid var(--es-line);
    border-radius: 22px;
    padding: 40px 36px;
    box-sizing: border-box;
    box-shadow: 0 30px 60px -30px rgba(15, 27, 51, .28);
    display: flex;
    flex-direction: column;
    gap: 18px;
    animation: es-in-right .7s cubic-bezier(.2, .8, .2, 1) .15s both;
}

.login-fields { display: flex; flex-direction: column; gap: 18px; }
.login-fields.es-shake-a { animation: es-shake-a .5s both; }
.login-fields.es-shake-b { animation: es-shake-b .5s both; }

.login-card h2 {
    margin: 0;
    font-size: 28px;
    line-height: 34px;
    font-weight: 800;
    letter-spacing: -.01em;
}

.login-intro {
    margin: 6px 0 0;
    font-size: 14px;
    line-height: 21px;
    color: var(--es-muted);
}

.es-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    font-size: 13px;
    font-weight: 600;
}

.es-label-row { display: flex; justify-content: space-between; }
.es-label-row label { margin: 0; }

.es-link { font-weight: 600; text-decoration: none; }

.es-field {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 48px;
    padding: 0 14px;
    border: 1.5px solid var(--es-line);
    border-radius: 12px;
    background: var(--es-bg);
    transition: border-color .2s, box-shadow .2s, background .2s;
}

.es-field--pw { padding: 0 6px 0 14px; }

.es-field:focus-within {
    border-color: var(--es-blue);
    box-shadow: 0 0 0 4px rgba(31, 95, 168, .16);
    background: #ffffff;
}

.es-field.is-invalid { border-color: var(--es-danger); }

.es-field input {
    all: unset;
    flex: 1;
    min-width: 0;
    font: 500 15px/22px var(--es-font);
    color: var(--es-ink);
}

.es-field input::placeholder { color: #7a8496; }

.es-eye {
    all: unset;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: var(--es-muted);
}

.es-eye:focus-visible,
.es-link:focus-visible { outline: 2px solid var(--es-blue); outline-offset: 3px; }

.login-error {
    font-size: 12px;
    font-weight: 600;
    color: var(--es-danger);
}

.login-remember {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 14px;
    color: var(--es-muted);
    cursor: pointer;
}

.login-remember input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--es-blue);
}

/* ---- Pulsante Accedi con stati idle / loading / ok ----------------- */
.login-submit {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 52px;
    border: 0;
    border-radius: 12px;
    background: var(--es-blue);
    color: #ffffff;
    font-family: var(--es-font);
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform .15s, box-shadow .2s, background .2s;
}

.login-submit:hover { transform: translateY(-1px); box-shadow: 0 12px 24px -10px rgba(31, 95, 168, .7); }
.login-submit:active { transform: translateY(0); }
.login-submit:focus-visible { outline: 2px solid var(--es-blue); outline-offset: 3px; }
.login-submit:disabled { cursor: default; }

.login-submit::after {
    content: "";
    position: absolute;
    inset: 0;
    width: 40%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .28), transparent);
    transform: translateX(-120%);
}

.login-submit:hover::after { animation: es-sheen .9s ease; }

.login-submit[data-stato="ok"] { background: var(--es-success); }

.login-submit .stato { display: none; align-items: center; gap: 10px; }
.login-submit[data-stato="idle"]    .stato-idle,
.login-submit[data-stato="loading"] .stato-loading,
.login-submit[data-stato="ok"]      .stato-ok { display: flex; }

.es-spin  { animation: es-spin .8s linear infinite; }
.es-check { stroke-dasharray: 30; stroke-dashoffset: 30; animation: es-draw .45s ease .1s forwards; }

.login-foot {
    margin: 4px 0 0;
    text-align: center;
    font-size: 12px;
    line-height: 18px;
    color: var(--es-muted);
}

/* ---- Schermi piccoli: le tessere decorative coprirebbero il testo -- */
@media (max-width: 720px) {
    .login-hero { padding: 28px 24px; min-height: 0; gap: 28px; }
    .login-tiles { display: none; }
    .login-title { font-size: 34px; line-height: 38px; }
    .login-card { padding: 32px 22px; }
}

/* ---- Richiesta di accesso (al posto della registrazione di ERPSuite) ---- */
.login-sep { display: flex; align-items: center; gap: 12px; margin: 2px 0 -4px; color: var(--es-muted); font-size: 12.5px; }
.login-sep::before, .login-sep::after { content: ""; flex: 1; height: 1px; background: var(--es-line); }
.login-demo { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px dashed #c9dcf2; border-radius: 14px; background: #f4f8fd; font-size: 12.5px; color: #184c86; }
.login-demo b { font-family: var(--es-mono); font-weight: 500; }
