/* ═══════════════════════════════════════════════════════════════
   INVIAL — Auth CSS  |  Mobile-first (Android Material 3)
   Responsive: mobile → tablet → desktop
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

/* ── Variables ── */
:root {
    /* Paleta MTC Perú: azul institucional + acento ámbar vial */
    --primary:        #1a56db;
    --primary-dark:   #1141b0;
    --primary-light:  #e8f0fe;
    --accent:         #f59e0b;
    --accent-dark:    #d97706;

    --surface:        #ffffff;
    --surface-2:      #f8fafc;
    --on-surface:     #1e293b;
    --on-surface-2:   #64748b;
    --outline:        #cbd5e1;
    --outline-focus:  #1a56db;

    --error:          #dc2626;
    --error-light:    #fef2f2;
    --success:        #16a34a;
    --success-light:  #f0fdf4;

    --radius-sm:      8px;
    --radius:         14px;
    --radius-lg:      20px;
    --radius-full:    999px;

    --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
    --shadow:     0 4px 20px rgba(0,0,0,0.10);
    --shadow-lg:  0 8px 40px rgba(0,0,0,0.14);

    --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Roboto', -apple-system, sans-serif;
    background: #e8edf5;
    min-height: 100vh;
    min-height: 100dvh; /* dynamic viewport para mobile */
    color: var(--on-surface);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

/* ══════════════════════════════════════════════════════════════
   LAYOUT RAÍZ
══════════════════════════════════════════════════════════════ */

.auth-root {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ── Header barra de estado estilo Android ── */
.auth-statusbar {
    background: var(--primary-dark);
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 18px;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.auth-statusbar span {
    color: rgba(255,255,255,0.85);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* ── App Bar ── */
.auth-appbar {
    background: var(--primary);
    padding: 0 16px;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    position: sticky;
    top: 28px;
    z-index: 99;
}

.auth-appbar__logo {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.auth-appbar__logo svg { width: 20px; height: 20px; fill: #fff; }

.auth-appbar__title {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1;
}

.auth-appbar__subtitle {
    color: rgba(255,255,255,0.7);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-top: 2px;
}

/* ── Scroll area ── */
.auth-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

/* ══════════════════════════════════════════════════════════════
   CARD
══════════════════════════════════════════════════════════════ */

.auth-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 28px 20px;
    width: 100%;
    max-width: 480px;
}

.auth-card__hero {
    text-align: center;
    margin-bottom: 28px;
}

.auth-card__icon {
    width: 72px;
    height: 72px;
    background: var(--primary-light);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.auth-card__icon svg { width: 36px; height: 36px; fill: var(--primary); }

.auth-card__title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--on-surface);
    letter-spacing: -0.02em;
}

.auth-card__desc {
    font-size: 0.88rem;
    color: var(--on-surface-2);
    margin-top: 6px;
    line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════════
   INPUTS — Material 3 Outlined style
══════════════════════════════════════════════════════════════ */

.field {
    position: relative;
    margin-bottom: 18px;
}

.field__label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--on-surface-2);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.field__label span.req { color: var(--error); margin-left: 2px; }

.field__input,
.field__select {
    width: 100%;
    height: 52px;
    padding: 0 16px;
    border: 1.5px solid var(--outline);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--on-surface);
    background: var(--surface-2);
    outline: none;
    transition: var(--transition);
    -webkit-appearance: none;
    appearance: none;
}

.field__input:focus,
.field__select:focus {
    border-color: var(--outline-focus);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(26,86,219,0.12);
}

.field__input.is-valid  { border-color: var(--success); }
.field__input.is-error  { border-color: var(--error); background: var(--error-light); }

.field__input--with-btn { padding-right: 52px; }

/* Ícono dentro del campo */
.field__inner { position: relative; }

.field__icon {
    position: absolute;
    right: 0;
    top: 0;
    height: 52px;
    width: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--on-surface-2);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    transition: var(--transition);
}

.field__icon:hover { color: var(--primary); }
.field__icon svg   { width: 20px; height: 20px; }

/* Select: flecha custom */
.field__select-wrap { position: relative; }
.field__select-wrap::after {
    content: '';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--on-surface-2);
    pointer-events: none;
}
.field__select { padding-right: 40px; cursor: pointer; }

/* Hint y error bajo el campo */
.field__hint  { font-size: 0.75rem; color: var(--on-surface-2); margin-top: 4px; }
.field__error { font-size: 0.75rem; color: var(--error); margin-top: 4px; display: none; }
.field.has-error .field__error { display: block; }
.field.has-error .field__hint  { display: none; }

/* Chip de resultado RUC */
.ruc-result {
    background: var(--success-light);
    border: 1px solid #bbf7d0;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-top: 8px;
    display: none;
    animation: slideDown 0.2s ease;
}

.ruc-result.visible { display: block; }

.ruc-result__name {
    font-size: 0.92rem;
    font-weight: 700;
    color: #15803d;
}

.ruc-result__meta {
    font-size: 0.75rem;
    color: #166534;
    margin-top: 3px;
    line-height: 1.5;
}

.ruc-error {
    background: var(--error-light);
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    margin-top: 8px;
    font-size: 0.82rem;
    color: var(--error);
    display: none;
}
.ruc-error.visible { display: block; }

/* ══════════════════════════════════════════════════════════════
   BOTONES
══════════════════════════════════════════════════════════════ */

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 52px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }

.btn--primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(26,86,219,0.35);
}

.btn--primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 16px rgba(26,86,219,0.4);
}

.btn--primary:disabled {
    background: var(--outline);
    color: var(--on-surface-2);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.btn--outline {
    background: transparent;
    border: 1.5px solid var(--outline);
    color: var(--on-surface);
}

.btn--outline:hover {
    background: var(--surface-2);
    border-color: var(--primary);
    color: var(--primary);
}

.btn--sm {
    height: 40px;
    font-size: 0.82rem;
    width: auto;
    padding: 0 16px;
}

.btn--ruc {
    background: var(--primary-light);
    color: var(--primary);
    border: 1.5px solid var(--primary);
    height: 52px;
    flex-shrink: 0;
    width: 52px;
    border-radius: var(--radius-sm);
}

.btn--ruc:hover { background: var(--primary); color: #fff; }

/* Ripple effect */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: scale(0);
    animation: ripple-anim 0.5s ease-out forwards;
    pointer-events: none;
}

@keyframes ripple-anim { to { transform: scale(3); opacity: 0; } }

/* ══════════════════════════════════════════════════════════════
   STEPPER — indicador de pasos del registro
══════════════════════════════════════════════════════════════ */

.stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 28px;
}

.stepper__step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
    position: relative;
}

.stepper__step::before {
    content: '';
    position: absolute;
    top: 14px;
    left: 50%;
    width: 100%;
    height: 2px;
    background: var(--outline);
    z-index: 0;
}

.stepper__step:last-child::before { display: none; }

.stepper__dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--outline);
    color: var(--on-surface-2);
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
    transition: var(--transition);
    flex-shrink: 0;
}

.stepper__label {
    font-size: 0.62rem;
    color: var(--on-surface-2);
    letter-spacing: 0.04em;
    text-align: center;
    white-space: nowrap;
}

.stepper__step.active   .stepper__dot { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px rgba(26,86,219,0.15); }
.stepper__step.done     .stepper__dot { background: var(--success); color: #fff; }
.stepper__step.active   .stepper__label { color: var(--primary); font-weight: 600; }
.stepper__step.done     .stepper__label { color: var(--success); }
.stepper__step.done::before { background: var(--success); }
.stepper__step.active::before { background: linear-gradient(to right, var(--success), var(--outline)); }

/* ══════════════════════════════════════════════════════════════
   SECCIONES DEL FORMULARIO (steps)
══════════════════════════════════════════════════════════════ */

.form-step { display: none; }
.form-step.active { display: block; animation: fadeSlide 0.25s ease; }

@keyframes fadeSlide {
    from { opacity: 0; transform: translateX(18px); }
    to   { opacity: 1; transform: translateX(0); }
}

.step-nav {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

/* ══════════════════════════════════════════════════════════════
   DIVIDER / LINK
══════════════════════════════════════════════════════════════ */

.auth-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--on-surface-2);
    font-size: 0.78rem;
    margin: 4px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--outline);
}

.auth-link {
    text-align: center;
    font-size: 0.88rem;
    color: var(--on-surface-2);
}

.auth-link a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.auth-link a:hover { text-decoration: underline; }

/* ══════════════════════════════════════════════════════════════
   ALERTAS
══════════════════════════════════════════════════════════════ */

.auth-alert {
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 0.84rem;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.auth-alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.auth-alert--ok  { background: var(--success-light); color: #15803d; border: 1px solid #bbf7d0; }
.auth-alert--err { background: var(--error-light);   color: var(--error); border: 1px solid #fecaca; }

/* ══════════════════════════════════════════════════════════════
   SPINNER
══════════════════════════════════════════════════════════════ */

.spinner {
    width: 20px; height: 20px;
    border: 2.5px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: none;
}

.spinner.dark {
    border-color: rgba(26,86,219,0.25);
    border-top-color: var(--primary);
}

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

/* ══════════════════════════════════════════════════════════════
   BADGE RUC
══════════════════════════════════════════════════════════════ */

.ruc-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.ruc-row .field { flex: 1; margin-bottom: 0; }

/* ══════════════════════════════════════════════════════════════
   PASSWORD STRENGTH
══════════════════════════════════════════════════════════════ */

.pwd-strength {
    margin-top: 6px;
    display: flex;
    gap: 4px;
}

.pwd-bar {
    flex: 1;
    height: 3px;
    border-radius: 2px;
    background: var(--outline);
    transition: background 0.3s;
}

.pwd-bar.weak   { background: var(--error); }
.pwd-bar.medium { background: var(--accent); }
.pwd-bar.strong { background: var(--success); }

.pwd-label {
    font-size: 0.72rem;
    margin-top: 4px;
    color: var(--on-surface-2);
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (≥ 600px)
══════════════════════════════════════════════════════════════ */

@media (min-width: 600px) {
    .auth-statusbar { height: 32px; }
    .auth-appbar    { height: 64px; padding: 0 24px; }
    .auth-appbar__title { font-size: 1.2rem; }

    .auth-scroll { padding: 40px 24px 60px; }

    .auth-card {
        padding: 36px 32px;
        border-radius: 20px;
        box-shadow: var(--shadow-lg);
    }

    .auth-card__icon { width: 80px; height: 80px; }
    .auth-card__icon svg { width: 40px; height: 40px; }
    .auth-card__title { font-size: 1.5rem; }

    /* Grid de 2 columnas para campos del formulario */
    .field-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 14px;
    }

    .field-row .field { margin-bottom: 0; }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — Desktop (≥ 960px)
══════════════════════════════════════════════════════════════ */

@media (min-width: 960px) {
    body { background: linear-gradient(135deg, #1141b0 0%, #1a56db 40%, #3b82f6 100%); }

    .auth-statusbar { display: none; }
    .auth-appbar    { display: none; }

    .auth-scroll {
        padding: 48px 24px;
        justify-content: center;
        min-height: 100vh;
    }

    /* Logo grande para desktop */
    .desktop-brand {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        margin-bottom: 8px;
    }

    .desktop-brand__logo {
        width: 64px;
        height: 64px;
        background: rgba(255,255,255,0.15);
        border-radius: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        backdrop-filter: blur(10px);
    }

    .desktop-brand__logo svg { width: 36px; height: 36px; fill: #fff; }

    .desktop-brand__name {
        font-size: 1.8rem;
        font-weight: 800;
        color: #fff;
        letter-spacing: 0.08em;
    }

    .desktop-brand__tagline {
        font-size: 0.82rem;
        color: rgba(255,255,255,0.75);
        letter-spacing: 0.1em;
        text-transform: uppercase;
    }

    .auth-card {
        max-width: 520px;
        padding: 40px 40px;
        border-radius: 24px;
        box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    }
}

/* Ocultar desktop-brand en mobile/tablet */
.desktop-brand { display: none; }

@media (min-width: 960px) {
    .desktop-brand { display: flex; }
}

/* ══════════════════════════════════════════════════════════════
   OTP — Inputs de dígito individual estilo teclado numérico
══════════════════════════════════════════════════════════════ */

.otp-inputs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
}

.otp-digit {
    width: 48px;
    height: 58px;
    border: 2px solid var(--outline);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--surface-2);
    outline: none;
    transition: var(--transition);
    caret-color: var(--primary);
    -webkit-appearance: none;
    appearance: none;
}

.otp-digit:focus {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(26,86,219,0.15);
    transform: scale(1.08);
}

.otp-digit.filled {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary-dark);
}

.otp-digit.error {
    border-color: var(--error);
    background: var(--error-light);
    animation: shake 0.35s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-4px); }
    40%       { transform: translateX(4px); }
    60%       { transform: translateX(-3px); }
    80%       { transform: translateX(3px); }
}

@media (min-width: 400px) {
    .otp-digit { width: 52px; height: 62px; }
}

/* Countdown reenviar */
#reenviar-countdown {
    font-size: 0.78rem;
    color: var(--on-surface-2);
    margin-left: 4px;
}
