/* ═══════════════════════════════════════════════════════════════════
   Job Detail Modal  —  jdm-* namespace
   Mobile-first: full-screen bottom sheet on mobile,
   centered Apple popup on ≥768px (tablet/desktop).
   ═══════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────
   1. OVERLAY
   Mobile base: covers whole screen, aligns sheet to bottom.
   ───────────────────────────────────────────────────────────────── */
.jdm-overlay {
    position: fixed;
    inset: 0;
    z-index: 1080;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;       /* ← sheet anchors to bottom */
    justify-content: center;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
}

.jdm-overlay.jdm-open {
    opacity: 1;
    pointer-events: auto;
}

/* ─────────────────────────────────────────────────────────────────
   2. PANEL  (mobile = full-width bottom sheet)
   ───────────────────────────────────────────────────────────────── */
.jdm-box {
    position: relative;
    width: 100%;
    height: 96dvh;                /* nearly full screen */
    background: var(--white, #fff);
    border-radius: 20px 20px 0 0; /* only top corners rounded */
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    touch-action: pan-y;          /* allow vertical swipe */
    transform: translateY(100%);  /* starts off-screen below */
    opacity: 1;
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}

.jdm-overlay.jdm-open .jdm-box {
    transform: translateY(0);
}

/* Drag handle pill on mobile */
.jdm-box::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: var(--gray-300, #d1d5db);
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
}

/* ─────────────────────────────────────────────────────────────────
   3. CLOSE BUTTON
   ───────────────────────────────────────────────────────────────── */
.jdm-close {
    position: absolute;
    top: 20px;           /* clears the drag pill (14px pill + 6px margin) */
    right: 14px;
    z-index: 20;
    background: rgba(243,244,246,0.95);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: none;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--gray-600, #4b5563);
    font-size: .9rem;
    transition: background 0.2s, transform 0.15s;
    flex-shrink: 0;
}

.jdm-close:hover,
.jdm-close:focus-visible {
    background: var(--gray-200, #e5e7eb);
    transform: scale(1.1);
    outline: none;
}

/* ─────────────────────────────────────────────────────────────────
   4. SCROLL WRAPPER  (the content area between handle and bottom)
   ───────────────────────────────────────────────────────────────── */
.jdm-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    /* Safe-area for notch phones */
    padding-bottom: env(safe-area-inset-bottom, 1rem);
}

.jdm-scroll::-webkit-scrollbar { width: 5px; }
.jdm-scroll::-webkit-scrollbar-thumb {
    background: var(--gray-300, #d1d5db);
    border-radius: 4px;
}

/* ─────────────────────────────────────────────────────────────────
   5.  CONTENT OVERRIDES — make job_detail layout work inside modal
       Stack the Bootstrap col-lg-4 sidebar below on mobile.
   ───────────────────────────────────────────────────────────────── */

/* Ensure job-card inside scroll has reasonable spacing */
.jdm-scroll .job-card {
    margin-bottom: 0 !important;
    border-radius: 0;
    box-shadow: none;
    border: none;
}

/* Remove back-link that shouldn't appear in modal */
.jdm-scroll .back-link { display: none; }

/* Keep close button visible over header */
.jdm-scroll .px-3 { padding-top: 2.5rem; }

/* On mobile, force sidebar (col-lg-4) to stack after the main col */
.jdm-scroll .col-lg-4 {
    width: 100%;
    max-width: 100%;
    padding-top: 0;
}

/* Make d-grid buttons full-width naturally */
.jdm-scroll .d-grid { display: grid; }

/* Ensure action buttons look good in the sheet */
.jdm-scroll .btn-apply,
.jdm-scroll .btn-secondary-custom {
    min-height: 46px;
    font-size: .9rem;
}

/* ─────────────────────────────────────────────────────────────────
   6. LOADING / ERROR STATES
   ───────────────────────────────────────────────────────────────── */
.jdm-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 5rem 2rem;
    color: var(--gray-500, #6b7280);
    font-size: .9rem;
}

.jdm-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid var(--gray-200, #e5e7eb);
    border-top-color: var(--primary-blue, #2563eb);
    border-radius: 50%;
    animation: jdm-spin 0.75s linear infinite;
}

.jdm-spinner-sm {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: jdm-spin 0.7s linear infinite;
    vertical-align: middle;
}

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

.jdm-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    padding: 5rem 2rem;
    text-align: center;
    color: var(--gray-500, #6b7280);
    font-size: .9rem;
}
.jdm-error i    { font-size: 2.5rem; color: var(--error, #ef4444); }
.jdm-error a    { color: var(--primary-blue, #2563eb); text-decoration: none; }

/* ─────────────────────────────────────────────────────────────────
   7. MISC jdm-* elements (kept for backward compat)
   ───────────────────────────────────────────────────────────────── */
.jdm-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    border-radius: 50px;
    font-size: .85rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.18s, box-shadow 0.18s, background 0.18s;
    white-space: nowrap;
}
.jdm-btn:hover { transform: translateY(-1px); }

.jdm-btn-primary {
    background: var(--primary-gradient, linear-gradient(135deg,#3b82f6,#2563eb));
    color: #fff;
}
.jdm-btn-primary:hover { box-shadow: 0 6px 18px rgba(37,99,235,.35); color: #fff; text-decoration: none; }

.jdm-btn-secondary {
    background: var(--gray-100, #f3f4f6);
    color: var(--gray-700, #374151);
    border: 1px solid var(--gray-200, #e5e7eb);
}
.jdm-btn-secondary:hover { background: var(--gray-200, #e5e7eb); }
.jdm-btn-secondary.jdm-saved {
    background: var(--success-gradient, linear-gradient(135deg,#22c55e,#16a34a));
    color: #fff;
    border-color: transparent;
}

.jdm-btn-ghost {
    background: transparent;
    color: var(--primary-blue, #2563eb);
    border: 1px solid var(--primary-blue, #2563eb);
}
.jdm-btn-ghost:hover { background: var(--primary-blue-50, #eff6ff); text-decoration: none; color: var(--primary-blue, #2563eb); }

/* Skills tags */
.jdm-skill-tag {
    display: inline-block;
    background: var(--gray-100, #f3f4f6);
    color: var(--gray-700, #374151);
    padding: .3rem .75rem;
    border-radius: 50px;
    font-size: .8rem;
    font-weight: 500;
    border: 1px solid var(--gray-200, #e5e7eb);
}

/* ═══════════════════════════════════════════════════════════════════
   DESKTOP OVERRIDES  (≥ 768px)
   Become a centred Apple-style popup instead of a bottom sheet.
   ═══════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) {

    .jdm-overlay {
        align-items: center;        /* vertically centred */
        justify-content: center;
        padding: 1.5rem;
    }

    .jdm-box {
        width: min(940px, 100%);
        height: min(88dvh, 860px);
        border-radius: 20px;         /* all corners rounded */
        box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22),
                    0 8px 20px rgba(0, 0, 0, 0.12);
        transform: scale(0.93) translateY(14px); /* spring-in from slightly below-centre */
        opacity: 0;
        transition: transform 0.42s cubic-bezier(0.175, 0.885, 0.32, 1.15),
                    opacity 0.28s ease;
    }

    /* Hide the drag pill on desktop */
    .jdm-box::before { display: none; }

    .jdm-overlay.jdm-open .jdm-box {
        transform: scale(1) translateY(0);
        opacity: 1;
    }

    /* Restore Bootstrap grid columns inside the modal */
    .jdm-scroll .col-lg-4 {
        width: 33.3333%;
        max-width: 33.3333%;
    }

    .jdm-scroll .col-lg-8 {
        width: 66.6667%;
        max-width: 66.6667%;
    }

    /* Remove extra padding top override */
    .jdm-scroll .px-3 { padding-top: 0; }
}
