/* Universal Email Collector Modal Styles - FIXED VERSION */
.uec-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: none;
    z-index: 999999;
    animation: fadeIn 0.3s ease-out;
}

.uec-modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.uec-modal {
    background: #ffffff;
    border-radius: 16px;
    max-width: 480px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.8);
    animation: modalSlideIn 0.4s ease-out forwards;
}

.uec-modal-header {
    background: var(--uec-primary-color, linear-gradient(135deg, #2563eb 0%, #dc2626 100%));
    color: white;
    padding: 24px;
    border-radius: 16px 16px 0 0;
    text-align: center;
    position: relative;
}

.uec-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s ease;
}

.uec-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.uec-modal-icon {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 28px;
}

.uec-modal-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 8px;
    line-height: 1.2;
}

.uec-modal-subtitle {
    font-size: 16px;
    opacity: 0.9;
    margin: 0;
    line-height: 1.4;
}

.uec-modal-body {
    padding: 32px;
}

.uec-benefits {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
}

.uec-benefits li {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
    color: #333;
}

.uec-benefits li:before {
    content: "✓";
    background: var(--uec-primary-color, #2563eb);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
}

.uec-form {
    margin-bottom: 20px;
}

.uec-form-group {
    margin-bottom: 16px;
    position: relative;
}

.uec-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--uec-primary-color, #2563eb);
    font-size: 14px;
}

.uec-form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.2s ease;
    box-sizing: border-box;
    background: #ffffff;
}

.uec-form-group input:focus {
    outline: none;
    border-color: var(--uec-primary-color, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* FIXED: Improved validation states */
.uec-form-group.has-error input,
.uec-form-group input.error {
    border-color: var(--uec-secondary-color, #dc2626);
    background-color: #fef2f2;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.uec-form-group.has-success input,
.uec-form-group input.valid {
    border-color: #10b981;
    background-color: #f0fdf4;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* FIXED: Error message styling */
.uec-error-message {
    color: var(--uec-secondary-color, #dc2626);
    font-size: 12px;
    margin-top: 4px;
    line-height: 1.3;
    display: block;
    font-weight: 500;
}

/* General error messages */
.uec-general-error {
    background: #f8d7da;
    color: #721c24;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid #f5c6cb;
    text-align: center;
    font-weight: 500;
    animation: slideIn 0.3s ease-out;
}

.uec-submit-btn {
    width: 100%;
    background: var(--uec-primary-color, linear-gradient(135deg, #2563eb 0%, #dc2626 100%));
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.uec-submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.3);
    filter: brightness(1.1);
}

.uec-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.uec-submit-btn:disabled:hover {
    transform: none;
    box-shadow: none;
    filter: none;
}

.uec-privacy-notice {
    font-size: 12px;
    color: #666;
    text-align: center;
    margin-top: 16px;
    line-height: 1.4;
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    border-left: 3px solid var(--uec-primary-color, #2563eb);
}

.uec-privacy-notice strong {
    color: var(--uec-secondary-color, #dc2626);
}

.uec-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.uec-submit-btn.loading .uec-loading {
    opacity: 1;
}

.uec-submit-btn.loading .uec-btn-text {
    opacity: 0;
}

.uec-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

.uec-success-message {
    background: #d4edda;
    color: #155724;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid #c3e6cb;
    text-align: center;
    font-weight: 500;
    animation: slideIn 0.3s ease-out;
}

.uec-download-link {
    display: inline-block;
    background: var(--uec-primary-color, #2563eb);
    color: white;
    padding: 12px 24px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    margin-top: 12px;
    transition: all 0.2s ease;
}

.uec-download-link:hover {
    background: var(--uec-secondary-color, #dc2626);
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
}

/* Color customization support */
.uec-modal[data-primary-color] {
    --uec-primary-color: attr(data-primary-color);
}

.uec-modal[data-secondary-color] {
    --uec-secondary-color: attr(data-secondary-color);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.8) translateY(20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* FIXED: Focus management */
.uec-form-group input:focus {
    outline: none;
    border-color: var(--uec-primary-color, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.uec-form-group.has-error input:focus {
    border-color: var(--uec-secondary-color, #dc2626);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* FIXED: Prevent layout shift from error messages */
.uec-form-group {
    min-height: 60px; /* Accommodate label + input + potential error */
}

/* Responsive */
@media (max-width: 768px) {
    .uec-modal {
        width: 95%;
        margin: 20px;
    }
    
    .uec-modal-header {
        padding: 20px;
    }
    
    .uec-modal-body {
        padding: 24px;
    }
    
    .uec-modal-title {
        font-size: 20px;
    }
    
    .uec-modal-subtitle {
        font-size: 14px;
    }
    
    .uec-form-group {
        min-height: 55px;
    }
}

/* Session storage check - hide if already shown */
body.uec-email-submitted .uec-modal-overlay {
    display: none !important;
}

/* Theme variants - can be enabled via custom CSS */
.uec-modal.theme-minimal {
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.uec-modal.theme-minimal .uec-modal-header {
    background: #ffffff;
    color: #333;
    border-bottom: 1px solid #eee;
}

.uec-modal.theme-modern {
    border-radius: 24px;
    backdrop-filter: blur(10px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.uec-modal.theme-corporate {
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.uec-modal.theme-corporate .uec-modal-header {
    background: #f8f9fa;
    color: #333;
    border-bottom: 2px solid var(--uec-primary-color, #2563eb);
}

/* FIXED: Loading state improvements */
.uec-submit-btn.loading {
    pointer-events: none;
}

.uec-submit-btn .uec-btn-text {
    transition: opacity 0.2s ease;
}

/* FIXED: Better error message positioning */
.uec-error-message {
    position: relative;
    z-index: 1;
}

/* FIXED: Accessibility improvements */
.uec-form-group input[aria-invalid="true"] {
    border-color: var(--uec-secondary-color, #dc2626);
    background-color: #fef2f2;
}

.uec-form-group input[aria-invalid="false"] {
    border-color: #10b981;
    background-color: #f0fdf4;
}

.uec-modal .uec-modal-header button.uec-modal-close {
    padding: 0;
    transform: scale(1.5);
}