/**
 * EventLive News & Segments - Subscribe Modal
 */

/* ========================================
   MODAL BASE
======================================== */
.elns-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: 20px;
    box-sizing: border-box;
}

.elns-modal.active {
    display: flex !important;
    opacity: 1;
}

/* Asegurar que el modal no se muestre sin la clase active */
.elns-modal:not(.active) {
    display: none !important;
}

/* Overlay */
.elns-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

/* Wrapper */
.elns-modal-wrapper {
    position: relative;
    z-index: 1;
    max-width: 550px;
    width: 100%;
    max-height: 90vh;
    margin: 0;
    overflow: hidden; /* Cambiar de auto a hidden para que el contenido no se desborde */
    animation: elns-modal-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    align-self: center;
    justify-self: center;
    display: flex;
    flex-direction: column;
}

/* Content */
.elns-modal-content {
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Importante para que flex funcione correctamente */
    max-height: 90vh;
    overflow: hidden; /* El contenido interno manejará el scroll */
}

/* Close Button */
.elns-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.elns-modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: rotate(90deg);
}

.elns-modal-close .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    color: #666;
}

/* Header */
.elns-modal-header {
    padding: 40px 40px 20px;
    text-align: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px 16px 0 0;
    color: white;
    flex-shrink: 0; /* El header nunca se contrae */
}

.elns-modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.elns-modal-icon .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
}

.elns-modal-header h2 {
    margin: 0 0 8px 0;
    font-size: 26px;
    font-weight: 700;
    color: #ffffff;
}

.elns-modal-subtitle {
    margin: 0;
    font-size: 15px;
    opacity: 0.9;
}

/* Body */
.elns-modal-body {
    padding: 30px 40px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0; /* Importante para que el scroll funcione en flex */
    -webkit-overflow-scrolling: touch; /* Scroll suave en iOS */
}

/* Form */
.elns-modal-form {}

.elns-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.elns-form-group {
    margin-bottom: 20px;
}

.elns-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.elns-form-group .required {
    color: #e74c3c;
}

.elns-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s;
    background: #ffffff;
}

.elns-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Categories Grid */
.elns-categories-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 10px;
}

.elns-category-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.elns-category-item:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.elns-category-item input[type="checkbox"] {
    margin: 0 10px 0 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.elns-category-item input[type="checkbox"]:checked + .elns-category-label {
    font-weight: 600;
    color: #667eea;
}

.elns-category-label {
    font-size: 14px;
    color: #333;
    cursor: pointer;
}

.elns-help-text {
    font-size: 13px;
    color: #999;
    margin: 0;
}

/* GDPR Checkbox */
.elns-gdpr-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.elns-gdpr-checkbox input[type="checkbox"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.elns-gdpr-checkbox span {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
}

.elns-gdpr-checkbox a {
    color: #667eea;
    text-decoration: none;
}

.elns-gdpr-checkbox a:hover {
    text-decoration: underline;
}

/* Button */
.elns-btn {
    padding: 14px 32px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.elns-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
}

.elns-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.elns-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.elns-btn-full {
    width: 100%;
}

.elns-loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: elns-spin 0.8s linear infinite;
}

/* Messages */
.elns-messages {
    margin-bottom: 20px;
}

.elns-message {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.elns-message::before {
    content: '';
    font-family: 'dashicons';
    font-size: 20px;
}

.elns-message.success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}

.elns-message.success::before {
    content: '\f147'; /* checkmark */
}

.elns-message.error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.elns-message.error::before {
    content: '\f153'; /* warning */
}

/* Footer */
.elns-modal-footer {
    padding: 20px 40px 30px;
    text-align: center;
    flex-shrink: 0; /* El footer nunca se contrae */
    background: #ffffff; /* Asegurar fondo blanco */
    border-radius: 0 0 16px 16px; /* Redondear solo las esquinas inferiores */
}

.elns-privacy-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    color: #999;
    margin: 0;
}

.elns-privacy-note .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* ========================================
   ANIMATIONS
======================================== */
@keyframes elns-modal-slide-up {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

/* ========================================
   DARK MODE
======================================== */
@media (prefers-color-scheme: dark) {
    .elns-modal-content {
        background: #1e1e1e;
    }
    
    .elns-modal-body {
        background: #1e1e1e; /* Asegurar fondo oscuro en el body */
    }
    
    .elns-modal-footer {
        background: #1e1e1e; /* Asegurar fondo oscuro en el footer */
    }
    
    .elns-modal-close {
        background: rgba(255, 255, 255, 0.1);
    }
    
    .elns-modal-close:hover {
        background: rgba(255, 255, 255, 0.2);
    }
    
    .elns-modal-close .dashicons {
        color: #e5e5e5;
    }
    
    .elns-form-group label {
        color: #e5e5e5;
    }
    
    .elns-input {
        background: #2a2a2a;
        border-color: #3a3a3a;
        color: #ffffff;
    }
    
    .elns-input:focus {
        border-color: #667eea;
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
    }
    
    .elns-category-item {
        border-color: #3a3a3a;
        background: #1e1e1e;
    }
    
    .elns-category-item:hover {
        border-color: #667eea;
        background: #2a2a3a;
    }
    
    .elns-category-label {
        color: #e5e5e5;
    }
    
    .elns-help-text {
        color: #999;
    }
    
    .elns-gdpr-checkbox span {
        color: #b0b0b0;
    }
}

/* ========================================
   RESPONSIVE
======================================== */
@media (max-width: 768px) {
    .elns-modal {
        padding: 10px;
    }
    
    .elns-modal-wrapper {
        max-width: 100% !important; /* Sobrescribir estilos inline */
        width: 100% !important;
        max-height: 95vh;
        margin: 0;
    }
    
    .elns-modal-content {
        border-radius: 12px;
    }
    
    .elns-modal-header {
        padding: 30px 24px 20px;
    }
    
    .elns-modal-header h2 {
        font-size: 22px;
    }
    
    .elns-modal-body {
        padding: 24px;
    }
    
    .elns-modal-footer {
        padding: 16px 24px 24px;
    }
    
    .elns-form-row {
        grid-template-columns: 1fr;
    }
    
    .elns-categories-grid {
        grid-template-columns: 1fr;
    }
    
    .elns-modal-icon {
        width: 56px;
        height: 56px;
    }
    
    .elns-modal-icon .dashicons {
        font-size: 28px;
        width: 28px;
        height: 28px;
    }
    
    .elns-modal-close {
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
    }
}

/* Móviles muy pequeños */
@media (max-width: 480px) {
    .elns-modal {
        padding: 5px;
    }
    
    .elns-modal-wrapper {
        max-width: 100% !important; /* Sobrescribir estilos inline */
        width: 100% !important;
        max-height: 98vh;
    }
    
    .elns-modal-header {
        padding: 24px 20px 16px;
    }
    
    .elns-modal-header h2 {
        font-size: 20px;
    }
    
    .elns-modal-body {
        padding: 20px;
    }
    
    .elns-modal-footer {
        padding: 12px 20px 20px;
    }
}

/* ========================================
   SUBSCRIBE TRIGGER BUTTONS
======================================== */
.elns-subscribe-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff !important;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none !important;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.elns-subscribe-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    color: #ffffff !important;
}

.elns-subscribe-trigger .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Variantes de botón */
.elns-subscribe-trigger.elns-btn-outline {
    background: transparent;
    color: #667eea !important;
    border: 2px solid #667eea;
    box-shadow: none;
}

.elns-subscribe-trigger.elns-btn-outline:hover {
    background: #667eea;
    color: #ffffff !important;
}

.elns-subscribe-trigger.elns-btn-small {
    padding: 8px 16px;
    font-size: 14px;
}

.elns-subscribe-trigger.elns-btn-large {
    padding: 16px 32px;
    font-size: 18px;
}

/* Body class when modal is active - el JavaScript maneja el position fixed */
body.elns-modal-active {
    overflow: hidden !important;
}

/* ========================================
   UNSUBSCRIBE BUTTON
======================================== */
.elns-unsubscribe-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #e74c3c;
    color: #ffffff !important;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none !important;
    cursor: pointer;
    transition: all 0.3s ease;
}

.elns-unsubscribe-trigger:hover {
    background: #c0392b;
    transform: translateY(-1px);
    color: #ffffff !important;
}

.elns-unsubscribe-trigger .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.elns-unsubscribe-trigger.elns-btn-link {
    background: transparent;
    color: #e74c3c !important;
    text-decoration: underline !important;
    padding: 0;
}

.elns-unsubscribe-trigger.elns-btn-link:hover {
    color: #c0392b !important;
    transform: none;
}

/* Danger button */
.elns-btn-danger {
    background: #e74c3c;
    color: #ffffff;
}

.elns-btn-danger:hover {
    background: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

/* Unsubscribe form wrapper */
.elns-unsubscribe-form-wrapper {
    max-width: 500px;
    margin: 40px auto;
    padding: 30px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.elns-unsubscribe-form-wrapper h3 {
    margin: 0 0 20px 0;
    text-align: center;
    color: #e74c3c;
}

/* User list styles */
.elns-user-subscribed {
    color: #00a32a;
    font-weight: 600;
}

.elns-user-not-subscribed {
    color: #999;
}

/* Dark mode for unsubscribe */
@media (prefers-color-scheme: dark) {
    .elns-unsubscribe-form-wrapper {
        background: #1e1e1e;
    }
    
    .elns-unsubscribe-form-wrapper h3 {
        color: #ff6b6b;
    }
}

