/**
 * P&D Core — Mi Cuenta Magic Link Login
 *
 * Estilos para la página de autenticación: social auth + magic link.
 * El JS reemplaza el HTML nativo de WooCommerce con un card centrado.
 *
 * Dashboard CSS (usuarios logueados) → pyd-theme/assets/css/my-account-dashboard.css
 *
 * @package PYD_Core
 * @since 0.2.35
 * @updated 0.3.0
 */

/* ==========================================================================
   ANTI-FOUC — Ocultar form original hasta que JS lo transforme
   ========================================================================== */

.woocommerce-account:not(.logged-in) #customer_login {
    opacity: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

.woocommerce-account:not(.logged-in) #customer_login.pyd-auth-transformed {
    opacity: 1 !important;
    height: auto !important;
    overflow: visible !important;
    transition: opacity 0.3s ease !important;
}

/* ==========================================================================
   PÁGINA AISLADA — Ocultar header, footer y hero para login limpio
   ========================================================================== */

.woocommerce-account:not(.logged-in) .hero-section {
    display: none !important;
}

.woocommerce-account:not(.logged-in) .entry-title,
.woocommerce-account:not(.logged-in) .page-title,
.woocommerce-account:not(.logged-in) .pyd-page__header {
    display: none !important;
}

/* P&D custom header + footer — also hide on login page */
.woocommerce-account:not(.logged-in) .pyd-header-wrapper {
    display: none !important;
}
.woocommerce-account:not(.logged-in) .pyd-footer {
    display: none !important;
}
.woocommerce-account:not(.logged-in) .scroll-top {
    display: none !important;
}

/* ==========================================================================
   LAYOUT — Centrar card horizontal y verticalmente
   ========================================================================== */

body.woocommerce-account:not(.logged-in) #main-container {
    padding-top: 0 !important;
    margin-top: 0 !important;
    min-height: 100vh !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #F3F4F6 !important;
}

body.woocommerce-account:not(.logged-in) #main-container > * {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

.woocommerce-account:not(.logged-in) .site-main {
    min-height: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 1rem !important;
    margin: 0 !important;
    background: transparent !important;
}

.woocommerce-account:not(.logged-in) .pyd-page,
.woocommerce-account:not(.logged-in) .pyd-page__content,
.woocommerce-account:not(.logged-in) .entry-content {
    padding: 0 !important;
    width: 100% !important;
}

.woocommerce-account:not(.logged-in) .pyd-auth-card {
    margin: 0 auto !important;
}

.woocommerce-account:not(.logged-in) .entry-content .woocommerce {
    width: 100% !important;
    max-width: none !important;
    display: flex !important;
    justify-content: center !important;
}

.pyd-auth-transformed {
    display: block !important;
    max-width: none !important;
    margin: 0 auto !important;
    padding: 0 !important;
}

/* ==========================================================================
   CARD PRINCIPAL
   ========================================================================== */

.pyd-auth-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 440px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: #1F2937;
    line-height: 1.5;
    outline: none !important;
    border: none !important;
}

.pyd-auth-card *,
.pyd-auth-card *::before,
.pyd-auth-card *::after {
    box-sizing: border-box;
}

.pyd-auth-card p {
    margin: 0 0 1rem;
    padding: 0;
    font-size: 0.9rem;
}

/* ==========================================================================
   HEADER CON LOGO
   ========================================================================== */

.pyd-auth-header {
    text-align: center;
    padding: 2rem 2rem 0;
}

.pyd-auth-card .pyd-auth-logo {
    height: auto !important;
    width: 250px !important;
}

/* FIDO2 challenge en login card — diseño idéntico al admin login */
.pyd-fido2-login { text-align: center; padding: 1rem 0; }

.pyd-fido2-login-icon {
    width: 56px; height: 56px; margin: 8px auto 14px;
    background: #F1F5F9; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
}

.pyd-fido2-login-title {
    font-size: 16px; font-weight: 600; color: #1F2937; margin: 0 0 6px;
}

.pyd-fido2-login-subtitle {
    font-size: 13px; color: #6B7280; line-height: 1.5; margin: 0 0 16px;
}

/* Detecting state — dot + texto + countdown */
.pyd-fido2-login-detecting {
    background: #F8FAFC; border: 1px solid #E2E8F0; border-radius: 8px;
    padding: 10px 14px; display: flex; align-items: center; gap: 10px;
    margin-bottom: 12px;
}

.pyd-fido2-login-dot {
    width: 8px; height: 8px; background: #3B82F6; border-radius: 50%;
    animation: pyd-fido2-blink 1s ease-in-out infinite; flex-shrink: 0;
}

@keyframes pyd-fido2-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.pyd-fido2-login-detecting-text {
    font-size: 13px; color: #475569; flex: 1; text-align: left;
}

.pyd-fido2-login-countdown {
    font-size: 12px; color: #94A3B8; font-variant-numeric: tabular-nums; flex-shrink: 0;
}

/* Success state */
.pyd-fido2-login-success {
    background: #F0FDF4; border: 1px solid #BBF7D0; border-radius: 8px;
    padding: 10px 14px; align-items: center; gap: 10px;
    margin-bottom: 12px; justify-content: center;
}

.pyd-fido2-login-success span {
    color: #059669; font-weight: 600; font-size: 13px;
}

/* Error state */
.pyd-fido2-login-error-box {
    background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA;
    border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 12px;
}

/* TOTP challenge en login card — diseño idéntico al admin login */
.pyd-totp-login { text-align: center; padding: 1rem 0; }

.pyd-totp-login-icon {
    width: 56px; height: 56px; margin: 8px auto 14px;
    background: #EDE9FE; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
}

.pyd-totp-input-wrap {
    position: relative; display: inline-block; margin-bottom: 16px;
}

.pyd-totp-hidden-input {
    position: absolute !important; top: 0 !important; left: 0 !important;
    width: 100% !important; height: 100% !important;
    opacity: 0.12 !important; color: transparent !important;
    background: transparent !important;
    border: none !important; box-shadow: none !important;
    padding: 0 !important; margin: 0 !important;
    font-size: 22px !important; z-index: 2 !important;
    outline: none !important; box-sizing: border-box !important;
}

.pyd-totp-slots { display: flex; gap: 8px; }

.pyd-totp-slot {
    width: 44px; height: 52px; display: flex; align-items: center;
    justify-content: center; font-size: 22px; font-weight: 700;
    border: 1px solid #D1D5DB; border-radius: 8px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: #9CA3AF; background: #fff;
    transition: border-color 0.15s, color 0.15s;
}

.pyd-totp-slot-filled {
    color: #1F2937; border-color: #6366F1;
}

.pyd-auth-card .pyd-auth-subtitle {
    margin: 0.75rem 0 0;
    font-size: 0.8rem;
    font-weight: 400;
    color: #9CA3AF;
    text-align: center;
}

/* ==========================================================================
   BODY
   ========================================================================== */

.pyd-auth-body {
    padding: 0.75rem 2rem 2rem;
}

/* ==========================================================================
   SOCIAL LOGIN — Botones pill (Google / Steam / Microsoft)
   ========================================================================== */

.pyd-social-login {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.pyd-social-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    background: #fff;
    font-size: 0.8rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    line-height: 1;
}

.pyd-social-btn:hover {
    background: #EFF4FF;
    border-color: #2B6CB0;
    color: #2B6CB0;
}

.pyd-social-btn svg,
.pyd-social-btn img {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ==========================================================================
   SEPARADOR "o continúa con tu email"
   ========================================================================== */

.pyd-auth-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.pyd-auth-divider::before,
.pyd-auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #E5E7EB;
}

.pyd-auth-divider span {
    font-size: 0.8rem;
    color: #9CA3AF;
    text-transform: lowercase;
    white-space: nowrap;
}

/* ==========================================================================
   MAGIC LINK — Campo de email + botón submit
   ========================================================================== */

.pyd-auth-field {
    margin-bottom: 1rem;
}

.pyd-auth-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.375rem;
}

.pyd-auth-field input[type="email"] {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #1F2937;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    height: auto;
    line-height: 1.4;
    font-family: inherit;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

.pyd-auth-field input[type="email"]:focus {
    border-color: #2B6CB0;
    box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.1);
}

/* Botón submit del magic link */
.pyd-auth-submit {
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: #2B6CB0;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
    line-height: 1.4;
    text-align: center;
}

.pyd-auth-submit:hover {
    background: #245A96;
}

.pyd-auth-submit:disabled {
    background: #93C5FD;
    cursor: not-allowed;
}

/* Turnstile widget */
.pyd-auth-turnstile {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
}

/* Link "Regresar a inicio" */
.pyd-auth-back {
    display: block;
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.8rem;
    color: #6B7280;
    text-decoration: none;
    transition: color 0.15s;
}

.pyd-auth-back:hover {
    color: #2B6CB0;
}

/* ==========================================================================
   MAGIC LINK — Estado de confirmación ("Revisa tu correo")
   ========================================================================== */

.pyd-magic-confirmation {
    text-align: center;
    padding: 1rem 0;
}

.pyd-magic-check {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.25rem;
    background: #DEF7EC;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pyd-magic-check svg {
    width: 28px;
    height: 28px;
}

.pyd-magic-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1F2937;
    margin: 0 0 0.5rem;
}

.pyd-magic-subtitle {
    font-size: 0.9rem;
    color: #6B7280;
    margin: 0 0 0.25rem;
}

.pyd-magic-email {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1F2937;
    margin: 0 0 1rem;
}

.pyd-magic-hint {
    font-size: 0.8rem;
    color: #9CA3AF;
    margin: 0 0 1.5rem;
}

.pyd-magic-resend {
    background: none;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    padding: 0.5rem 1.25rem;
    font-size: 0.8rem;
    color: #2B6CB0;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}

.pyd-magic-resend:hover:not(:disabled) {
    background: #EFF4FF;
    border-color: #2B6CB0;
}

.pyd-magic-resend:disabled {
    color: #9CA3AF;
    cursor: not-allowed;
}

/* ==========================================================================
   MAGIC LINK — Banner de error
   ========================================================================== */

.pyd-magic-error {
    background: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FECACA;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    margin-bottom: 1rem;
    text-align: center;
    animation: pyd-fade-in 0.3s ease;
}

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

/* ==========================================================================
   OCULTAR ELEMENTOS INNECESARIOS
   ========================================================================== */

.woocommerce-account:not(.logged-in) .woocommerce-notices-wrapper:empty {
    display: none !important;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 480px) {
    .pyd-auth-body {
        padding: 1.25rem 1.25rem 1.5rem;
    }

    /* Social pills: solo iconos en mobile */
    .pyd-social-btn span {
        display: none;
    }

    .pyd-social-btn {
        justify-content: center;
        padding: 0.75rem;
    }
}
