/* =============================================================
   PARSED CONTRACTS REPORT — parsed_contracts_report_v4.css
   PLA-10. Mirrors salary_report_v4.css conventions:
     - var(--jt-bg-deep) for the modal background
     - var(--jt-border-muted) for subtle borders
     - var(--jt-text-primary/secondary/muted) for text
     - HARDCODED linear-gradient(135deg, #1e3a5f 0%, #1a2942 100%)
       for the header (theme-independent)
     - HARDCODED #fff and rgba(255,255,255,0.85) for text on gradient
   No explicit [data-theme="light"] block — tokens auto-flip via
   jt_theme_v4.css.
   ============================================================= */

/* ── Backdrop + positioning ───────────────────────────────────── */
#parsedContractsReportModal {
    position: fixed;
    inset: 0;
    z-index: 10002;       /* sits above SalaryReport (10001) when both open */
    display: flex;
    align-items: center;
    justify-content: center;
}

.pcr-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

/* ── Modal shell ──────────────────────────────────────────────── */
.pcr-modal {
    position: relative;
    background: var(--jt-bg-deep);
    border: 1px solid var(--jt-border-muted);
    border-radius: 12px;
    width: min(1280px, 96vw);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}

/* ── Header (always dark — matches SalaryReport gradient) ─────── */
.pcr-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    background: linear-gradient(135deg, #1e3a5f 0%, #1a2942 100%);
    border-bottom: 1px solid var(--jt-border-muted);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.pcr-title {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;             /* always white — sits on dark gradient header */
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.pcr-subtitle {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.65);  /* on dark gradient */
    font-weight: 400;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.01em;
}
.pcr-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Badge (e.g. "12 unconfirmed") ────────────────────────────── */
.pcr-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.02em;
}
.pcr-badge-warn {
    background: #fbbf24;
    color: #422006;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.pcr-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.82rem;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.15s, background 0.12s, transform 0.05s;
}
.pcr-btn:hover  { opacity: 0.9; }
.pcr-btn:active { transform: translateY(1px); }
.pcr-btn-icon   { font-size: 1rem; line-height: 1; }

.pcr-btn-primary {
    background: var(--jt-accent-blue);
    color: #fff;
}
.pcr-btn-primary:hover {
    background: var(--jt-accent-blue-hover);
    opacity: 1;
}

/* "on-dark" — for buttons that sit on the gradient header */
.pcr-btn-on-dark {
    background: var(--jt-on-dark-bg);
    color: var(--jt-on-dark-text-bright);
    border-color: var(--jt-on-dark-border);
}
.pcr-btn-on-dark:hover {
    background: var(--jt-on-dark-bg-hover);
    opacity: 1;
}

/* Ghost — for reset etc. (on body surface) */
.pcr-btn-ghost {
    background: transparent;
    color: var(--jt-text-secondary);
    border-color: var(--jt-border-primary);
}
.pcr-btn-ghost:hover {
    border-color: var(--jt-accent-blue);
    color: var(--jt-text-primary);
    opacity: 1;
}

/* Close — sits on the gradient header */
.pcr-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 4px;
    transition: color 0.12s, background 0.12s;
}
.pcr-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

/* ── Filters bar ──────────────────────────────────────────────── */
.pcr-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--jt-bg-primary);
    border-bottom: 1px solid var(--jt-border-muted);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.pcr-filter-input,
.pcr-filter-select {
    background: var(--jt-bg-secondary);
    color: var(--jt-text-primary);
    border: 1px solid var(--jt-border-primary);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 0.82rem;
    font-family: inherit;
}
.pcr-filter-input { min-width: 200px; }
.pcr-filter-input:focus,
.pcr-filter-select:focus {
    outline: none;
    border-color: var(--jt-border-focus);
}

/* ── Loading / empty / error states ───────────────────────────── */
.pcr-loading,
.pcr-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 48px 20px;
    color: var(--jt-text-muted);
    text-align: center;
    font-size: 0.9rem;
}
.pcr-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--jt-border-primary);
    border-top-color: var(--jt-accent-blue);
    border-radius: 50%;
    animation: pcrSpin 0.7s linear infinite;
}
@keyframes pcrSpin { to { transform: rotate(360deg); } }

.pcr-error {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 48px 20px;
    color: var(--jt-accent-red);
    font-size: 0.9rem;
    text-align: center;
}
.pcr-error strong { color: var(--jt-text-primary); font-size: 1rem; }
.pcr-error p { margin: 0; max-width: 500px; color: var(--jt-text-secondary); }

/* ── Table ────────────────────────────────────────────────────── */
.pcr-table-wrapper {
    flex: 1;
    overflow: auto;
}
.pcr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.pcr-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--jt-bg-primary);
}
.pcr-th {
    text-align: left;
    padding: 9px 12px;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--jt-text-secondary);
    border-bottom: 1px solid var(--jt-border-muted);
    white-space: nowrap;
    user-select: none;
}
.pcr-th-sortable { cursor: pointer; }
.pcr-th-sortable:hover { color: var(--jt-text-primary); }
.pcr-th-active   { color: var(--jt-accent-blue); }
.pcr-th-context  { min-width: 280px; }
.pcr-th-actions  { width: 80px; }

.pcr-table tbody tr {
    border-bottom: 1px solid var(--jt-border-muted);
    transition: background 0.1s;
}
.pcr-table tbody tr:hover { background: var(--jt-bg-hover); }
.pcr-table td {
    padding: 7px 12px;
    vertical-align: middle;
    color: var(--jt-text-primary);
}

/* Player cell — stack name + position chip + franchise */
.pcr-td-player {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.pcr-player-name { font-weight: 500; }
.pcr-pos {
    display: inline-block;
    padding: 1px 6px;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 4px;
    color: #fff;
}
/* Use the theme's authoritative position accent palette */
.pcr-pos-QB  { background: var(--jt-pos-qb-accent); }
.pcr-pos-RB  { background: var(--jt-pos-rb-accent); }
.pcr-pos-WR  { background: var(--jt-pos-wr-accent); }
.pcr-pos-TE  { background: var(--jt-pos-te-accent); }
.pcr-pos-K   { background: var(--jt-pos-k-accent); }
.pcr-pos-DEF, .pcr-pos-DST { background: var(--jt-pos-def-accent); }
.pcr-franchise {
    font-size: 0.72rem;
    color: var(--jt-text-muted);
}

/* Kind pills */
.pcr-kind {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 4px;
    text-transform: capitalize;
    letter-spacing: 0.01em;
}
.pcr-kind-deferral     { background: #1e40af; color: #dbeafe; }
.pcr-kind-trade_held   { background: #6d28d9; color: #ede9fe; }
.pcr-kind-advance      { background: #047857; color: #d1fae5; }
.pcr-kind-holdout      { background: #c2410c; color: #ffedd5; }
.pcr-kind-holdout_paid { background: #92400e; color: #fef3c7; }
.pcr-kind-stash        { background: #4b5563; color: #f3f4f6; }
.pcr-kind-ps_steal     { background: #b91c1c; color: #fee2e2; }
.pcr-kind-other        { background: #374151; color: #d1d5db; }

/* Confidence pills */
.pcr-conf {
    display: inline-block;
    padding: 1px 8px;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.pcr-conf-high   { background: #064e3b; color: #6ee7b7; }
.pcr-conf-medium { background: #78350f; color: #fcd34d; }
.pcr-conf-low    { background: #7f1d1d; color: #fca5a5; }
.pcr-conf-manual { background: #1e3a8a; color: #93c5fd; }

/* Numeric / right-aligned columns */
.pcr-td-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: 'Courier New', monospace;
}

/* Source clause cell — truncated; full text in title attribute */
.pcr-td-clause {
    color: var(--jt-text-muted);
    font-size: 0.75rem;
    max-width: 350px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Action buttons (per-row) */
.pcr-td-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}
.pcr-row-btn {
    background: var(--jt-bg-secondary);
    color: var(--jt-text-secondary);
    border: 1px solid var(--jt-border-primary);
    width: 26px;
    height: 26px;
    border-radius: 5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    line-height: 1;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.pcr-row-btn:hover {
    background: var(--jt-accent-blue);
    color: #fff;
    border-color: var(--jt-accent-blue);
}
.pcr-row-btn-danger:hover {
    background: var(--jt-accent-red);
    color: #fff;
    border-color: var(--jt-accent-red);
}

/* Footer */
.pcr-footer {
    flex-shrink: 0;
    padding: 8px 20px;
    border-top: 1px solid var(--jt-border-muted);
    background: var(--jt-bg-primary);
    color: var(--jt-text-muted);
    font-size: 0.78rem;
}

/* PLA-10 v24: date_taken column — monospace tabular nums match the
   year/cap-year numeric columns; muted color so the date doesn't compete
   visually with the more important year column to its left. */
.pcr-td-date {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: 'Courier New', monospace;
    color: var(--jt-text-secondary);
    font-size: 0.78rem;
    white-space: nowrap;
}

/* ─── Collapsible parent/child rows ─────────────────────────────
   Multi-row players collapse under a single parent row by default. Clicking
   the parent expands the children. Single-row players render flat (no
   wrapping, no chevron) — handled by _renderTable rendering them as the
   existing single-row HTML rather than a group.
*/

/* Parent row — clickable, slightly elevated to read as a group header */
.pcr-row-parent {
    cursor: pointer;
    background: var(--jt-bg-secondary);
}
.pcr-row-parent:hover { background: var(--jt-bg-hover); }

/* Chevron rotates when expanded — a touch of motion without being noisy */
.pcr-expand-icon {
    display: inline-block;
    margin-right: 6px;
    font-size: 0.7rem;
    color: var(--jt-text-muted);
    transition: transform 0.15s;
    width: 10px;            /* prevent layout shift when ▶ → ▼ */
}

/* Adjustment count pill — sits to the right of the player + position chips */
.pcr-row-count {
    display: inline-block;
    padding: 1px 7px;
    margin-left: 6px;
    background: var(--jt-bg-deep);
    color: var(--jt-text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 999px;
    white-space: nowrap;
}

/* Child rows — slight indent in the player column to signal hierarchy */
.pcr-row-child > td:first-child { padding-left: 28px; }

/* The "↳" marker shown in the child row's player cell. Muted so it
   doesn't compete with the kind pill and other data in the row. */
.pcr-child-marker {
    color: var(--jt-text-muted);
    font-weight: 400;
}

/* Note: NO [data-theme="light"] block here. The --jt-* tokens defined in
   jt_theme_v4.css automatically flip values when [data-theme="light"] is
   set on <html>. The header gradient and on-dark tokens stay dark in both
   themes by design (matches SalaryReport behavior). */

/* =================================================================
   PRINT — invoked by ReportActions toolbar's Print button
   =================================================================
   Invoked by window.print() from the ReportActions Print button.
   Mirrors the strategy used in salary_report_v4.css:
     - Hide everything outside #parsedContractsReportModal
     - Strip the modal's overlay/backdrop framing
     - Drop the dark gradient header for ink-friendly black-on-white
     - Hide interactive controls (filters, sync buttons, action buttons,
       expand/collapse chevrons, edit/delete row buttons)
     - Flatten the parent/child collapsible groups into a flat table
       (printed output is static — no "click to expand")
     - Repeat the table header on each page

   Users get the layout by clicking Print → "Save as PDF" in the
   browser dialog. No server-side PDF rendering required.
   ================================================================= */
@media print {

    /* ── Bulletproof "print one element" pattern ─────────────────────
       Earlier versions used `body > *:not(...) { display: none }` which
       combined with `position: fixed → static` on the modal was producing
       inconsistent results in Safari — sometimes the modal laid out at
       zero-height before the table rendered, leaving a blank page.

       The visibility-hidden pattern below is the canonical CSS-tricks
       approach: make EVERYTHING invisible, then re-show only the modal
       subtree. visibility keeps elements in layout flow, but nothing
       paints except what we explicitly re-show. */
    html, body {
        background: #fff !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        height: auto !important;
    }
    body * {
        visibility: hidden !important;
    }
    #parsedContractsReportModal,
    #parsedContractsReportModal * {
        visibility: visible !important;
    }

    @page {
        size: letter landscape;
        margin: 0.4in;
    }

    #parsedContractsReportModal {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: auto !important;
        display: block !important;
        background: #fff !important;
        padding: 0 !important;
        margin: 0 !important;
        inset: auto !important;
        z-index: auto !important;
    }
    .pcr-backdrop {
        display: none !important;
    }
    .pcr-modal {
        position: static !important;
        /* CRITICAL: override base display:flex → block. Base .pcr-modal is a
           flex column where .pcr-table-wrapper has flex:1 (fills remaining
           space). In print, max-height is removed and the column has no
           constrained height, so flex:1 children collapse to 0px — the
           table disappears and only the (non-flex) header renders.
           Block layout lets each child take its natural content height. */
        display: block !important;
        width: 100% !important;
        max-width: none !important;
        max-height: none !important;
        height: auto !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        background: #fff !important;
        color: #000 !important;
        overflow: visible !important;
    }

    /* Header — drop the gradient, keep title + subtitle (provider:leagueId · season),
       but hide all interactive controls. Title text becomes black ink. */
    .pcr-header {
        background: none !important;
        color: #000 !important;
        padding: 0 0 8px 0 !important;
        border-bottom: 2px solid #000 !important;
        margin-bottom: 12px !important;
    }
    .pcr-title,
    .pcr-subtitle {
        color: #000 !important;
    }
    .pcr-title {
        font-size: 18pt !important;
    }
    .pcr-subtitle {
        font-size: 10pt !important;
    }
    /* Unconfirmed-count badge — keep visible but flatten the bright yellow */
    .pcr-badge-warn {
        background: #f5f5f5 !important;
        color: #000 !important;
        border: 1px solid #999 !important;
    }

    /* Hide every in-header control + ReportActions toolbar + close button */
    .pcr-actions-mount,
    .pcr-close,
    .ra-toolbar,
    .pcr-btn,
    .pcr-header-right .pcr-btn {
        display: none !important;
    }

    /* Hide the filter bar entirely — its state is captured in the printed
       footer/metadata if needed, and the filters aren't interactive in print */
    .pcr-filters {
        display: none !important;
    }

    /* Footer — show as plain text */
    .pcr-footer {
        background: none !important;
        color: #000 !important;
        border-top: 1px solid #ccc !important;
        margin-top: 8px !important;
        padding: 4px 0 !important;
        font-size: 9pt !important;
    }

    /* Table — full-width, no scroll, light on white */
    .pcr-table-wrapper {
        /* Override flex:1 from the base rule (belt-and-suspenders alongside
           .pcr-modal display:block above). Guarantees the wrapper takes
           natural content height regardless of the modal's display mode. */
        flex: none !important;
        overflow: visible !important;
        max-height: none !important;
    }
    .pcr-table {
        width: 100% !important;
        font-size: 9pt !important;
        color: #000 !important;
        border-collapse: collapse !important;
    }
    .pcr-th,
    .pcr-td {
        background: #fff !important;
        color: #000 !important;
        border: 1px solid #ddd !important;
        padding: 4px 6px !important;
        font-size: 9pt !important;
    }
    .pcr-th {
        background: #eee !important;
        font-weight: 700 !important;
    }
    /* Repeat table header at top of every page */
    .pcr-table thead {
        display: table-header-group;
    }

    /* Position chips — outlined instead of filled (saves toner) */
    .pcr-pos {
        background: #fff !important;
        color: #000 !important;
        border: 1px solid #000 !important;
        padding: 0 4px !important;
    }

    /* Kind pills — flatten the bright colors to bordered grey */
    [class*="pcr-kind-"] {
        background: #f0f0f0 !important;
        color: #000 !important;
        border: 1px solid #999 !important;
        padding: 1px 6px !important;
    }

    /* Confidence pills — same treatment but slightly differentiated by border */
    .pcr-conf-high   { border: 1px solid #16a34a !important; color: #000 !important; background: #f0fdf4 !important; }
    .pcr-conf-medium { border: 1px solid #ca8a04 !important; color: #000 !important; background: #fefce8 !important; }
    .pcr-conf-low    { border: 1px solid #dc2626 !important; color: #000 !important; background: #fef2f2 !important; }
    .pcr-conf-manual { border: 1px solid #2563eb !important; color: #000 !important; background: #eff6ff !important; }

    /* Hide collapsible chevrons + adjustment count pills + edit/delete buttons.
       These are interactive affordances that don't make sense in a static doc. */
    .pcr-expand-icon,
    .pcr-row-count,
    .pcr-td-actions,
    .pcr-row-btn {
        display: none !important;
    }

    /* Flatten collapsed children — make sure all rows print even if the UI
       had them hidden behind a chevron. [hidden] on child rows is the
       collapse mechanism; force them visible for print. */
    .pcr-row-child[hidden] {
        display: table-row !important;
    }
    .pcr-row-child > td:first-child {
        padding-left: 28px !important;  /* keep the indent for visual hierarchy */
    }
    .pcr-row-parent {
        background: #f9f9f9 !important;
        cursor: default !important;
    }

    /* Source clause cell — let it wrap in print so long DSL strings fit
       (the UI ellipsis-truncates them) */
    .pcr-td-clause {
        max-width: none !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
    }

    /* Don't break inside individual rows */
    .pcr-table tbody tr {
        page-break-inside: avoid;
    }

    /* Hide minimize-related artifacts */
    .minimizable-pill,
    .minimize-btn {
        display: none !important;
    }
}
