.auth-section {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
}

.btn-auth-send {
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    padding: 0.3rem;
    max-width: 36px;
    max-height: 36px;
}

.row-digit {
    align-items: center;
    width: max-content;
}

#countdown-timer {
    color: var(--primary-color);
    font-weight: bold;
}

.app-container {
    display: flex;
    flex-direction: row;
    gap: 1vw;
}

.auth-digit {
    background-color: var(--background-alt);
}

/**/

.fancy-card {
    max-width: 350px;
    padding: 30px 25px;
    background: #ffffff;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    text-align: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    height: max-content;
    margin-left: auto;
    margin-right: auto;
}

.fancy-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.12);
}

.fancy-card h3 {
    margin-bottom: 20px;
    font-size: 1.3rem;
    font-weight: bold;
    color: #333;
}

.g_id_signin {
    display: flex;
    justify-content: center;
}

/* ---------------------------- */
/* RESPONSIVE LAYOUT            */
/* ---------------------------- */

.auth-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    gap: 60px;
    padding-top: 20px;
    flex-wrap: nowrap;
}

/* Impila le colonne su tablet */
@media (max-width: 992px) {
    .auth-container {
        flex-direction: column;
        align-items: center;
        gap: 30px;
    }

    .auth-section {
        width: 90%;
        max-width: 500px;
    }

    .fancy-card {
        margin: 0 auto;
    }
}

/* Ottimizzazione per smartphone */
@media (max-width: 600px) {

    .auth-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        gap: 40px;
        width: 100%;
    }

    .auth-section {
        width: 100%;
        max-width: 400px;
        margin: 0 auto;
    }

    .row-digit {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    .auth-digit {
        width: 45px !important;
        height: 45px;
        font-size: 1.2rem;
        text-align: center;
    }

    #qrcode canvas,
    #qrcode img {
        width: 200px !important;
        height: 200px !important;
    }

    .fancy-card {
        width: 100%;
        max-width: 400px;
        margin: 0 auto;
    }
}

/* Mini schermi */
@media (max-width: 400px) {

    .auth-digit {
        width: 38px !important;
        height: 38px;
        font-size: 1rem;
    }

    .fancy-card {
        padding: 20px 15px;
    }
}

/* Layout desktop: QR e Google affiancati */
@media (min-width: 993px) {
    .auth-container {
        display: flex;
        flex-direction: row;
        justify-content: center;
        /* o space-between se li vuoi più larghi */
        align-items: flex-start;
        gap: 60px;
    }

    .auth-section.qr,
    .auth-section.fancy-card {
        flex: 1 1 0;
        max-width: 500px;
        /* opzionale, regola a piacere */
    }

    /* opzionale: evita che la fancy-card si centri “strano” */
    .fancy-card {
        margin-left: 0;
        margin-right: 0;
    }
}

/* Responsive auth refresh */

.auth-page {
    padding-block: clamp(1rem, 4vw, 3rem);
}

.auth-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    gap: clamp(1rem, 3vw, 2.5rem);
    align-items: start;
    justify-items: center;
    width: min(100%, 1100px);
    margin: 0 auto;
    padding-top: 0;
}

.auth-section {
    display: flex;
    justify-content: center;
    width: 100%;
    margin: 0;
}

.auth-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.9rem, 2vw, 1.4rem);
    min-height: 100%;
    padding: clamp(1.25rem, 3vw, 2rem);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    background:
        radial-gradient(circle at top right, rgba(240, 85, 55, 0.08), transparent 36%),
        linear-gradient(180deg, rgba(252, 252, 252, 0.98), rgba(244, 245, 240, 0.96));
    box-shadow: var(--shadow-md);
    text-align: center;
    width: min(100%, 34rem);
    margin-inline: auto;
}

.auth-section--qr .auth-card {
    width: min(100%, 36rem);
}

.auth-section--oauth .auth-card {
    width: min(100%, 30rem);
}

.auth-card__header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
}

.auth-card__header h1,
.auth-card__header h2,
.fancy-card h2 {
    margin: 0;
    font-size: clamp(1.65rem, 4vw, 2.35rem);
    line-height: 1.05;
    color: var(--text-primary);
}

.auth-help-link {
    padding: 0;
    font-size: 0.95rem;
    color: var(--primary-color);
    white-space: normal;
    text-align: center;
}

.auth-error {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(203, 36, 40, 0.18);
    border-radius: var(--radius-md);
    background: rgba(203, 36, 40, 0.08);
    color: var(--danger);
    font-weight: bold;
}

#countdown-timer {
    color: var(--primary-color);
    font-size: 0.98rem;
    font-weight: bold;
}

.auth-qr-frame {
    display: flex;
    justify-content: center;
    align-items: center;
    width: min(100%, 320px);
    padding: clamp(0.85rem, 2vw, 1.2rem);
    border: 1px solid var(--border-color);
    border-radius: calc(var(--radius-xl) - 4px);
    background: var(--background-alt);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

#qrcode {
    display: flex;
    justify-content: center;
    width: 100%;
}

#qrcode canvas,
#qrcode img {
    display: block;
    width: min(100%, 250px) !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
    margin: 0;
    color: var(--text-secondary);
    font-weight: bold;
    text-align: center;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: var(--border-color);
}

.auth-code-form {
    width: 100%;
}

.auth-code-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.85rem;
    width: 100%;
}

.row-digit,
.auth-code-inputs {
    display: grid;
    grid-template-columns: repeat(var(--auth-code-length, 7), minmax(0, 1fr));
    gap: 0.55rem;
    width: 100%;
}

.auth-digit {
    width: 100%;
    min-width: 0;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--background-alt);
    color: var(--text-primary);
    text-align: center;
    font-size: clamp(1rem, 2.6vw, 1.25rem);
    font-weight: bold;
}

.auth-digit:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--background-active);
}

.btn-auth-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 3.5rem;
    min-width: 3.5rem;
    height: 3.5rem;
    padding: 0;
    border-radius: 1rem;
    max-width: none;
    max-height: none;
}

.btn-auth-send__label {
    display: none;
}

.fancy-card {
    justify-content: center;
    max-width: none;
    width: 100%;
    margin: 0;
}

.g_id_signin {
    display: flex;
    justify-content: center;
    width: 100%;
    overflow: hidden;
}

.g_id_signin > div {
    max-width: 100%;
}

.app-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.85rem;
    width: 100%;
    margin-top: 1rem;
}

.app-badge {
    display: block;
    width: min(100%, 180px);
}

.app-badge img {
    display: block;
    width: 100%;
    height: auto;
}

@media (max-width: 640px) {
    .auth-page {
        padding-block: 1rem 2rem;
    }

    .auth-container {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .auth-code-controls {
        grid-template-columns: 1fr;
    }

    .btn-auth-send {
        width: 100%;
        min-width: 0;
        height: auto;
        min-height: 3.25rem;
        border-radius: var(--radius-md);
    }

    .btn-auth-send__label {
        display: inline;
    }
}

@media (max-width: 420px) {
    .auth-card {
        padding-inline: 1rem;
    }

    .row-digit,
    .auth-code-inputs {
        gap: 0.4rem;
    }

    .auth-digit {
        font-size: 0.95rem;
    }
}
