/**
 * Modal de Selección de Cuenta - Estilos
 * Modal que aparece cuando hay cupón pero no hay cuentas añadidas
 *
 * @package Noctorial_Checkout
 * @since 1.0.0
 */

/* ============================================
   Modal Base - Estilos idénticos al modal de promociones
   ============================================ */

.noctorial-account-selection-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.75) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center !important;
    justify-content: center !important;
    z-index: 99999 !important;
    padding: 20px;
    margin: 0 !important;
    /* Optimizaciones móviles */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Prevenir zoom en iOS cuando se hace focus en inputs */
@supports (-webkit-touch-callout: none) {
    .noctorial-account-selection-modal input,
    .noctorial-account-selection-modal button,
    .noctorial-account-selection-modal select,
    .noctorial-account-selection-modal textarea {
        font-size: 16px; /* Prevenir zoom automático en iOS */
    }
}

.noctorial-account-selection-modal.visible {
    display: flex !important;
    opacity: 1 !important;
}

.noctorial-modal-content {
    position: relative;
    background: linear-gradient(135deg, 
        rgba(17, 110, 251, 0.15) 0%, 
        rgba(17, 110, 251, 0.25) 25%,
        rgba(17, 110, 251, 0.20) 50%,
        rgba(17, 110, 251, 0.15) 75%,
        rgba(17, 110, 251, 0.10) 100%
    ), 
    linear-gradient(0deg, 
        rgba(19, 23, 29, 0.95) 0%, 
        rgba(19, 23, 29, 0.98) 100%
    );
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    border-radius: 20px;
    padding: 0;
    margin: auto;
    box-shadow: 
        0 25px 80px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(17, 110, 251, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    animation: modalSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(17, 110, 251, 0.3);
}

@keyframes modalSlideUp {
    from {
        transform: translateY(50px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Animación de fadeIn */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Transición suave al ocultar */
.noctorial-account-selection-modal:not(.visible) {
    display: none;
    opacity: 0;
    pointer-events: none;
}

/* ============================================
   Header del Modal - Estilo idéntico al modal de promociones
   ============================================ */

.noctorial-modal-header {
    padding: 24px 32px 20px;
    border-bottom: 1px solid rgba(17, 110, 251, 0.2);
    position: sticky;
    top: 0;
    background: rgba(17, 110, 251, 0.05);
    backdrop-filter: blur(15px);
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 20px 20px 0 0;
}

.noctorial-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.noctorial-modal-title h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
}

.noctorial-modal-title-icon {
    font-size: 24px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Botón de cerrar */
.noctorial-modal-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.7);
    font-size: 20px;
    line-height: 1;
}

.noctorial-modal-close:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 1);
    transform: rotate(90deg);
}

/* ============================================
   Body del Modal - Estilo idéntico al modal de promociones
   ============================================ */

.noctorial-modal-body {
    padding: 20px 24px;
}

.modal-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-color, #FFFFFF);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid var(--primary-color, #77A3EB);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

.modal-content-sections {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px 24px;
}

.modal-section {
    margin-bottom: 32px;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.modal-section h4 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color, #FFFFFF);
    margin: 0 0 16px 0;
    font-family: 'Urbanist', sans-serif;
}

/* ============================================
   Grid de Botones de Opciones
   ============================================ */

.modal-buttons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

/* Asegurar que todos los botones ocupen el ancho completo */
.modal-buttons-grid .modal-option-btn,
.challenge-option,
.capital-option {
    width: 100%;
    box-sizing: border-box;
}

/* Grid específico para capital en desktop - 2 filas x 3 columnas */
@media (min-width: 768px) {
    .capital-section .modal-buttons-grid {
        grid-template-columns: repeat(3, 1fr);
        max-width: 600px;
        margin: 20px auto 0;
    }
}

.modal-option-btn {
    border-radius: 8px;
    border: 0.5px solid rgba(247, 246, 240, 0.10);
    background: rgba(16, 110, 251, 0.10);
    color: #000000;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    text-align: center;
    font-family: 'Public Sans', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
}


.modal-option-btn:hover {
    background: rgba(16, 110, 251, 0.15);
    border-color: rgba(247, 246, 240, 0.15);
}

.modal-option-btn.selected {
    background: #77A3EB !important;
    border-color: rgba(247, 246, 240, 0.10) !important;
    color: var(--text-color, #FFFFFF);
}

/* Simplificar animaciones para coincidir con la captura */
.modal-option-btn:active {
    transform: scale(0.98);
    transition: all 0.1s ease;
}

.modal-option-btn .btn-text {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0);
}

.modal-option-btn:hover .btn-text {
    transform: translateY(-1px);
}

.modal-option-btn .btn-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.modal-option-btn .btn-text {
    color: #F7F6F0;
    font-weight: 600;
    font-size: 14px;
    text-align: center;
    line-height: 1.2;
}

/* Botón de atrás para navegación entre steps */
.modal-back-button {
    background: transparent;
    border: 1px solid rgba(247, 246, 240, 0.20);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.8);
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    font-family: 'Public Sans', sans-serif;
    width: auto;
    max-width: 120px;
}

.modal-back-button:hover {
    background: rgba(247, 246, 240, 0.05);
    border-color: rgba(247, 246, 240, 0.30);
    color: #FFFFFF;
}

.modal-back-button .back-icon {
    font-size: 14px;
}

/* Estilos específicos para cada tipo de opción */
.challenge-option .btn-icon {
    color: #FFD700;
}

.capital-option .btn-icon {
    color: #00D4AA;
}

/* ============================================
   Acciones del Modal
   ============================================ */

.modal-actions {
    margin-top: 32px;
    text-align: center;
}

.modal-confirm-btn {
    padding: 16px 32px;
    border: none;
    border-radius: 12px;
    background: var(--primary-color, #77A3EB);
    color: #FFFFFF;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    min-width: 160px;
    font-family: 'Public Sans', sans-serif;
}

.modal-confirm-btn:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    cursor: not-allowed;
    transform: none;
}

.modal-confirm-btn.enabled:hover {
    background: var(--secondary-color, #0E5FD8);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(119, 163, 235, 0.3);
}

.modal-confirm-btn .btn-loading {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

/* ============================================
   Error del Modal
   ============================================ */

.modal-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-color, #FFFFFF);
}

.modal-error p {
    margin: 0 0 20px 0;
    font-size: 16px;
}

.modal-close-btn {
    padding: 12px 24px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 8px;
    background: transparent;
    color: var(--text-color, #FFFFFF);
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Public Sans', sans-serif;
}

.modal-close-btn:hover {
    border-color: var(--primary-color, #77A3EB);
    background: rgba(119, 163, 235, 0.1);
}

/* ============================================
   Enhanced 2-Step Flow Animations
   ============================================ */

.modal-step {
    display: none;
    opacity: 0;
    transform: translateX(30px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-step.active {
    display: block;
    opacity: 1;
    transform: translateX(0) scale(1);
}

/* Contenedor de los step tabs */
.modal-steps-indicator {
    display: flex;
    gap: 10px;
    padding: 20px 32px 0;
    margin-bottom: 20px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Ocultar tabs cuando se muestra el contenido */
.noctorial-modal-content:has(.modal-content-sections:not([style*="display: none"])) .modal-steps-indicator,
.noctorial-modal-content.content-loaded .modal-steps-indicator {
    display: none;
}

.modal-step-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 16px;
    border-radius: 8px;
    border: 0.5px solid rgba(247, 246, 240, 0.10);
    background: rgba(237, 237, 240, 0.04);
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-family: 'Public Sans', sans-serif;
}

.modal-step-tab .step-number {
    font-weight: 600;
    font-size: 12px;
}

.modal-step-tab .step-label {
    font-size: 13px;
}

.modal-step-tab.active {
    background: rgba(16, 110, 251, 0.30);
    color: var(--text-color, #FFFFFF);
    border: 0.5px solid rgba(247, 246, 240, 0.10);
}

.modal-step-tab.completed {
    background: rgba(46, 204, 113, 0.20);
    color: var(--success-color, #2ecc71);
    border: 0.5px solid rgba(46, 204, 113, 0.30);
}

.step-dot.completed::before {
    width: 16px;
    height: 16px;
    background: var(--success-color, #2ecc71);
    opacity: 0.2;
}

/* ============================================
   Estados de Carga y Procesamiento
   ============================================ */

.noctorial-account-selection-modal.processing .account-selection-btn {
    pointer-events: none;
    opacity: 0.6;
}

.account-selection-btn.loading {
    position: relative;
}

.account-selection-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid var(--text-color, #FFFFFF);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ============================================
   Sistema de Cierre Automático - Feedback Visual
   ============================================ */

.noctorial-account-selection-modal.overlay-clicked .noctorial-modal-content {
    transform: scale(0.98);
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.6, 1);
}

.noctorial-account-selection-modal.escape-pressed .noctorial-modal-content {
    transform: scale(0.97) translateY(5px);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.6, 1);
}

.noctorial-account-selection-modal.processing-block .noctorial-modal-content {
    animation: processingShake 0.3s cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes processingShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Indicador visual de que el modal se puede cerrar */
.noctorial-account-selection-modal:not(.processing) .noctorial-modal-overlay {
    cursor: pointer;
}

.noctorial-account-selection-modal.processing .noctorial-modal-overlay {
    cursor: not-allowed;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   Responsive Design - Mobile Optimized
   ============================================ */

@media (max-width: 768px) {
    .noctorial-modal-content {
        padding: 24px;
        width: 95%;
        max-width: 400px;
        min-height: 350px;
        /* Asegurar que el modal no se salga de la pantalla */
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .noctorial-modal-header h3 {
        font-size: 20px;
    }
    
    .modal-buttons-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 12px; /* Aumentar gap para mejor separación táctil */
    }
    
    .modal-option-btn {
        padding: 16px 12px; /* Aumentar padding para mejor área táctil */
        min-height: 80px; /* Aumentar altura mínima para cumplir con estándares táctiles */
        /* Asegurar que los botones sean fáciles de tocar (mínimo 44px según WCAG) */
        min-width: 120px;
        touch-action: manipulation; /* Optimizar para touch */
    }
    
    .modal-option-btn .btn-icon {
        font-size: 22px; /* Aumentar tamaño de iconos para mejor visibilidad */
    }
    
    .modal-option-btn .btn-text {
        font-size: 14px; /* Aumentar tamaño de texto para mejor legibilidad */
        font-weight: 600;
    }
    
    .modal-section {
        margin-bottom: 24px;
    }
    
    .modal-section h4 {
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    .modal-confirm-btn {
        padding: 16px 32px; /* Aumentar padding para mejor área táctil */
        font-size: 16px;
        min-width: 160px;
        min-height: 48px; /* Asegurar altura mínima táctil */
        touch-action: manipulation;
    }
    
    /* Optimizaciones específicas para touch */
    .modal-option-btn:hover {
        /* En móvil, reducir efectos hover ya que no hay hover real */
        transform: translateY(-2px) scale(1.01);
    }
    
    .modal-option-btn:active {
        /* Mejorar feedback táctil */
        transform: translateY(0) scale(0.98);
        transition: all 0.1s ease;
    }
}

@media (max-width: 480px) {
    .noctorial-modal-content {
        padding: 20px;
        width: 95%; /* Aumentar ancho para mejor uso del espacio */
        border-radius: 12px;
        max-width: 380px; /* Aumentar max-width */
        min-height: 320px;
        /* Asegurar que el modal sea completamente visible */
        max-height: 85vh;
        overflow-y: auto;
        /* Centrado mejorado en pantallas pequeñas */
        margin: 10px;
    }
    
    .noctorial-modal-header {
        margin-bottom: 20px;
    }
    
    .noctorial-modal-header h3 {
        font-size: 18px;
        line-height: 1.3; /* Mejorar legibilidad */
    }
    
    .modal-buttons-grid {
        grid-template-columns: 1fr; /* Una columna en pantallas muy pequeñas para mejor táctil */
        gap: 12px; /* Aumentar gap para mejor separación */
    }
    
    .modal-option-btn {
        padding: 18px 16px; /* Aumentar padding significativamente */
        min-height: 72px; /* Aumentar altura para cumplir estándares táctiles */
        width: 100%; /* Usar todo el ancho disponible */
        /* Optimizar para touch en pantallas pequeñas */
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(119, 163, 235, 0.3);
    }
    
    .modal-option-btn .btn-icon {
        font-size: 20px; /* Mantener tamaño legible */
    }
    
    .modal-option-btn .btn-text {
        font-size: 14px; /* Aumentar para mejor legibilidad */
        font-weight: 600;
        line-height: 1.2;
    }
    
    .modal-section {
        margin-bottom: 20px;
    }
    
    .modal-section h4 {
        font-size: 16px; /* Aumentar para mejor legibilidad */
        margin-bottom: 12px;
        line-height: 1.3;
    }
    
    .modal-confirm-btn {
        padding: 16px 32px; /* Aumentar padding para mejor área táctil */
        font-size: 16px; /* Aumentar tamaño de fuente */
        min-width: 200px; /* Aumentar ancho mínimo */
        min-height: 52px; /* Asegurar altura táctil adecuada */
        width: 100%; /* Usar todo el ancho en móvil */
        max-width: 280px;
        touch-action: manipulation;
    }
    
    .modal-actions {
        margin-top: 24px;
    }
    
    /* Optimizaciones específicas para pantallas muy pequeñas */
    .step-dot {
        width: 12px; /* Aumentar tamaño para mejor visibilidad */
        height: 12px;
    }
    
    .modal-step-indicator {
        gap: 16px; /* Aumentar separación */
        margin-bottom: 24px;
    }
    
    /* Mejorar visibilidad de elementos de procesamiento en móvil */
    .processing-steps {
        gap: 14px;
    }
    
    .processing-step {
        padding: 14px 16px;
        border-radius: 10px;
    }
    
    .processing-step .step-icon {
        font-size: 20px;
        width: 28px;
    }
    
    .processing-step .step-text {
        font-size: 15px;
    }
    
    /* Optimizar loading spinner para móvil */
    .loading-spinner-enhanced {
        width: 45px;
        height: 45px;
    }
    
    .loading-text h4 {
        font-size: 18px;
    }
    
    .loading-text p {
        font-size: 15px;
    }
}

/* ============================================
   Accesibilidad y Estados de Foco Optimizados
   ============================================ */

.modal-option-btn:focus {
    outline: 3px solid var(--primary-color, #77A3EB);
    outline-offset: 2px;
}

.modal-option-btn:focus:not(:focus-visible) {
    outline: none;
}

/* Mejorar accesibilidad en móviles */
@media (max-width: 768px) {
    .modal-option-btn:focus {
        outline-width: 4px; /* Outline más grueso en móvil */
        outline-offset: 3px;
    }
}

/* Estados de focus para elementos interactivos */
.modal-confirm-btn:focus,
.modal-close-btn:focus,
.modal-retry-btn:focus {
    outline: 3px solid var(--primary-color, #77A3EB);
    outline-offset: 2px;
}

/* Asegurar que los elementos sean accesibles por teclado */
.modal-option-btn,
.modal-confirm-btn,
.modal-close-btn,
.modal-retry-btn {
    cursor: pointer;
}

/* Mejorar contraste para usuarios con problemas de visión */
@media (prefers-contrast: high) {
    .modal-option-btn {
        border-width: 3px;
    }
    
    .modal-option-btn:focus {
        outline-width: 4px;
        outline-color: #ffffff;
        background: rgba(255, 255, 255, 0.1);
    }
}

/* Soporte para usuarios que prefieren menos movimiento */
@media (prefers-reduced-motion: reduce) {
    .modal-option-btn,
    .noctorial-modal-content,
    .modal-step {
        transition: none;
        animation: none;
    }
    
    .modal-option-btn:hover,
    .modal-option-btn:active {
        transform: none;
    }
}

/* ============================================
   Enhanced Keyframe Animations
   ============================================ */

@keyframes modalBackdropFadeIn {
    from {
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
    to {
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
}

@keyframes modalContentSlideIn {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(30px);
    }
    50% {
        opacity: 0.8;
        transform: scale(0.95) translateY(10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes modalFadeOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.9) translateY(-10px);
    }
}

@keyframes selectPulse {
    0% { 
        transform: scale(1) translateY(-2px); 
    }
    50% { 
        transform: scale(1.05) translateY(-3px);
        box-shadow: 
            0 15px 35px rgba(119, 163, 235, 0.4),
            0 8px 20px rgba(0, 0, 0, 0.2);
    }
    100% { 
        transform: scale(1.01) translateY(-2px); 
    }
}

@keyframes buttonRipple {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(4);
        opacity: 0;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Enhanced step transitions */
@keyframes stepSlideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes stepSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-30px);
    }
}

.noctorial-account-selection-modal.entering .noctorial-modal-content {
    animation: modalFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.noctorial-account-selection-modal.exiting .noctorial-modal-content {
    animation: modalFadeOut 0.3s cubic-bezier(0.4, 0, 0.6, 1) forwards;
}

/* ============================================
   Utilidades
   ============================================ */

.noctorial-modal-hidden {
    display: none !important;
}

.noctorial-modal-no-scroll {
    overflow: hidden;
}

/* ============================================
   Estados de Procesamiento Actualizados
   ============================================ */

.noctorial-account-selection-modal.processing .modal-option-btn {
    pointer-events: none;
    opacity: 0.6;
}

.noctorial-account-selection-modal.processing .modal-confirm-btn {
    pointer-events: none;
}

.modal-confirm-btn .btn-loading {
    font-size: 16px;
}

/* ============================================
   Mejoras Visuales para Flujo de 2 Pasos
   ============================================ */

.modal-section h4 {
    text-align: center;
    margin-bottom: 20px;
}

.modal-buttons-grid {
    justify-items: center;
}

.modal-option-btn {
    transition: all 0.2s ease;
}

.modal-option-btn:hover {
    transform: translateY(-3px);
}

.modal-option-btn.selected {
    animation: selectPulse 0.3s ease;
}

@keyframes selectPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Mejorar el loading del procesamiento */
.modal-loading p {
    font-weight: 500;
    margin-top: 8px;
}

/* ============================================
   Success and Error States with Auto-Close
   ============================================ */
.modal-success,
.modal-error {
    text-align: center;
    padding: 40px 20px;
}

.modal-success .success-icon,
.modal-error .error-icon {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
    animation: successPulse 2s ease-in-out infinite;
}

.modal-success h4,
.modal-error h4 {
    color: var(--text-primary, #F7F6F0);
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 12px;
}

.modal-success p,
.modal-error p {
    color: var(--text-secondary, rgba(247, 246, 240, 0.8));
    font-size: 16px;
    line-height: 1.5;
    margin-bottom: 24px;
}

/* Auto-close indicator */
.auto-close-indicator {
    margin-top: 20px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.auto-close-progress {
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color, #77A3EB), var(--secondary-color, #0E5FD8));
    border-radius: 2px;
    transition: width 1.8s linear;
    margin-bottom: 8px;
}

.auto-close-text {
    font-size: 14px;
    color: var(--text-secondary, rgba(247, 246, 240, 0.7));
    font-weight: 500;
}

@keyframes successPulse {
    0%, 100% { 
        transform: scale(1);
        opacity: 1;
    }
    50% { 
        transform: scale(1.05);
        opacity: 0.8;
    }
}

/* Enhanced error state */
.modal-error.enhanced {
    padding: 30px 20px;
}

.error-animation {
    margin-bottom: 24px;
}

.error-icon-container {
    position: relative;
    display: inline-block;
}

.error-icon-container .error-icon {
    font-size: 48px;
    display: block;
    animation: errorShake 0.5s ease-in-out;
}

.error-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 60px;
    border: 2px solid #e74c3c;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: errorPulse 2s ease-in-out infinite;
    opacity: 0;
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes errorPulse {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0.8;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.4;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

.error-content {
    margin-bottom: 24px;
}

.error-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-close-btn,
.modal-retry-btn {
    border: none;
    border-radius: 10px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 120px;
}

.modal-close-btn.primary {
    background: var(--primary-color, #116EFB);
    color: white;
}

.modal-close-btn.primary:hover {
    background: var(--primary-hover, #0D5CE8);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(17, 110, 251, 0.3);
}

.modal-retry-btn.secondary {
    background: transparent;
    color: var(--text-secondary, rgba(247, 246, 240, 0.8));
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-retry-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--text-primary, #F7F6F0);
    transform: translateY(-1px);
}

/* ============================================
   Enhanced Processing State with Visual Indicators
   ============================================ */

.noctorial-account-selection-modal.processing {
    pointer-events: none;
}

.noctorial-account-selection-modal.processing .modal-content-sections {
    opacity: 1;
}

.modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.modal-loading.enhanced {
    padding: 30px 20px;
}

/* Enhanced loading container */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 24px;
}

.loading-spinner-enhanced {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(17, 110, 251, 0.2);
    border-top: 4px solid rgba(17, 110, 251, 0.8);
    border-radius: 50%;
    animation: spinEnhanced 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spinEnhanced {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Loading dots animation */
.loading-dots {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.loading-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color, #77A3EB);
    animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dots .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.4;
    }
    30% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Loading text */
.loading-text {
    text-align: center;
    margin-bottom: 32px;
}

.loading-text h4 {
    color: var(--text-primary, #F7F6F0);
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 8px 0;
    transition: all 0.3s ease;
}

.loading-text p {
    color: var(--text-secondary, rgba(247, 246, 240, 0.7));
    font-size: 14px;
    margin: 0;
    transition: all 0.3s ease;
}

/* Processing steps */
.processing-steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    max-width: 300px;
}

.processing-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.processing-step .step-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    transition: all 0.3s ease;
}

.processing-step .step-text {
    flex: 1;
    color: var(--text-secondary, rgba(247, 246, 240, 0.6));
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.processing-step .step-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Step states */
.processing-step.pending .step-status {
    background: rgba(255, 255, 255, 0.2);
}

.processing-step.active {
    background: rgba(119, 163, 235, 0.1);
    border-color: rgba(119, 163, 235, 0.2);
    transform: translateX(4px);
}

.processing-step.active .step-text {
    color: var(--text-primary, #F7F6F0);
    font-weight: 600;
}

.processing-step.active .step-icon {
    transform: scale(1.1);
}

.processing-step.active .step-status {
    background: var(--primary-color, #77A3EB);
    animation: statusPulse 1.5s ease-in-out infinite;
}

.processing-step.completed {
    background: rgba(46, 204, 113, 0.1);
    border-color: rgba(46, 204, 113, 0.2);
}

.processing-step.completed .step-text {
    color: var(--success-color, #2ecc71);
    font-weight: 600;
}

.processing-step.completed .step-icon {
    transform: scale(1.05);
}

.processing-step.completed .step-status {
    background: var(--success-color, #2ecc71);
    transform: scale(1.1);
}

.processing-step.error {
    background: rgba(231, 76, 60, 0.1);
    border-color: rgba(231, 76, 60, 0.2);
}

.processing-step.error .step-text {
    color: #e74c3c;
    font-weight: 600;
}

.processing-step.error .step-status {
    background: #e74c3c;
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

/* Legacy loading spinner for compatibility */
.modal-loading .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(17, 110, 251, 0.2);
    border-top: 3px solid var(--primary-color, #116EFB);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.modal-loading p {
    color: var(--text-secondary, rgba(247, 246, 240, 0.8));
    font-size: 16px;
    margin: 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   Animation Improvements
   ============================================ */

.modal-step {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.modal-step.active {
    opacity: 1;
    transform: translateY(0);
}

.modal-step.exiting {
    opacity: 0;
    transform: translateY(-20px);
}

.noctorial-account-selection-modal.exiting {
    opacity: 0;
    transform: scale(0.95);
}
/* 
============================================
   Error Handling and Fallback Styles
   ============================================ */

/* Warning states for recoverable errors */
.modal-warning {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-color, #FFFFFF);
}

.modal-warning .warning-icon {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
    animation: warningPulse 2s ease-in-out infinite;
}

.modal-warning h4 {
    color: var(--text-primary, #F7F6F0);
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 12px;
}

.modal-warning p {
    color: var(--text-secondary, rgba(247, 246, 240, 0.8));
    font-size: 16px;
    line-height: 1.5;
    margin-bottom: 16px;
}

.modal-warning .error-detail {
    font-size: 14px;
    color: var(--text-tertiary, rgba(247, 246, 240, 0.6));
    font-style: italic;
    margin-bottom: 24px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border-left: 3px solid #f39c12;
}

.fallback-text {
    font-weight: 600;
    color: var(--text-primary, #F7F6F0);
    margin-bottom: 12px;
}

.fallback-options {
    text-align: left;
    margin: 16px 0 24px 0;
    padding-left: 20px;
}

.fallback-options li {
    margin-bottom: 8px;
    color: var(--text-secondary, rgba(247, 246, 240, 0.8));
    line-height: 1.4;
}

.warning-actions,
.error-actions,
.system-error-actions,
.network-error-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 24px;
}

@keyframes warningPulse {
    0%, 100% { 
        transform: scale(1);
        opacity: 1;
    }
    50% { 
        transform: scale(1.03);
        opacity: 0.9;
    }
}

/* User-friendly error styles */
.modal-user-error {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-color, #FFFFFF);
}

.modal-user-error .user-error-icon {
    font-size: 42px;
    margin-bottom: 16px;
    display: block;
    color: #3498db;
}

.modal-user-error h4 {
    color: var(--text-primary, #F7F6F0);
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
}

.modal-user-error p {
    color: var(--text-secondary, rgba(247, 246, 240, 0.8));
    font-size: 16px;
    line-height: 1.5;
    margin-bottom: 20px;
}

.user-error-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.user-error-btn {
    border: none;
    border-radius: 10px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 120px;
}

.user-error-btn.primary {
    background: var(--primary-color, #116EFB);
    color: white;
}

.user-error-btn.primary:hover {
    background: var(--primary-hover, #0D5CE8);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(17, 110, 251, 0.3);
}

.user-error-btn.secondary {
    background: transparent;
    color: var(--text-secondary, rgba(247, 246, 240, 0.8));
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.user-error-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--text-primary, #F7F6F0);
    transform: translateY(-1px);
}

/* Reload button for system errors */
.modal-reload-btn {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 140px;
}

.modal-reload-btn:hover {
    background: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(231, 76, 60, 0.3);
}

/* Fallback notification styles */
.noctorial-fallback-notification {
    font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    animation: notificationSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.fallback-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.fallback-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.fallback-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
    color: #495057;
}

.fallback-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #6c757d;
    margin-left: 8px;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.fallback-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #495057;
}

/* Error notification styles */
.noctorial-error-notification {
    font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    animation: notificationSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.error-notification-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.error-notification-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.error-notification-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.error-notification-title {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
}

.error-notification-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #856404;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.error-notification-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

.error-notification-message {
    font-size: 13px;
    line-height: 1.4;
    color: #856404;
    margin-left: 26px;
}

/* Checkout unavailable message */
.noctorial-checkout-unavailable {
    font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    animation: modalFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.unavailable-content h4 {
    color: #dc3545;
    margin: 0 0 16px 0;
    font-size: 20px;
}

.unavailable-content p {
    color: #495057;
    margin: 0 0 12px 0;
    line-height: 1.5;
}

.reload-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 16px;
}

.reload-btn:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(220, 53, 69, 0.3);
}

@keyframes notificationSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Enhanced error detail styling */
.error-detail {
    font-size: 14px;
    color: var(--text-tertiary, rgba(247, 246, 240, 0.6));
    font-style: italic;
    margin-top: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border-left: 3px solid #e74c3c;
}

/* Responsive adjustments for error states */
@media (max-width: 768px) {
    .modal-warning,
    .modal-user-error {
        padding: 24px 16px;
    }
    
    .modal-warning .warning-icon,
    .modal-user-error .user-error-icon {
        font-size: 36px;
    }
    
    .modal-warning h4,
    .modal-user-error h4 {
        font-size: 18px;
    }
    
    .modal-warning p,
    .modal-user-error p {
        font-size: 15px;
    }
    
    .warning-actions,
    .error-actions,
    .user-error-actions,
    .system-error-actions,
    .network-error-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .user-error-btn,
    .modal-close-btn,
    .modal-retry-btn,
    .modal-reload-btn {
        width: 100%;
        max-width: 200px;
    }
    
    .fallback-options {
        padding-left: 16px;
    }
    
    .noctorial-fallback-notification,
    .noctorial-error-notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .modal-warning,
    .modal-user-error {
        padding: 20px 12px;
    }
    
    .modal-warning .warning-icon,
    .modal-user-error .user-error-icon {
        font-size: 32px;
    }
    
    .modal-warning h4,
    .modal-user-error h4 {
        font-size: 16px;
    }
    
    .modal-warning p,
    .modal-user-error p {
        font-size: 14px;
    }
    
    .user-error-btn,
    .modal-close-btn,
    .modal-retry-btn,
    .modal-reload-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .modal-warning .error-detail {
        border-left-width: 4px;
        background: rgba(255, 255, 255, 0.1);
    }
    
    .error-detail {
        border-left-width: 4px;
        background: rgba(255, 255, 255, 0.1);
    }
    
    .user-error-btn.primary {
        border: 2px solid var(--primary-color, #116EFB);
    }
    
    .user-error-btn.secondary {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .modal-warning .warning-icon,
    .modal-user-error .user-error-icon {
        animation: none;
    }
    
    .noctorial-fallback-notification,
    .noctorial-error-notification {
        animation: none;
        opacity: 1;
        transform: none;
    }
    
    .user-error-btn:hover,
    .modal-close-btn:hover,
    .modal-retry-btn:hover,
    .modal-reload-btn:hover {
        transform: none;
    }
}