/**
 * Email Capture Modal Styles
 * Mobile-first responsive design for questionnaire lead generation
 * Integrates with questionnaire-base.css theme system
 */

/* ==================== MODAL CONTAINER ==================== */
.email-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.email-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ==================== MODAL CONTENT ==================== */
.email-modal-content {
    position: relative;
    background: white;
    border-radius: 24px;
    padding: 40px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    animation: modalSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-40px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ==================== CLOSE BUTTON ==================== */
.email-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 2rem;
    color: #a0aec0;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    line-height: 1;
}

.email-modal-close:hover {
    background: #f7fafc;
    color: #2d3748;
    transform: rotate(90deg);
}

.email-modal-close:focus-visible {
    outline: 3px solid var(--primary-color, #667eea);
    outline-offset: 2px;
}

/* ==================== HEADER ==================== */
.email-modal-header {
    text-align: center;
    margin-bottom: 32px;
}

.email-modal-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--primary-color, #667eea);
    margin-bottom: 12px;
    line-height: 1.3;
}

.email-modal-header p {
    font-size: 1rem;
    color: #718096;
    line-height: 1.5;
}

/* ==================== FORM ==================== */
.email-modal-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.email-modal-input {
    width: 100%;
    padding: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
    background: white;
}

.email-modal-input:focus {
    outline: none;
    border-color: var(--primary-color, #667eea);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.email-modal-input::placeholder {
    color: #cbd5e0;
}

.email-modal-input:focus::placeholder {
    color: #a0aec0;
}

/* HTML5 validation states */
.email-modal-input:invalid:not(:placeholder-shown) {
    border-color: #fc8181;
}

.email-modal-input:valid:not(:placeholder-shown) {
    border-color: #48bb78;
}

/* ==================== SUBMIT BUTTON ==================== */
.email-modal-submit {
    padding: 16px 32px;
    font-size: 1.1rem;
    font-weight: 600;
    background: var(--primary-color, #667eea);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    margin-top: 8px;
}

.email-modal-submit:hover:not(:disabled) {
    background: var(--primary-color-dark, #5568d3);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.email-modal-submit:active:not(:disabled) {
    transform: translateY(0);
    transition: transform 0.1s ease;
}

.email-modal-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.email-modal-submit:focus-visible {
    outline: 3px solid var(--primary-color-dark, #5568d3);
    outline-offset: 2px;
}

/* ==================== PRIVACY TEXT ==================== */
.email-modal-privacy {
    text-align: center;
    font-size: 0.85rem;
    color: #a0aec0;
    margin-top: 8px;
    line-height: 1.4;
}

/* ==================== SUCCESS STATE ==================== */
.email-modal-success {
    text-align: center;
    padding: 20px 0;
}

.success-icon {
    width: 80px;
    height: 80px;
    background: var(--primary-color, #667eea);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    margin: 0 auto 24px;
    animation: successPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-weight: 300;
}

@keyframes successPop {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.email-modal-success h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 12px;
}

.email-modal-success p {
    font-size: 1rem;
    color: #718096;
    line-height: 1.6;
}

/* ==================== ERROR STATE ==================== */
.email-modal-error {
    background: #fed7d7;
    color: #c53030;
    padding: 14px 18px;
    border-radius: 10px;
    margin-top: 16px;
    border: 2px solid #fc8181;
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: errorShake 0.4s ease;
}

.email-modal-error strong {
    font-weight: 600;
}

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

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

/* Tablet (768px and below) */
@media (max-width: 768px) {
    .email-modal-content {
        padding: 36px 28px;
        border-radius: 20px;
        max-width: 450px;
    }

    .email-modal-header h2 {
        font-size: 1.6rem;
    }

    .email-modal-header p {
        font-size: 0.95rem;
    }

    .success-icon {
        width: 72px;
        height: 72px;
        font-size: 2.75rem;
    }

    .email-modal-submit {
        font-size: 1.05rem;
        padding: 15px 28px;
    }
}

/* Mobile (640px and below) */
@media (max-width: 640px) {
    .email-modal {
        padding: 16px;
    }

    .email-modal-content {
        padding: 32px 24px;
        border-radius: 20px;
    }

    .email-modal-header h2 {
        font-size: 1.5rem;
    }

    .email-modal-header p {
        font-size: 0.95rem;
    }

    .success-icon {
        width: 64px;
        height: 64px;
        font-size: 2.5rem;
    }

    .email-modal-input {
        padding: 14px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    .email-modal-submit {
        padding: 14px 24px;
        font-size: 1rem;
    }

    .email-modal-close {
        top: 12px;
        right: 12px;
        width: 40px;
        height: 40px;
        font-size: 1.75rem;
    }

    .email-modal-privacy {
        font-size: 0.8rem;
    }

    .email-modal-error {
        font-size: 0.85rem;
        padding: 12px 16px;
    }
}

/* Small mobile (480px and below) */
@media (max-width: 480px) {
    .email-modal-content {
        padding: 28px 20px;
    }

    .email-modal-header h2 {
        font-size: 1.35rem;
    }

    .email-modal-header p {
        font-size: 0.9rem;
    }

    .email-modal-form {
        gap: 14px;
    }

    .success-icon {
        width: 56px;
        height: 56px;
        font-size: 2.25rem;
        margin-bottom: 20px;
    }

    .email-modal-success h3 {
        font-size: 1.35rem;
    }

    .email-modal-success p {
        font-size: 0.95rem;
    }
}

/* Large desktop (1280px and above) */
@media (min-width: 1280px) {
    .email-modal-content {
        max-width: 550px;
        padding: 48px;
    }

    .email-modal-header h2 {
        font-size: 1.9rem;
    }

    .email-modal-header p {
        font-size: 1.05rem;
    }

    .success-icon {
        width: 88px;
        height: 88px;
        font-size: 3.25rem;
    }
}

/* ==================== ACCESSIBILITY ==================== */

/* Keyboard navigation focus states */
.email-modal-input:focus-visible,
.email-modal-submit:focus-visible,
.email-modal-close:focus-visible {
    outline: 3px solid var(--primary-color, #667eea);
    outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .email-modal-content {
        border: 3px solid currentColor;
    }

    .email-modal-input {
        border-width: 3px;
    }

    .email-modal-submit {
        border: 3px solid white;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .email-modal-overlay,
    .email-modal-content,
    .success-icon,
    .email-modal-error,
    .email-modal-close,
    .email-modal-submit,
    .email-modal-input {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .email-modal-overlay {
        animation: none;
    }

    .email-modal-content {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .success-icon {
        animation: none;
        transform: none;
    }

    .email-modal-error {
        animation: none;
        transform: none;
    }
}

/* ==================== THEME COMPATIBILITY ==================== */

/* Dark mode support (if theme system extends to dark mode) */
@media (prefers-color-scheme: dark) {
    /* Keep modal always light for readability */
    .email-modal-content {
        background: white;
        color: #2d3748;
    }

    .email-modal-header h2 {
        color: var(--primary-color, #667eea);
    }

    .email-modal-header p,
    .email-modal-success p {
        color: #718096;
    }

    .email-modal-success h3 {
        color: #2d3748;
    }

    .email-modal-input {
        background: white;
        color: #2d3748;
    }
}

/* Print styles (hide modal when printing) */
@media print {
    .email-modal {
        display: none !important;
    }
}
