/* ==========================================================================
   OTP Login - Estilos
   Usa variables CSS para el color de marca: otplogin.js detecta el color
   real del botón nativo de cada tema y lo aplica aquí en tiempo real, así
   el módulo se ve "de la casa" sin importar qué tema esté activo.
   ========================================================================== */

:root {
    --otplogin-accent: #e30613;
    --otplogin-accent-dark: #b70510;
    --otplogin-text: #222222;
    --otplogin-muted: #6b6b6b;
    --otplogin-border: #e2e2e2;
    --otplogin-bg: #ffffff;
    --otplogin-error-bg: #fdecea;
    --otplogin-error-text: #b71c1c;
    --otplogin-success-bg: #e8f7ec;
    --otplogin-success-text: #1e7e34;
    --otplogin-radius: 14px;
}

/* ---- Botón disparador: SOLO reglas estructurales -----------------------
   El color, tamaño, tipografía, radio, etc. los aporta el propio tema
   (otplogin.js copia las clases del botón nativo de login/checkout).
   Esta clase NO debe imponer colores, o pisaría el estilo del tema. */
.otplogin-trigger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    cursor: pointer;
}

.otplogin-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Grupo lado a lado: botón nativo de login + botón OTP */
.otplogin-inline-group {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    margin: 10px 0;
}

.otplogin-inline-group > * {
    flex: 1 1 180px;
    margin: 0 !important;
}

@media (max-width: 480px) {
    .otplogin-inline-group {
        flex-direction: column;
    }
    .otplogin-inline-group > * {
        flex: 1 1 auto;
        width: 100%;
    }
}

/* ---- Botón de respaldo (solo si no se encontró ningún botón nativo
   de referencia en el formulario detectado) — usa el diseño propio. */
.otplogin-trigger-wrapper {
    margin: 12px 0;
    width: 100%;
}

.otplogin-trigger-btn--fallback {
    width: 100%;
    padding: 11px 18px;
    background: #ffffff;
    color: var(--otplogin-accent);
    border: 2px solid var(--otplogin-accent);
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    transition: background-color .15s ease, color .15s ease, transform .05s ease;
}

.otplogin-trigger-btn--fallback:hover {
    background: var(--otplogin-accent);
    color: #ffffff;
}

.otplogin-trigger-btn--fallback:active {
    transform: scale(0.99);
}

/* ---- Overlay / modal ---- */
.otplogin-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 20, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    padding: 16px;
    animation: otplogin-fade-in .15s ease-out;
}

.otplogin-overlay[hidden] {
    display: none !important;
}

@keyframes otplogin-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.otplogin-modal {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    background: var(--otplogin-bg);
    border-radius: var(--otplogin-radius);
    padding: 30px 26px 26px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    text-align: center;
    animation: otplogin-pop-in .18s ease-out;
}

@keyframes otplogin-pop-in {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.otplogin-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    color: var(--otplogin-muted);
    cursor: pointer;
    padding: 4px 8px;
}

.otplogin-close:hover {
    color: var(--otplogin-text);
}

.otplogin-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
    color: var(--otplogin-text);
    padding: 0 16px;
}

.otplogin-title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--otplogin-accent);
    color: #ffffff;
    font-size: 12px;
    font-style: italic;
    font-weight: 700;
    flex-shrink: 0;
}

.otplogin-subtitle {
    margin: 0 0 20px;
    font-size: 13.5px;
    color: var(--otplogin-muted);
    line-height: 1.45;
}

.otplogin-subtitle[hidden] {
    display: none !important;
}

.otplogin-alert {
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13.5px;
    background: var(--otplogin-error-bg);
    color: var(--otplogin-error-text);
    text-align: left;
}

.otplogin-alert.otplogin-alert-success {
    background: var(--otplogin-success-bg);
    color: var(--otplogin-success-text);
}

.otplogin-alert[hidden] {
    display: none !important;
}

.otplogin-step[hidden] {
    display: none !important;
}

.otplogin-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--otplogin-text);
    text-align: left;
}

.otplogin-input-email {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    font-size: 15px;
    border: 1px solid var(--otplogin-border);
    border-radius: 8px;
    margin-bottom: 16px;
    transition: border-color .15s ease;
}

.otplogin-input-email:focus {
    outline: none;
    border-color: var(--otplogin-accent);
}

.otplogin-btn-primary {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 13px 16px;
    background: var(--otplogin-accent);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .15s ease;
}

.otplogin-btn-primary:hover {
    background: var(--otplogin-accent-dark);
}

.otplogin-btn-primary:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.otplogin-btn-secondary {
    width: 100%;
    padding: 13px 16px;
    background: #eef0f2;
    color: var(--otplogin-muted);
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .15s ease;
}

.otplogin-btn-secondary:hover {
    background: #e2e4e7;
}

.otplogin-actions-row {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.otplogin-actions-row > * {
    flex: 1 1 0;
}

.otplogin-spinner {
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: otplogin-spin .6s linear infinite;
    flex-shrink: 0;
}

.otplogin-spinner[hidden] {
    display: none !important;
}

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

.otplogin-sent-to {
    font-size: 13.5px;
    color: var(--otplogin-muted);
    margin: 0 0 4px;
    line-height: 1.5;
}

.otplogin-sent-to strong {
    color: var(--otplogin-text);
    word-break: break-all;
}

.otplogin-instructions {
    font-size: 13.5px;
    color: var(--otplogin-muted);
    margin: 0 0 20px;
}

/* ---- Casillas de dígitos individuales (estilo redondeado, color de marca) ---- */
.otplogin-digits {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 16px;
}

.otplogin-digit {
    width: 46px;
    height: 54px;
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--otplogin-text);
    border: 2px solid var(--otplogin-accent);
    border-radius: 12px;
    box-sizing: border-box;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}

.otplogin-digit:focus {
    outline: none;
    border-color: var(--otplogin-accent-dark);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

/* ---- Temporizador de expiración: protagonista, en color de marca ---- */
.otplogin-expire-row {
    margin-bottom: 18px;
}

.otplogin-expire-timer {
    font-size: 14px;
    font-weight: 700;
    color: var(--otplogin-accent);
    letter-spacing: .2px;
}

/* ---- Acciones secundarias: reenviar / cambiar correo ---- */
.otplogin-secondary-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px 10px;
    font-size: 12.5px;
}

.otplogin-timer {
    color: var(--otplogin-muted);
}

.otplogin-link-btn {
    background: none;
    border: none;
    color: var(--otplogin-accent);
    font-weight: 600;
    font-size: 12.5px;
    cursor: pointer;
    padding: 4px;
}

.otplogin-link-btn:disabled {
    color: var(--otplogin-muted);
    cursor: not-allowed;
}

.otplogin-step-success {
    text-align: center;
    padding: 20px 0 8px;
}

.otplogin-success-icon {
    width: 56px;
    height: 56px;
    line-height: 56px;
    border-radius: 50%;
    background: var(--otplogin-success-bg);
    color: var(--otplogin-success-text);
    font-size: 28px;
    margin: 0 auto 14px;
}

/* ---- Responsive: móviles pequeños ---- */
@media (max-width: 480px) {
    .otplogin-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .otplogin-modal {
        max-width: 100%;
        width: 100%;
        border-radius: 18px 18px 0 0;
        max-height: 92vh;
        padding: 24px 18px 20px;
        animation: otplogin-slide-up .2s ease-out;
    }

    @keyframes otplogin-slide-up {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    .otplogin-digit {
        width: 40px;
        height: 48px;
        font-size: 20px;
    }

    .otplogin-actions-row {
        flex-direction: column;
    }
}

@media (max-width: 360px) {
    .otplogin-digits {
        gap: 6px;
    }

    .otplogin-digit {
        width: 34px;
        height: 44px;
        font-size: 18px;
        border-radius: 10px;
    }
}
