/**
 * Infocruit — Single Job Listing Page Styles
 * Extracted from single-job_listing.php (H9 fix).
 * Enqueued only on single job_listing pages via functions.php.
 *
 * Class prefix: ijdp- (Infocruit Job Detail Page)
 */

/* ── Reduced-motion safety (M1) ─────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .ijdp-back,
    .ijdp-apply-btn,
    .ijdp-apply-online,
    .ijdp-rjob-card {
        transition: none !important;
    }
}

/* ── Layout ──────────────────────────────────────────────────────────────────── */
.ijdp-wrap {
    background: #f3f4f6;
    min-height: 100vh;
    padding: 28px 0 60px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ijdp-inner {
    width: 100%;
    max-width: 1150px; /* Reduced from 1440px to add space on sides */
    margin: 0 auto; /* Keeps it perfectly centered */
    padding: 0 16px;
}

/* ── Back link ───────────────────────────────────────────────────────────────── */
.ijdp-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #6b7280;
    text-decoration: none;
    margin-bottom: 20px;
    transition: color .15s;
}

.ijdp-back:hover {
    color: #3b82f6;
}

/* ── Header card ─────────────────────────────────────────────────────────────── */
.ijdp-header {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 24px 28px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}

.ijdp-header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 20px;
    justify-content: space-between;
}

.ijdp-header-left {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex: 1;
    min-width: 0;
}

/* ── Avatar ──────────────────────────────────────────────────────────────────── */
.ijdp-avatar {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 24px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ── Title & org ─────────────────────────────────────────────────────────────── */
.ijdp-title {
    margin: 0 0 6px;
    font-size: 18px; /* Reduced per request */
    font-weight: 700;
    color: #111827;
    line-height: 1.3;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ijdp-org {
    margin: 0 0 6px;
    font-size: 15px;
    color: #374151; /* Darker grey as requested */
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Force the location span wrapper to perfectly center the icon */
.ijdp-org > span {
    display: inline-flex !important;
    align-items: center !important;
}

/* Ensure the location icon perfectly matches the font size and is centered */
.ijdp-org svg {
    display: block !important;
    width: 1em !important;
    height: 1em !important;
    margin-top: 0 !important;
}

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.ijdp-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.ijdp-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.ijdp-badge-new {
    background: #3b82f6;
    color: #fff;
}

.ijdp-badge-blue {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.ijdp-badge-outline {
    border: 1px solid #d1d5db;
    color: #374151;
    background: transparent;
}

/* ── Apply button ────────────────────────────────────────────────────────────── */
.ijdp-apply-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: #3b82f6;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 22px;
    border-radius: 8px;
    text-decoration: none;
    transition: background .15s;
    flex-shrink: 0;
    min-height: 44px; /* WCAG touch target */
}

.ijdp-apply-btn:hover {
    background: #2563eb;
    color: #fff;
}

@media (max-width: 640px) {
    .ijdp-header {
        padding: 20px 16px;
    }
    .ijdp-header-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    .ijdp-title {
        font-size: 18px; /* Smaller title on mobile */
    }
    .ijdp-avatar {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
    .ijdp-apply-btn {
        width: 100%;
        justify-content: center;
        order: 3;
    }
    .ijdp-badges {
        order: 2;
    }
    .ijdp-stats {
        padding: 14px 16px;
        gap: 16px;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── Stats bar ───────────────────────────────────────────────────────────────── */
.ijdp-stats {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 14px 22px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
}

.ijdp-stat-label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin: 0 0 2px;
}

.ijdp-stat-val {
    font-size: 15px;
    font-weight: 700;
    color: #1e40af;
    margin: 0;
    min-width: 0;
    overflow-wrap: break-word;
}

/* ── Two-column grid layout ──────────────────────────────────────────────────── */
.ijdp-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 22px;
    align-items: start; /* Required for sticky children to work */
}

/* Make the right sidebar follow the user down the page */
.ijdp-sidebar-wrapper {
    position: sticky;
    top: 80px;
}

@media (max-width: 900px) {
    .ijdp-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Content cards ───────────────────────────────────────────────────────────── */
.ijdp-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
    /* Prevent any child content from bleeding past the card on mobile */
    overflow: hidden;
    min-width: 0;
}

.ijdp-section {
    margin-bottom: 28px;
}

.ijdp-section:last-child {
    margin-bottom: 0;
}

.ijdp-sh {
    font-size: 17px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 12px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ijdp-body {
    font-size: 16px; /* Slightly reduced for readability */
    color: #374151;
    line-height: 1.6;
    margin: 0;
}

/* ── Typography & Table Overrides (FreeJobAlert Style) ───────────────────────── */
.ijdp-body p { margin-bottom: 1.25em; }
.ijdp-body h2 { font-size: 18px; font-weight: 700; margin-top: 1.4em; margin-bottom: 0.5em; color: #111827; }
.ijdp-body h3 { font-size: 16px; font-weight: 700; margin-top: 1.4em; margin-bottom: 0.5em; color: #111827; }
.ijdp-body ul { list-style-type: disc; padding-left: 1.5em; margin-bottom: 1.25em; }
.ijdp-body ol { list-style-type: decimal; padding-left: 1.5em; margin-bottom: 1.25em; }
.ijdp-body li { margin-bottom: 0.5em; }
.ijdp-body strong { font-weight: 700; color: #111827; }
.ijdp-body a { color: #2563eb; text-decoration: underline; text-underline-offset: 2px; }
.ijdp-body a:hover { color: #1d4ed8; }

/* Enforce 100% width, high-contrast tables against Tailwind reset */
/* Mobile: wrap all tables in a scrollable container so long content
   scrolls horizontally instead of overflowing to the right */
.ijdp-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 16px;
    table-layout: auto;
}
/* Scrollable table wrapper — applied via JS below, or use CSS display trick */
.ijdp-body .table-scroll-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1.5em 0;
    border-radius: 8px;
    border: 1px solid #d1d5db;
}
.ijdp-body .table-scroll-wrap table {
    margin: 0;
    border: none;
}
.ijdp-body table th {
    background-color: #f3f4f6;
    font-weight: 700;
    text-align: left;
    padding: 14px 16px;
    border: 1px solid #d1d5db;
    color: #111827;
    word-break: break-word;
    min-width: 100px;
}
.ijdp-body table td {
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    vertical-align: top;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 280px;
}
.ijdp-body table tr:nth-child(even) {
    background-color: #f9fafb;
}

.ijdp-req-list {
    margin: 0;
    padding-left: 20px;
    font-size: 14px;
    color: #374151;
    line-height: 1.9;
}

.ijdp-dates {
    margin: 0;
    padding-left: 20px;
    font-size: 14px;
    color: #374151;
    line-height: 1.9;
}

.ijdp-date-row {
    margin-bottom: 4px;
}

.ijdp-date-label {
    font-weight: 600;
    color: #111827;
}

.ijdp-date-val {
    color: #374151;
}

/* ── Apply online button ─────────────────────────────────────────────────────── */
.ijdp-apply-online {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 8px;
    background: #10b981;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    margin-top: 12px;
    min-height: 44px; /* WCAG touch target */
}

.ijdp-apply-online:hover {
    background: #059669;
    color: #fff;
}

/* ── Official Notification button — matches apply-online size exactly ────────── */
.ic-notif-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    color: #dc2626;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    border: 1.5px solid #dc2626;
    min-height: 44px;
    margin-top: 12px;
    box-sizing: border-box;
    transition: background .15s, color .15s;
    cursor: pointer;
}

.ic-notif-btn:hover {
    background: #dc2626;
    color: #fff;
}

/* ── Related Jobs sidebar ────────────────────────────────────────────────────── */
.ijdp-sidebar-title {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 16px;
}


.ijdp-rjobs {
    display: flex;
    overflow-y: auto;
    scrollbar-width: none;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    gap: 16px;
}
.ijdp-rjobs::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Edge */
}
.ijdp-rjob-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 18px 20px;
    text-decoration: none;
    display: block;
    transition: box-shadow .15s, border-color .15s;
}

.ijdp-rjob-card:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, .09);
    border-color: #93c5fd;
}

.ijdp-rjob-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.ijdp-rjob-badge {
    display: inline-flex;
    align-items: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ijdp-rjob-new {
    font-size: 13px;
    font-weight: 700;
    color: #ef4444;
}

.ijdp-rjob-title {
    font-size: 15px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 8px;
    line-height: 1.4;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ijdp-rjob-meta {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ijdp-rjob-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #4b5563;
    font-weight: 500;
}

.ijdp-rjob-row svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    color: #6b7280;
}

/* ── Mobile Layout Fixes ─────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .ijdp-inner {
        padding-left: 16px !important;
        padding-right: 16px !important;
        overflow-x: hidden;
    }
    .ijdp-card {
        padding: 20px 16px;
        overflow: hidden;
    }
    /* Make all tables inside the body scrollable horizontally on mobile */
    .ijdp-body {
        overflow-x: hidden;
        max-width: 100%;
    }
    .ijdp-body table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: normal;
        max-width: 100%;
        font-size: 14px;
    }
    .ijdp-body table th,
    .ijdp-body table td {
        padding: 10px 12px;
        word-break: break-word;
        overflow-wrap: break-word;
        white-space: normal;
        max-width: 200px;
    }
    /* Named table classes: facts-table, post-summary, dates-meta-table */
    .ijdp-body .facts-table,
    .ijdp-body .post-summary,
    .ijdp-body .dates-meta-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        font-size: 14px;
    }
    .ijdp-body .facts-table th,
    .ijdp-body .facts-table td,
    .ijdp-body .post-summary th,
    .ijdp-body .post-summary td,
    .ijdp-body .dates-meta-table th,
    .ijdp-body .dates-meta-table td {
        padding: 10px 12px;
        word-break: break-word;
        overflow-wrap: break-word;
        white-space: normal;
        min-width: 100px;
        max-width: 200px;
    }
    .ijdp-rjobs {
        max-width: 100%;
        overflow: visible;
        padding-bottom: 20px;
    }
    .ijdp-rjob-card {
        border-radius: 12px !important;
        margin: 0 !important;
        max-width: 100%;
        box-sizing: border-box;
    }
}
.ijdp-rjobs::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Edge */
}

/* ── Ad Slot Responsiveness Fix ──────────────────────────────────────────────── */
/* Prevents any AdSense unit from causing horizontal scroll or overflow inside   */
/* the padded .ijdp-card container, especially on narrow mobile viewports.        */
.ic-ad-slot {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    margin-top: 16px;
    margin-bottom: 16px;
}

/* Force AdSense <ins> and <iframe> elements to respect container width */
.ic-ad-slot ins,
.ic-ad-slot iframe,
.ic-ad-slot > div {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* On mobile, remove any horizontal padding bleed from the card */
@media (max-width: 640px) {
    .ijdp-card .ic-ad-slot {
        margin-left: -4px;
        margin-right: -4px;
        width: calc(100% + 8px);
    }
}

/* ── AI Generated Article Components (TOC, Callouts, Tables) ─────────────────── */
.ijdp-body .toc {
    background: #f8fbff;
    border: 1px solid #dbeafe;
    border-radius: 18px;
    padding: 18px 20px;
    margin-top: 6px;
    margin-bottom: 24px;
}
.ijdp-body .toc h2 { font-size: 18px !important; margin: 0 0 12px; color: #0f172a; border: none; padding: 0; }
.ijdp-body .toc-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 20px; margin: 0; padding-left: 18px; list-style-type: decimal; }
.ijdp-body .toc-list li { margin-bottom: 8px; font-size: 16px; }
.ijdp-body .lead { font-size: 17px !important; line-height: 1.8 !important; color: #4b5563; font-weight: 400; }
.ijdp-body .toc-list a { color: #1e3a8a; text-decoration: none; font-weight: 600; }
.ijdp-body .toc-list a:hover { text-decoration: underline; }

.ijdp-body .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 20px 0 16px; }

.ijdp-body .callout { padding: 18px; border-radius: 16px; border: 1px solid #e5e7eb; background: #f9fafb; }
.ijdp-body .callout.good { background: #f0fdf4; border-color: #bbf7d0; }
.ijdp-body .callout.warn { background: #fff7ed; border-color: #fed7aa; }
.ijdp-body .callout h3 { margin-top: 0; margin-bottom: 8px; font-size: 18px; color: #111827; }
.ijdp-body .callout ul.compact-list { padding-left: 20px; margin: 10px 0 0; list-style-type: disc;}
.ijdp-body .callout ul.compact-list li { margin-bottom: 8px; color: #374151; font-size: 15px;}

.ijdp-body .facts-table,
.ijdp-body .post-summary,
.ijdp-body .dates-meta-table {
    width: 100%;
    border-collapse: collapse;
    margin: 18px 0 24px;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    /* Use overflow:hidden on desktop only — mobile overrides to block+overflow-x:auto */
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    display: table;
}
.ijdp-body .facts-table th, .ijdp-body .facts-table td,
.ijdp-body .post-summary th, .ijdp-body .post-summary td,
.ijdp-body .dates-meta-table th, .ijdp-body .dates-meta-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
    font-size: 15px;
    border-left: none;
    border-right: none;
    word-break: break-word;
    overflow-wrap: break-word;
}
.ijdp-body .facts-table th,
.ijdp-body .post-summary th,
.ijdp-body .dates-meta-table th {
    background: #f8fbff; color: #1e3a8a; font-weight: 700; border-bottom: 2px solid #bfdbfe;
}
.ijdp-body .facts-table tr:last-child td,
.ijdp-body .post-summary tr:last-child td,
.ijdp-body .dates-meta-table tr:last-child td { border-bottom: none; }

.ijdp-body .job-block { padding: 20px 0; border-top: 1px solid #e5e7eb; }
.ijdp-body .job-block:first-of-type { border-top: none; padding-top: 8px; }
.ijdp-body .job-meta { display: inline-block; margin-bottom: 10px; font-size: 13px; font-weight: 700; color: #1e40af; background: #eff6ff; border: 1px solid #dbeafe; padding: 6px 12px; border-radius: 999px; }

@media (max-width: 720px) {
    .ijdp-body .two-col, .ijdp-body .toc-list { grid-template-columns: 1fr; }
}

/* ── AI Generated Components: FAQs, Steps, and Lists ─────────────────────── */
.ijdp-body ul.compact-list { padding-left: 20px; margin: 10px 0 16px; list-style-type: disc; }
.ijdp-body ul.compact-list li { margin-bottom: 8px; color: #374151; font-size: 15px; }

.ijdp-body .steps { margin: 18px 0; padding-left: 28px; list-style-type: decimal; }
.ijdp-body .steps li { margin-bottom: 12px; padding-left: 6px; color: #374151; font-size: 16px; }
.ijdp-body .steps li::marker { font-weight: 700; color: #64748b; }

.ijdp-body .faq-list { display: grid; gap: 12px; margin-top: 16px; counter-reset: faq; }
.ijdp-body .faq-item { border: 1px solid #e5e7eb; border-radius: 12px; background: #fcfcfd; overflow: hidden; }
.ijdp-body .faq-item[open] { background: #ffffff; box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04); }
.ijdp-body .faq-item summary { list-style: none; cursor: pointer; position: relative; padding: 16px 40px 16px 48px; font-size: 16px; font-weight: 700; color: #111827; }
.ijdp-body .faq-item summary::-webkit-details-marker { display: none; }
.ijdp-body .faq-item summary::before { counter-increment: faq; content: counter(faq) "."; position: absolute; left: 16px; top: 16px; color: #1d4ed8; font-weight: 800; }
.ijdp-body .faq-item summary::after { content: "+"; position: absolute; right: 16px; top: 14px; font-size: 22px; line-height: 1; color: #1d4ed8; }
.ijdp-body .faq-item[open] summary::after { content: "−"; }
.ijdp-body .faq-answer { padding: 0 16px 16px 48px; color: #4b5563; font-size: 15px; }
.ijdp-body .faq-answer p { margin: 0; }

/* ── AI Generated Layout Gap Fixes (Overriding Tailwind Prose) ───────── */
.ijdp-body table { margin-top: 0 !important; }
.ijdp-body h2 { margin-top: 32px !important; margin-bottom: 16px !important; }
.ijdp-body .toc { margin-top: 24px !important; margin-bottom: 24px !important; }
.ijdp-body .two-col { margin-top: 8px !important; }

/* ── Extreme Prose Cleanups (Tightening Job Blocks & TOC) ───────── */
/* TOC Lines */
.ijdp-body .toc-list { row-gap: 4px !important; }
.ijdp-body .toc-list li { margin-top: 0 !important; margin-bottom: 0 !important; line-height: 1.4 !important; padding: 0 !important; }

/* Job Blocks Data Flow */
.ijdp-body .job-block h3 { margin-top: 6px !important; margin-bottom: 6px !important; }
.ijdp-body .job-block > p { margin-top: 0 !important; margin-bottom: 12px !important; }
.ijdp-body .job-block ul.compact-list { margin-top: 0 !important; margin-bottom: 12px !important; padding-top: 0 !important; padding-bottom: 0 !important; }
.ijdp-body .job-block ul.compact-list li { margin-top: 4px !important; margin-bottom: 4px !important; }
.ijdp-body p.job-pay { margin-top: 0 !important; margin-bottom: 0 !important; padding-top: 4px !important; }

/* ── Crush internal header margins inside cards (Tailwind Prose Override) ───────── */
.ijdp-body .toc h2 { margin-top: 0 !important; padding-top: 0 !important; }
.ijdp-body .callout h3 { margin-top: 0 !important; padding-top: 0 !important; line-height: 1.2 !important; }
