/* EDCare Email Marketing — Frontend Popup
   Mobile-first, accessible, professional styling. */

.edcare-em-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.edcare-em-popup-overlay[hidden] {
    display: none;
}

.edcare-em-popup-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.edcare-em-popup-card {
    position: relative;
    width: 100%;
    max-width: 440px;
    background: #ffffff;
    border-radius: 20px;
    padding: 40px 28px 32px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
    transform: translateY(20px) scale(0.97);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    box-sizing: border-box;
}

.edcare-em-popup-overlay.is-open .edcare-em-popup-card {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.edcare-em-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    padding: 0;
}

.edcare-em-popup-close:hover,
.edcare-em-popup-close:focus-visible {
    background: #e2e8f0;
    color: #0f172a;
    outline: none;
    transform: rotate(90deg);
}

.edcare-em-popup-badge {
    display: inline-block;
    background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
    padding: 6px 14px;
    border-radius: 999px;
    margin-bottom: 16px;
    text-transform: uppercase;
}

.edcare-em-popup-heading {
    margin: 0 0 10px 0;
    font-size: 26px;
    line-height: 1.2;
    font-weight: 800;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.edcare-em-popup-sub {
    margin: 0 0 24px 0;
    font-size: 15px;
    line-height: 1.5;
    color: #64748b;
}

.edcare-em-popup-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 0;
}

.edcare-em-popup-field {
    display: block;
    text-align: left;
}

.edcare-em-popup-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}

.edcare-em-popup-form input {
    width: 100%;
    box-sizing: border-box;
    padding: 13px 14px;
    font-size: 16px; /* >=16px prevents iOS zoom */
    line-height: 1.4;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    background: #ffffff;
    color: #0f172a;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
}

.edcare-em-popup-form input::placeholder {
    color: #94a3b8;
}

.edcare-em-popup-form input:hover {
    border-color: #cbd5e1;
}

.edcare-em-popup-form input:focus {
    outline: none;
    border-color: #0f172a;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.1);
}

.edcare-em-popup-form input.has-error {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.edcare-em-popup-submit {
    position: relative;
    width: 100%;
    padding: 15px 20px;
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    letter-spacing: 0.01em;
    margin-top: 6px;
    font-family: inherit;
}

.edcare-em-popup-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.25);
}

.edcare-em-popup-submit:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.3);
}

.edcare-em-popup-submit:active:not(:disabled) {
    transform: translateY(0);
}

.edcare-em-popup-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.edcare-em-popup-submit.is-loading .edcare-em-popup-submit-label {
    visibility: hidden;
}

.edcare-em-popup-submit.is-loading .edcare-em-popup-spinner {
    display: block;
}

.edcare-em-popup-spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: edcare-em-spin 0.7s linear infinite;
}

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

.edcare-em-popup-fineprint {
    margin: 8px 0 0 0;
    font-size: 12px;
    line-height: 1.45;
    color: #94a3b8;
    text-align: center;
}

.edcare-em-popup-message {
    margin: 0;
    font-size: 14px;
    color: #dc2626;
    text-align: center;
    min-height: 0;
    transition: min-height 0.2s ease;
}

.edcare-em-popup-message:not(:empty) {
    min-height: 20px;
    margin-top: 4px;
}

/* Success state */
.edcare-em-popup-success {
    text-align: center;
    padding: 8px 0;
}

.edcare-em-popup-success-icon {
    color: #10b981;
    margin: 0 auto 16px;
    display: inline-block;
    animation: edcare-em-pop 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes edcare-em-pop {
    0%   { transform: scale(0.4); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.edcare-em-popup-success-title {
    margin: 0 0 8px 0;
    font-size: 22px;
    font-weight: 800;
    color: #0f172a;
}

.edcare-em-popup-success-text {
    margin: 0 0 24px 0;
    font-size: 15px;
    line-height: 1.5;
    color: #64748b;
}

.edcare-em-popup-success-btn {
    margin-top: 0;
}

/* Mobile breakpoint */
@media (max-width: 480px) {
    .edcare-em-popup-overlay {
        padding: 12px;
        align-items: flex-end;
    }

    .edcare-em-popup-card {
        padding: 32px 22px 24px;
        border-radius: 18px;
        max-height: calc(100vh - 24px);
    }

    .edcare-em-popup-heading {
        font-size: 22px;
    }

    .edcare-em-popup-sub {
        font-size: 14px;
        margin-bottom: 20px;
    }

    .edcare-em-popup-badge {
        font-size: 11px;
        padding: 5px 12px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .edcare-em-popup-overlay,
    .edcare-em-popup-card,
    .edcare-em-popup-close,
    .edcare-em-popup-submit,
    .edcare-em-popup-success-icon {
        transition: none;
        animation: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .edcare-em-popup-card {
        background: #0f172a;
        color: #f1f5f9;
    }
    .edcare-em-popup-heading { color: #f8fafc; }
    .edcare-em-popup-sub { color: #94a3b8; }
    .edcare-em-popup-label { color: #cbd5e1; }
    .edcare-em-popup-form input {
        background: #1e293b;
        border-color: #334155;
        color: #f1f5f9;
    }
    .edcare-em-popup-form input::placeholder { color: #64748b; }
    .edcare-em-popup-form input:focus {
        border-color: #f1f5f9;
        box-shadow: 0 0 0 3px rgba(241, 245, 249, 0.15);
    }
    .edcare-em-popup-submit {
        background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
        color: #0f172a;
    }
    .edcare-em-popup-close {
        background: #1e293b;
        color: #94a3b8;
    }
    .edcare-em-popup-close:hover { background: #334155; color: #f1f5f9; }
    .edcare-em-popup-success-title { color: #f8fafc; }
    .edcare-em-popup-success-text { color: #94a3b8; }
}
