:root {
    --blue-50: #E6F4FB;
    --blue-100: #BCE0F3;
    --blue-500: #40ACE6;
    --blue-700: #1E7BAB;
    --blue-900: #0F4E72;
    --gray-50: #F7F8FA;
    --gray-100: #F1F2F4;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-900: #1F2937;
    --ow-font-sans: 'DM Sans', system-ui, sans-serif;
    --ow-r-sm: 6px;
    --ow-r-md: 10px;
    --ow-r-lg: 14px;
    --ow-r-pill: 999px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: var(--ow-font-sans);
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-900);
    background: var(--gray-50);
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   2. LAYOUT GENERALE
   ------------------------------------------------------------
   Desktop: 2 colonne 50/50.
   Mobile: solo colonna form, panel sx nascosto.
   ============================================================ */
.login-app {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
}

/* ============================================================
   3. SIDE PANEL (sinistra, desktop only)
   ============================================================ */
.login-visual {
    position: relative;
    background: linear-gradient(135deg, var(--blue-700) 0%, var(--blue-900) 100%);
    color: white;
    padding: 48px 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}

/* Decorazione SVG di sfondo (linee astratte tipo sparkline) */
.login-visual__decoration {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.25;
}

.login-visual__decoration svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Brand block (in alto sx) */
.login-visual__brand {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 12px;
}

.login-visual__brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--blue-500) 0%, var(--blue-700) 100%);
    display: grid;
    place-items: center;
    color: white;
    font-weight: 700;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
}

.login-visual__brand-name {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.login-visual__brand-sub {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 2px;
    font-weight: 500;
}

/* Hero text (centro) */
.login-visual__hero {
    position: relative;
    z-index: 2;
    max-width: 480px;
}

.login-visual__title {
    font-size: 36px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin: 0 0 18px;
}

.login-visual__subtitle {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1.55;
    max-width: 420px;
}

/* Feature list (sotto hero) */
.login-visual__features {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 28px;
}

.login-visual__feature {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.88);
}

.login-visual__feature i {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    display: grid;
    place-items: center;
    font-size: 12px;
    color: white;
    flex-shrink: 0;
}

/* Footer del panel (in basso sx) */
.login-visual__footer {
    position: relative;
    z-index: 2;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.login-visual__footer a {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-weight: 500;
}

.login-visual__footer a:hover {
    color: white;
    text-decoration: underline;
}

.login-visual__footer .sep {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
}

/* ============================================================
   4. FORM PANEL (destra)
   ============================================================ */
.login-form-panel {
    background: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    position: relative;
}

.login-form-wrap {
    width: 100%;
    max-width: 400px;
}

/* Mobile-only header (logo small) */
.login-mobile-brand {
    display: none;
    align-items: center;
    gap: 10px;
    margin-bottom: 32px;
}

.login-mobile-brand__mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--blue-500) 0%, var(--blue-700) 100%);
    display: grid;
    place-items: center;
    color: white;
    font-weight: 700;
    font-size: 15px;
}

.login-mobile-brand__name {
    font-size: 17px;
    font-weight: 600;
    color: var(--gray-900);
}

/* Titolo form */
.login-form-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--gray-900);
    letter-spacing: -0.01em;
    margin: 0 0 6px;
}

.login-form-subtitle {
    font-size: 13px;
    color: var(--gray-500);
    margin: 0 0 28px;
}

/* Form */
.form-floating {
    position: relative;
    margin-bottom: 14px;
}

.form-floating input {
    width: 100%;
    height: 56px;
    padding: 22px 14px 8px;
    border: 1px solid var(--gray-300);
    border-radius: var(--ow-r-md);
    font-family: var(--ow-font-sans);
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-900);
    background: white;
    outline: none;
    transition: border-color 120ms, box-shadow 120ms;
}

.form-floating input:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px var(--blue-50);
}

.form-floating input::placeholder {
    color: transparent;
}

.form-floating label {
    position: absolute;
    top: 50%;
    left: 14px;
    transform: translateY(-50%);
    font-size: 14px;
    color: var(--gray-500);
    pointer-events: none;
    transition: all 150ms cubic-bezier(0.32, 0.72, 0, 1);
    background: transparent;
}

.form-floating input:focus+label,
.form-floating input:not(:placeholder-shown)+label {
    top: 11px;
    transform: translateY(0);
    font-size: 11px;
    color: var(--blue-700);
    font-weight: 600;
}

/* Toggle password visibility */
.form-floating__toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--gray-400);
    display: grid;
    place-items: center;
    cursor: pointer;
    border-radius: var(--ow-r-sm);
    font-size: 18px;
}

.form-floating__toggle:hover {
    color: var(--gray-700);
    background: var(--gray-50);
}

/* Remember + forgot row */
.form-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 10px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.form-check input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--blue-500);
    cursor: pointer;
}

.form-check label {
    font-size: 13px;
    color: var(--gray-600);
    cursor: pointer;
    font-weight: 500;
}

.form-link {
    font-size: 13px;
    color: var(--blue-700);
    font-weight: 500;
    text-decoration: none;
}

.form-link:hover {
    text-decoration: underline;
    color: var(--blue-900);
}

/* Submit button */
.btn-login {
    width: 100%;
    min-height: 50px;
    padding: 0 16px;
    background: var(--blue-500);
    color: white;
    border: none;
    border-radius: var(--ow-r-md);
    font-family: var(--ow-font-sans);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 120ms;
}

.btn-login:hover {
    background: var(--blue-700);
}

.btn-login:active {
    transform: translateY(1px);
}

.btn-login:disabled {
    background: var(--gray-400);
    cursor: not-allowed;
}

.btn-login i {
    font-size: 18px;
}

/* Error message */
.login-error {
    margin-top: 16px;
    padding: 10px 14px;
    background: var(--gray-100);
    border: 0.5px solid var(--gray-300);
    border-left: 3px solid var(--gray-700);
    border-radius: var(--ow-r-sm);
    font-size: 12px;
    color: var(--gray-700);
    display: none;
    gap: 8px;
    align-items: center;
}

.login-error.is-visible {
    display: flex;
}

.login-error i {
    color: var(--gray-700);
    font-size: 14px;
    flex-shrink: 0;
}

/* Bottom helper */
.login-helper {
    text-align: center;
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 22px;
}

.login-helper a {
    color: var(--blue-700);
    text-decoration: none;
    font-weight: 500;
}

.login-helper a:hover {
    text-decoration: underline;
}

/* Footer panel (mobile only) */
.login-form-panel__footer {
    display: none;
    font-size: 11px;
    color: var(--gray-400);
    text-align: center;
    margin-top: 32px;
    padding-top: 22px;
    border-top: 0.5px solid var(--gray-200);
    width: 100%;
}

.login-form-panel__footer a {
    color: var(--gray-500);
    text-decoration: none;
}

/* Spinner overlay durante submit */
.spinner-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.spinner-overlay.is-visible {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--blue-100);
    border-top-color: var(--blue-500);
    border-radius: 50%;
    animation: spin 800ms linear infinite;
}

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

/* ============================================================
   5. MEDIA QUERIES MOBILE
   ============================================================ */
@media (max-width: 768px) {
    .login-app {
        grid-template-columns: 1fr;
    }

    .login-visual {
        display: none;
    }

    .login-form-panel {
        padding: 32px 24px;
        min-height: 100vh;
        justify-content: flex-start;
        padding-top: 48px;
    }

    .login-mobile-brand {
        display: flex;
    }

    .login-form-title {
        font-size: 20px;
    }

    .form-floating input {
        font-size: 16px;
        /* evita zoom iOS */
    }

    .btn-login {
        min-height: 52px;
    }

    .login-form-panel__footer {
        display: block;
    }
}

/* Tablet/laptop intermedi: meno padding panel sx */
@media (min-width: 769px) and (max-width: 1024px) {
    .login-visual {
        padding: 36px 40px;
    }

    .login-visual__title {
        font-size: 28px;
    }

    .login-form-panel {
        padding: 32px;
    }
}

/* Accessibility: focus visibile */
button:focus-visible,
input:focus-visible,
a:focus-visible {
    outline: 2px solid var(--blue-500);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}