/* ════════════════════════════════════════════════════════════
   ATS Job Board – Apply Modal Styles (Iframe + Simple Form)
   ════════════════════════════════════════════════════════════ */

/* ─── Modal Overlay ─────────────────────────────────────────── */
.atsjb-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.atsjb-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

/* ─── Modal Content ─────────────────────────────────────────── */
.atsjb-modal-content {
    position: relative;
    background: #fff;
    border-radius: 12px;
    padding: 36px 32px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
    z-index: 1;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Wider modal for iframe content */
.atsjb-modal-content-iframe {
    max-width: 900px;
    width: 94%;
    height: 90vh;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 16px;
}

.atsjb-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    z-index: 2;
}

.atsjb-modal-close:hover {
    color: #333;
    background: #f0f0f0;
}

.atsjb-modal-title {
    font-size: 1.4em;
    margin: 0 0 20px;
    font-weight: 700;
    color: #1a1a1a;
    padding-right: 30px;
    flex-shrink: 0;
}

/* ─── CAPTCHA Gate ──────────────────────────────────────────── */
.atsjb-captcha-gate {
    text-align: center;
    padding: 40px 20px;
}

.atsjb-captcha-prompt {
    font-size: 1.05em;
    color: #444;
    margin: 0 0 24px;
    line-height: 1.5;
}

.atsjb-recaptcha-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.atsjb-captcha-actions {
    margin-top: 8px;
}

.atsjb-captcha-actions .atsjb-btn {
    min-width: 240px;
}

.atsjb-captcha-actions .atsjb-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ─── Iframe Container ──────────────────────────────────────── */
.atsjb-iframe-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

.atsjb-apply-iframe {
    width: 100%;
    flex: 1;
    border: none;
    border-radius: 6px;
    min-height: 400px;
}

/* ─── Loading Spinner ───────────────────────────────────────── */
.atsjb-iframe-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    color: #555;
    font-size: 1em;
}

.atsjb-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #ddd;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: atsjb-spin 0.8s linear infinite;
}

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

/* ─── Status Messages ───────────────────────────────────────── */
.atsjb-apply-status {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 0.9em;
    text-align: center;
    margin-top: 12px;
}

.atsjb-apply-status.atsjb-status-error {
    background: #fdecea;
    color: #b32d2e;
    border: 1px solid #f5c6cb;
}

.atsjb-apply-status.atsjb-status-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* ─── Simple Form Modal Content ─────────────────────────────── */
.atsjb-modal-content-form {
    max-width: 560px;
    width: 94%;
    max-height: 90vh;
    overflow-y: auto;
}

/* ─── Simple Form Styles ────────────────────────────────────── */
.atsjb-simple-form-wrap {
    margin-top: 8px;
}

.atsjb-simple-apply-form .atsjb-form-field {
    margin-bottom: 18px;
}

.atsjb-simple-apply-form label {
    display: block;
    font-weight: 600;
    font-size: 0.9em;
    color: #333;
    margin-bottom: 6px;
}

.atsjb-simple-apply-form label .required {
    color: #d63638;
}

.atsjb-simple-apply-form input[type="text"],
.atsjb-simple-apply-form input[type="email"],
.atsjb-simple-apply-form input[type="tel"] {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.95em;
    border: 1px solid #ccc;
    border-radius: 6px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    background: #fff;
}

.atsjb-simple-apply-form input[type="text"]:focus,
.atsjb-simple-apply-form input[type="email"]:focus,
.atsjb-simple-apply-form input[type="tel"]:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.15);
    outline: none;
}

.atsjb-simple-apply-form input[readonly] {
    background: #f5f5f5;
    color: #555;
    cursor: not-allowed;
}

.atsjb-simple-apply-form input[type="file"] {
    width: 100%;
    padding: 8px;
    font-size: 0.9em;
    border: 2px dashed #ccc;
    border-radius: 6px;
    background: #fafafa;
    cursor: pointer;
    transition: border-color 0.2s;
}

.atsjb-simple-apply-form input[type="file"]:hover {
    border-color: #0073aa;
}

.atsjb-field-help {
    font-size: 0.8em;
    color: #888;
    margin: 4px 0 0;
}

.atsjb-form-recaptcha {
    display: flex;
    justify-content: center;
}

.atsjb-form-submit {
    text-align: center;
    margin-top: 24px;
}

.atsjb-form-submit .atsjb-btn {
    min-width: 220px;
}

.atsjb-form-submit .atsjb-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* General apply inline form */
.atsjb-general-apply-wrap > h2 {
    font-size: 1.4em;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 16px;
}

/* ─── General Apply (force visible on all devices) ──────────── */
.atsjb-general-apply-wrap {
    margin: 20px 0 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    position: relative !important;
    transform: none !important;
    clip: auto !important;
    clip-path: none !important;
    float: none !important;
    width: auto !important;
    min-height: 0 !important;
}

.atsjb-general-apply-wrap .atsjb-simple-form-wrap {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    position: relative !important;
}

.atsjb-general-apply-wrap .atsjb-simple-apply-form {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
}

.atsjb-general-apply-wrap .atsjb-form-field {
    display: block !important;
    visibility: visible !important;
    margin-bottom: 18px !important;
}

.atsjb-general-apply-wrap .atsjb-form-submit {
    display: block !important;
    visibility: visible !important;
}

.atsjb-general-apply-wrap .atsjb-apply-status {
    visibility: visible !important;
}

.atsjb-general-apply-wrap iframe {
    display: block;
    margin: 0 auto;
    max-width: 100%;
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Ensure modal overlay covers full viewport on mobile */
    .atsjb-modal {
        z-index: 9999999;
        -webkit-overflow-scrolling: touch;
    }

    .atsjb-modal-content-iframe {
        width: 98%;
        height: 95vh;
        padding: 20px 16px 12px;
        border-radius: 8px;
    }

    /* Simple form modal: scrollable, auto height */
    .atsjb-modal-content-form {
        width: 95%;
        max-width: 95%;
        height: auto;
        max-height: 92vh;
        padding: 20px 16px 16px;
        border-radius: 8px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .atsjb-modal-title {
        font-size: 1.15em;
    }

    .atsjb-captcha-gate {
        padding: 24px 12px;
    }

    /* Make form inputs full-width and touch-friendly on mobile */
    .atsjb-simple-apply-form input[type="text"],
    .atsjb-simple-apply-form input[type="email"],
    .atsjb-simple-apply-form input[type="tel"] {
        font-size: 16px; /* prevents iOS zoom on focus */
        padding: 12px 14px;
    }

    .atsjb-simple-apply-form input[type="file"] {
        font-size: 14px;
        padding: 10px;
    }

    .atsjb-form-submit .atsjb-btn {
        width: 100%;
        min-width: unset;
        padding: 14px 20px;
        font-size: 1em;
    }

    /* reCAPTCHA widget responsive scaling */
    .atsjb-form-recaptcha {
        transform: scale(0.9);
        transform-origin: center;
    }

    /* General apply inline form on mobile – aggressive overrides */
    .atsjb-general-apply-wrap {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        padding: 0 4px !important;
        position: relative !important;
        z-index: 1 !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .atsjb-general-apply-wrap .atsjb-simple-form-wrap {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 100% !important;
        box-sizing: border-box !important;
        height: auto !important;
    }
    .atsjb-general-apply-wrap .atsjb-simple-apply-form {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    .atsjb-general-apply-wrap .atsjb-form-field {
        display: block !important;
        visibility: visible !important;
    }
    .atsjb-general-apply-wrap .atsjb-form-field input,
    .atsjb-general-apply-wrap .atsjb-form-field label {
        display: block !important;
        visibility: visible !important;
    }
    .atsjb-general-apply-wrap .atsjb-form-submit {
        display: block !important;
        visibility: visible !important;
    }
    .atsjb-general-apply-wrap .atsjb-form-submit .atsjb-btn {
        display: inline-block !important;
        visibility: visible !important;
        width: 100% !important;
    }
    .atsjb-general-apply-wrap input[type="text"],
    .atsjb-general-apply-wrap input[type="email"],
    .atsjb-general-apply-wrap input[type="tel"] {
        font-size: 16px !important; /* prevents iOS auto-zoom */
    }
}

@media (max-width: 480px) {
    .atsjb-modal-content-iframe {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .atsjb-modal-content-form {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        padding: 16px 12px 16px;
    }

    .atsjb-form-recaptcha {
        transform: scale(0.82);
        transform-origin: center;
    }
}
