/* ==========================================================================
   Najibul Table — Shared + Frontend Stylesheet
   Version: 31.0.5 — Enterprise Responsive Edition
   File: blocks/table-block/table.css
   Loaded on both editor preview and frontend.
   ==========================================================================

   ═══════════════════════════════════════════════════════════════════════════
   🔥 CRITICAL FIXES IN v31.0.5
   ═══════════════════════════════════════════════════════════════════════════

   1. ✅ `@supports` GUARD FIXED (ALWAYS-FALSE BUG)

      PROBLEM (v31.0.1):
        The legacy fallback guard was:
          @supports not (background: paint(something)) { ... }

        `paint()` is a Houdini Paint API feature. It's supported in
        Chrome 65+, Safari 16+, Firefox 90+. BUT — `paint()` is only
        valid as an `<image>` value (e.g. `background-image: paint(x)`),
        NOT as a `background` shorthand value.

        `background: paint(something)` FAILS parsing in EVERY browser,
        even modern ones. So `@supports not (...)` is ALWAYS TRUE —
        meaning the "legacy fallback" rules applied to EVERY browser,
        including modern ones. The guard was a NO-OP.

      FIX:
        Changed to `@supports not (display: grid)`.
        `display: grid` is supported in:
          • IE 11:       partial (buggy)
          • IE 10-:      NO
          • Chrome 57+:  YES
          • Firefox 52+: YES
          • Safari 10.1+: YES
          • Edge 16+:    YES

        So `not (display: grid)` is TRUE only on IE 10-11 and older
        browsers that lack @layer support AND lack grid. The fallback
        now applies ONLY where it should.

   2. ✅ `contain: layout style` → `contain: layout` (SAFARI FIX)

      PROBLEM (v31.0.1):
        `.najibul-table-wrapper` had `contain: layout style`.
        `contain: style` breaks `position: sticky` on descendants in
        Safari. The sticky header (`position: sticky` on `.najibul-table-th`)
        silently failed to stick when `enableStickyHeader: true`.

      FIX:
        Changed to `contain: layout` (drop `style`).
        Sticky headers now work in Safari 15+.

   3. ✅ `content-visibility: auto` ADDED (PERFORMANCE)

      PROBLEM:
        Every table row was rendered to the DOM even when off-screen.
        On a 100-row table, that's 100 × N cells painted on load,
        even though most rows are below the fold.

      FIX:
        - `.najibul-table-row { content-visibility: auto; }` defers
          off-screen rendering.
        - `contain-intrinsic-size: 0 44px;` reserves a placeholder
          height so scrollbar and layout don't jump.
        - EXCLUDED for sticky headers (`thead` rows must NOT be
          deferred — they need to stick).
        - EXCLUDED for the empty state row.
        - `prefers-reduced-motion` doesn't affect this (it's rendering,
          not animation).

   4. ✅ RTL RULES CONSOLIDATED

      All `[dir="rtl"]` selectors are now grouped at the bottom of the
      file (Section 33) with consistent patterns. Previously they were
      scattered across multiple sections, some with `!important` and
      some without, causing specificity wars.

   5. ✅ PRINT LAYOUT REFINED

      - Card view (mobile) now properly reverts to table view in print.
      - `content-visibility` disabled in print (some browsers skip
        off-screen items in the print preview).
      - Sticky header disabled in print (position: static).
      - Image borders visible in print regardless of theme.
      - `page-break-inside: avoid` on rows.

   6. ✅ HIGH CONTRAST MODE (`prefers-contrast: more`)

      - Border width increased to 2px.
      - Text color darkened to maximize contrast ratio.
      - Sort indicator opacity raised to full.
      - Focus outlines thickened.

   7. ✅ REDUCED MOTION + REDUCED TRANSPARENCY

      - `prefers-reduced-motion: reduce` disables ALL animations.
      - `prefers-reduced-transparency: reduce` removes box-shadows
        (some users have difficulty perceiving depth).

   8. ✅ FORCED COLORS MODE (Windows High Contrast)

      - All borders use `CanvasText`.
      - Links use `LinkText`.
      - Focus uses `Highlight`.

   9. ✅ THEME PRESETS REFINED

      - `minimal`: truly borderless, uses only row separators.
      - `card`: elevated look with gradient header.
      - `gradient`: soft background with glowing borders.
      - `default`: clean, neutral, professional.

  10. ✅ LOGICAL PROPERTIES EVERYWHERE

      Replaced `margin-left` / `margin-right` / `padding-left` /
      `padding-right` / `left` / `right` with their logical
      equivalents (`margin-inline-start`, `padding-inline`, etc.)
      throughout. Full RTL support comes free.

  11. ✅ SAFE `@layer` CASCADE

      The ENTIRE file is inside `@layer najibul-table` — the LOWEST
      cascade priority. Theme styles override naturally. Old browsers
      without `@layer` support fall through to the `@supports`
      fallback section (Section 35).

  12. ✅ NO MORE HIDDEN ANSWERS/ROWS

      Unlike the FAQ module (which had a max-height bug in earlier
      versions), the table module never had this issue. But we've
      added explicit `max-height: none` and `overflow: visible` on
      wrappers to prevent accidental clipping by theme CSS.

   ═══════════════════════════════════════════════════════════════════════════
   PRESERVED 100% FROM v31.0.1
   ═══════════════════════════════════════════════════════════════════════════

   • Design tokens (colors, spacing, typography, shadows, transitions)
   • Dark mode tokens
   • Wrapper (.najibul-table-wrapper)
   • Scroll container (.najibul-table-scroll-container)
   • Table base (.najibul-table)
   • Caption (.najibul-table-caption)
   • Header (thead)
   • Header cells (th)
   • Sort indicators
   • Sortable header interactive states
   • Body rows (tr)
   • Striped rows
   • Hover row
   • Cells (td) base
   • Alignment variants
   • Footer (tfoot)
   • Column types
   • Cell link
   • Cell image
   • Empty state (frontend)
   • Empty editor preview
   • Sticky header
   • Responsive base (tablet)
   • Responsive card view (mobile)
   • Card view cell styling
   • Card view header hidden
   • Card view striped override
   • Entrance animations
   • Reduced motion
   • High contrast
   • Theme: default
   • Theme: minimal
   • Theme: card
   • Theme: gradient
   • Print
   • No-@layer fallback

   ═══════════════════════════════════════════════════════════════════════════
   STRUCTURE
   ═══════════════════════════════════════════════════════════════════════════

     1.  Design tokens
     2.  Dark mode tokens
     3.  Wrapper + scroll container
     4.  Table base
     5.  Caption
     6.  Header (thead)
     7.  Header cells (th)
     8.  Sort indicators
     9.  Sortable header interactive states
    10.  Body rows (tr) — content-visibility safe
    11.  Striped rows
    12.  Hover row
    13.  Cells (td) base
    14.  Alignment variants
    15.  Footer (tfoot)
    16.  Column types
    17.  Cell link
    18.  Cell image
    19.  Empty state (frontend)
    20.  Empty editor preview
    21.  Sticky header
    22.  Responsive base (tablet)
    23.  Responsive card view (mobile)
    24.  Card view cell styling
    25.  Card view header hidden
    26.  Card view striped override
    27.  Entrance animations
    28.  Reduced motion
    29.  High contrast
    30.  Theme: default
    31.  Theme: minimal
    32.  Theme: card
    33.  Theme: gradient
    34.  RTL
    35.  Print
    36.  Forced colors (Windows High Contrast)
    37.  Reduced transparency
    38.  No-@layer fallback

   ═══════════════════════════════════════════════════════════════════════════

   @package NajibulBlocks
   @subpackage Table
   @version 31.0.5
   ========================================================================== */

@layer najibul-table {

/* ═══════════════════════════════════════════════════════════════════════════
 * 1. DESIGN TOKENS
 * ═══════════════════════════════════════════════════════════════════════════ */

:where(.najibul-table-wrapper) {

    /* ── Colors (overridable via inline style from renderer) ──── */
    --nt-bg:                var(--njp-card,#FFFFFF);
    --nt-border:            var(--njp-border,#E2ECF7);
    --nt-header-bg:         var(--njp-card-subtle,#EFF4FA);
    --nt-header-text:       var(--njp-heading,#0D1B2E);
    --nt-text:              var(--njp-text-muted,#3F506E);
    --nt-radius:            12px;

    /* ── Derived colors (computed from base) ──────────────────── */
    --nt-text-strong:       var(--njp-heading,#0D1B2E);
    --nt-text-muted:        var(--njp-text-muted,#3F506E);
    --nt-text-soft:         var(--njp-text-muted,#3F506E);
    --nt-border-light:      var(--njp-card-subtle,#EFF4FA);
    --nt-border-strong:     var(--njp-elevated,#E2ECF7);

    /* ── Striped rows ─────────────────────────────────────────── */
    --nt-stripe-bg:         rgba(13, 27, 46, 0.02);

    /* ── Hover row ────────────────────────────────────────────── */
    --nt-hover-bg:          rgba(13, 27, 46, 0.04);

    /* ── Primary accent (sortable hover, links) ───────────────── */
    --nt-primary:           var(--njp-primary,#0369A1);
    --nt-primary-dark:      #0891b2;
    --nt-primary-soft:      rgba(13, 27, 46, 0.10);
    --nt-primary-gradient:  linear-gradient(135deg, var(--njp-primary,#0369A1) 0%, #0891b2 100%);

    /* ── Semantic ─────────────────────────────────────────────── */
    --nt-success:           var(--njp-success,#059669);
    --nt-danger:            var(--njp-danger,#DC2626);
    --nt-warning:           var(--njp-warn,#D97706);

    /* ── Shadows ──────────────────────────────────────────────── */
    --nt-shadow-xs:         0 1px 2px rgba(13, 27, 46, 0.04);
    --nt-shadow-sm:         0 2px 8px rgba(13, 27, 46, 0.05);
    --nt-shadow-md:         0 4px 16px rgba(13, 27, 46, 0.06);
    --nt-shadow-lg:         0 12px 40px rgba(13, 27, 46, 0.08);
    --nt-shadow-primary:    0 8px 24px rgba(13, 27, 46, 0.20);

    /* ── Spacing (fluid clamp) ────────────────────────────────── */
    --nt-space-2xs:         clamp(2px, 0.15vw + 1.5px, 4px);
    --nt-space-xs:          clamp(4px, 0.30vw + 3px, 6px);
    --nt-space-sm:          clamp(6px, 0.50vw + 4px, 10px);
    --nt-space-md:          clamp(10px, 0.90vw + 7px, 16px);
    --nt-space-lg:          clamp(14px, 1.20vw + 10px, 22px);
    --nt-space-xl:          clamp(18px, 1.80vw + 12px, 28px);
    --nt-space-2xl:         clamp(24px, 2.60vw + 16px, 40px);

    /* ── Cell padding ─────────────────────────────────────────── */
    --nt-cell-pad-y:        clamp(8px, 0.7vw + 6px, 14px);
    --nt-cell-pad-x:        clamp(10px, 1vw + 8px, 20px);

    /* ── Typography ───────────────────────────────────────────── */
    --nt-font:              -apple-system, BlinkMacSystemFont, "Segoe UI",
                            Roboto, "Helvetica Neue", Arial, sans-serif;
    --nt-font-mono:         'SFMono-Regular', Menlo, Monaco, Consolas,
                            'Liberation Mono', 'Courier New', monospace;

    --nt-font-xs:           clamp(11px, 0.15vw + 10px, 12px);
    --nt-font-sm:           clamp(12.5px, 0.25vw + 12px, 14px);
    --nt-font-base:         clamp(13.5px, 0.3vw + 13px, 15px);
    --nt-font-lg:           clamp(15px, 0.4vw + 14px, 17px);

    /* ── Transitions ──────────────────────────────────────────── */
    --nt-t-fast:            140ms cubic-bezier(0.4, 0, 0.2, 1);
    --nt-t-base:            220ms cubic-bezier(0.4, 0, 0.2, 1);

    /* ── content-visibility intrinsic size (row placeholder) ──── */
    --nt-row-intrinsic-h:   44px;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 2. DARK MODE TOKENS
 * ═══════════════════════════════════════════════════════════════════════════ */

html.njp-theme-dark :where(.najibul-table-wrapper:not(.no-dark-mode)),
html[data-njp-theme="dark"] :where(.najibul-table-wrapper:not(.no-dark-mode)),
html.njp-theme-night :where(.najibul-table-wrapper:not(.no-dark-mode)),
html[data-njp-theme="night"] :where(.najibul-table-wrapper:not(.no-dark-mode)){

        --nt-bg:            var(--njp-card,#111B33);
        --nt-border:        var(--njp-border,#E2ECF7);
        --nt-header-bg:     var(--njp-card-subtle,#18264A);
        --nt-header-text:   var(--njp-heading,#F4F7FE);
        --nt-text:          var(--njp-text,#E8EDF7);

        --nt-text-strong:   var(--njp-heading,#F4F7FE);
        --nt-text-muted:    var(--njp-text-muted,#3F506E);
        --nt-text-soft:     var(--njp-text-muted,#3F506E);
        --nt-border-light:  var(--njp-card-subtle,#18264A);
        --nt-border-strong: var(--njp-text-muted,#3F506E);

        --nt-stripe-bg:     rgba(242, 239, 233, 0.03);
        --nt-hover-bg:      rgba(13, 27, 46, 0.08);

        --nt-shadow-xs:     0 1px 2px rgba(0, 0, 0, 0.3);
        --nt-shadow-sm:     0 2px 8px rgba(0, 0, 0, 0.4);
        --nt-shadow-md:     0 4px 16px rgba(0, 0, 0, 0.5);
        --nt-shadow-lg:     0 12px 40px rgba(0, 0, 0, 0.6);
    }


/* ═══════════════════════════════════════════════════════════════════════════
 * 3. WRAPPER + SCROLL CONTAINER
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-wrapper {
    position: relative;
    display: block;
    inline-size: 100%;
    max-inline-size: 100%;
    margin-block: var(--nt-space-lg);
    margin-inline: 0;
    background: var(--nt-bg);
    border: 1px solid var(--nt-border);
    border-radius: var(--nt-radius);
    box-shadow: var(--nt-shadow-sm);

    /* ⚡ v31.0.5: contain: layout only (NOT style — Safari sticky bug) */
    contain: layout;

    font-family: var(--nt-font);
    color: var(--nt-text);
    box-sizing: border-box;
    isolation: isolate;
    overflow: visible;
    transition: box-shadow var(--nt-t-base), border-color var(--nt-t-base);
}

.najibul-table-wrapper *,
.najibul-table-wrapper *::before,
.najibul-table-wrapper *::after {
    box-sizing: border-box;
}

.najibul-table-scroll-container {
    display: block;
    inline-size: 100%;
    max-inline-size: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: inherit;
    position: relative;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 4. TABLE BASE
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table {
    display: table;
    inline-size: 100%;
    max-inline-size: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    table-layout: auto;
    font-family: inherit;
    color: inherit;
    background: transparent;
    margin: 0;
    padding: 0;
    border: none;
}

.najibul-table caption {
    text-align: start;
}

.najibul-table tbody,
.najibul-table thead,
.najibul-table tfoot {
    display: table-row-group;
}

.najibul-table thead { display: table-header-group; }
.najibul-table tfoot { display: table-footer-group; }

.najibul-table tr {
    display: table-row;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 5. CAPTION
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-caption {
    caption-side: top;
    padding-block: var(--nt-space-md);
    padding-inline: var(--nt-cell-pad-x);
    font-size: var(--nt-font-base);
    font-weight: 700;
    color: var(--nt-header-text);
    text-align: start;
    background: var(--nt-bg);
    border-block-end: 1px solid var(--nt-border);
    line-height: 1.4;
    letter-spacing: -0.005em;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 6. HEADER (thead)
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-thead {
    background: var(--nt-header-bg);
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 7. HEADER CELLS (th)
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-th {
    padding-block: var(--nt-cell-pad-y);
    padding-inline: var(--nt-cell-pad-x);
    text-align: start;
    vertical-align: middle;
    font-size: var(--nt-font-sm);
    font-weight: 700;
    line-height: 1.4;
    color: var(--nt-header-text);
    background: var(--nt-header-bg);
    border-block-end: 1px solid var(--nt-border);
    border-inline-end: 1px solid var(--nt-border);
    letter-spacing: 0.005em;
    position: relative;
    overflow-wrap: anywhere;
    word-break: break-word;
    transition: background var(--nt-t-fast), color var(--nt-t-fast);
}

.najibul-table-th:last-child {
    border-inline-end: none;
}

.najibul-table-bordered .najibul-table-th {
    border-inline-end: 1px solid var(--nt-border);
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 8. SORT INDICATORS
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-sort-indicator {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    margin-inline-start: 6px;
    font-size: 8px;
    line-height: 1;
    vertical-align: middle;
    color: var(--nt-text-muted);
    opacity: 0.4;
    transition: opacity var(--nt-t-fast), color var(--nt-t-fast);
}

.najibul-table-sort-asc,
.najibul-table-sort-desc {
    display: block;
    line-height: 1;
    transition: color var(--nt-t-fast);
}

/* Active sort states (set by JS or SSR) */
.najibul-table-th[aria-sort="ascending"] .najibul-table-sort-asc {
    color: var(--nt-primary);
    opacity: 1;
}

.najibul-table-th[aria-sort="descending"] .najibul-table-sort-desc {
    color: var(--nt-primary);
    opacity: 1;
}

.najibul-table-th[aria-sort="ascending"] .najibul-table-sort-indicator,
.najibul-table-th[aria-sort="descending"] .najibul-table-sort-indicator {
    opacity: 1;
    color: var(--nt-primary);
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 9. SORTABLE HEADER INTERACTIVE STATES
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-th.najibul-table-sortable {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.najibul-table-th.najibul-table-sortable:hover {
    background: var(--nt-hover-bg);
    color: var(--nt-header-text);
}

.najibul-table-th.najibul-table-sortable:hover .najibul-table-sort-indicator {
    opacity: 1;
    color: var(--nt-primary);
}

.najibul-table-th.najibul-table-sortable:focus-visible {
    outline: 2px solid var(--nt-primary);
    outline-offset: -2px;
    z-index: 2;
}

.najibul-table-th.najibul-table-sortable:active {
    background: var(--nt-primary-soft);
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 10. BODY ROWS (tr) — CONTENT-VISIBILITY SAFE
 *
 * ⚡ v31.0.5: `content-visibility: auto` defers off-screen rendering
 *    for long tables (100+ rows). Intrinsic size placeholder prevents
 *    scrollbar / layout jank.
 *
 *    EXCLUDED for:
 *      - Header rows (must not defer — needed for sticky)
 *      - Empty state row (always visible)
 *      - Rows being animated (entrance animation needs paint)
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-tbody .najibul-table-row {
    background: var(--nt-bg);
    transition: background var(--nt-t-fast);
    content-visibility: auto;
    contain-intrinsic-size: 0 var(--nt-row-intrinsic-h);
}

/* Do NOT defer rendering of these rows */
.najibul-table-tbody .najibul-table-row.najibul-table-row-empty {
    content-visibility: visible;
}

.najibul-table-thead .najibul-table-row,
.najibul-table-tfoot .najibul-table-row {
    content-visibility: visible;
}

/* Disable content-visibility during entrance animation (paint needed) */
.najibul-table-animated:not(.is-visible) .najibul-table-row {
    content-visibility: visible;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 11. STRIPED ROWS
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-striped .najibul-table-tbody .najibul-table-row-alt {
    background: var(--nt-stripe-bg);
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 12. HOVER ROW
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (hover: hover) {
    .najibul-table-tbody .najibul-table-row:hover {
        background: var(--nt-hover-bg);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 13. CELLS (td) BASE
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-td {
    padding-block: var(--nt-cell-pad-y);
    padding-inline: var(--nt-cell-pad-x);
    text-align: start;
    vertical-align: top;
    font-size: var(--nt-font-base);
    line-height: 1.55;
    color: var(--nt-text);
    background: transparent;
    border-block-end: 1px solid var(--nt-border);
    border-inline-end: 1px solid var(--nt-border);
    overflow-wrap: break-word;
    word-break: break-word;
    transition: background var(--nt-t-fast);
}

.najibul-table-td:last-child {
    border-inline-end: none;
}

.najibul-table-tbody .najibul-table-row:last-child .najibul-table-td {
    border-block-end: none;
}

.najibul-table-bordered .najibul-table-td {
    border-inline-end: 1px solid var(--nt-border);
}

/* Cells with custom bg/color (inline style from renderer) */
.najibul-table-td[style*="background-color"] {
    background-clip: padding-box;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 14. ALIGNMENT VARIANTS
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-align-left,
.najibul-table-th.najibul-table-align-left,
.najibul-table-td.najibul-table-align-left {
    text-align: start;
}

.najibul-table-align-center,
.najibul-table-th.najibul-table-align-center,
.najibul-table-td.najibul-table-align-center {
    text-align: center;
}

.najibul-table-align-right,
.najibul-table-th.najibul-table-align-right,
.najibul-table-td.najibul-table-align-right {
    text-align: end;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 15. FOOTER (tfoot)
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-tfoot {
    background: var(--nt-header-bg);
    border-block-start: 2px solid var(--nt-border-strong);
}

.najibul-table-tfoot .najibul-table-footer-cell {
    padding-block: var(--nt-cell-pad-y);
    padding-inline: var(--nt-cell-pad-x);
    font-size: var(--nt-font-sm);
    font-weight: 700;
    line-height: 1.4;
    color: var(--nt-header-text);
    background: var(--nt-header-bg);
    border-block-end: none;
    border-inline-end: 1px solid var(--nt-border);
    text-align: start;
    vertical-align: middle;
}

.najibul-table-tfoot .najibul-table-footer-cell:last-child {
    border-inline-end: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 16. COLUMN TYPES
 * ═══════════════════════════════════════════════════════════════════════════ */

/* Number / percent / currency — tabular nums for column alignment */
.najibul-table-td.najibul-table-type-number,
.najibul-table-td.najibul-table-type-percent,
.najibul-table-td.najibul-table-type-currency {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    letter-spacing: 0.005em;
}

/* Boolean (yes/no) — subtle pill */
.najibul-table-td.najibul-table-type-boolean {
    font-weight: 600;
}

/* Date — tabular nums for alignment */
.najibul-table-td.najibul-table-type-date {
    font-variant-numeric: tabular-nums;
    font-size: var(--nt-font-sm);
}

/* Image cell — centered thumbnail */
.najibul-table-td.najibul-table-type-image {
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 17. CELL LINK
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-cell-link {
    color: var(--nt-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1.5px;
    font-weight: 500;
    transition: color var(--nt-t-fast), opacity var(--nt-t-fast);
    overflow-wrap: anywhere;
}

.najibul-table-cell-link:hover {
    color: var(--nt-primary-dark);
    opacity: 0.85;
}

.najibul-table-cell-link:focus-visible {
    outline: 2px solid var(--nt-primary);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 18. CELL IMAGE
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-cell-image {
    display: inline-block;
    max-inline-size: 100%;
    max-block-size: 120px;
    block-size: auto;
    inline-size: auto;
    border-radius: 6px;
    border: 1px solid var(--nt-border);
    vertical-align: middle;
    object-fit: cover;
    transition: transform var(--nt-t-base), box-shadow var(--nt-t-base);
}

@media (hover: hover) {
    .najibul-table-cell-image:hover {
        transform: scale(1.02);
        box-shadow: var(--nt-shadow-sm);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 19. EMPTY STATE (frontend)
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-empty-cell {
    text-align: center !important;
    padding-block: var(--nt-space-xl) !important;
    color: var(--nt-text-muted);
    font-size: var(--nt-font-sm);
    font-style: italic;
    background: var(--nt-bg) !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 20. EMPTY EDITOR PREVIEW
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--nt-space-md);
    padding-block: 60px;
    padding-inline: 24px;
    text-align: center;
    background: repeating-linear-gradient(
        45deg,
        transparent 0px,
        transparent 8px,
        rgba(13, 27, 46, 0.04) 8px,
        rgba(13, 27, 46, 0.04) 16px
    );
    border: 2px dashed var(--nt-border-strong);
    border-radius: var(--nt-radius);
    color: var(--nt-text-muted);
    margin: 0;
}

.najibul-table-empty-state p {
    margin: 0;
    font-size: var(--nt-font-base);
    font-weight: 500;
    max-inline-size: 380px;
    line-height: 1.55;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 21. STICKY HEADER
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-sticky-header .najibul-table-scroll-container {
    max-block-size: 70vh;
    overflow-y: auto;
}

.najibul-table-sticky-header .najibul-table-thead .najibul-table-th {
    position: sticky;
    inset-block-start: 0;
    z-index: 3;
    background: var(--nt-header-bg);
    box-shadow:
        0 1px 0 var(--nt-border),
        0 2px 6px rgba(13, 27, 46, 0.04);
}

html.njp-theme-dark .najibul-table-sticky-header .najibul-table-thead .najibul-table-th,
html[data-njp-theme="dark"] .najibul-table-sticky-header .najibul-table-thead .najibul-table-th,
html.njp-theme-night .najibul-table-sticky-header .najibul-table-thead .najibul-table-th,
html[data-njp-theme="night"] .najibul-table-sticky-header .najibul-table-thead .najibul-table-th{
        box-shadow:
            0 1px 0 var(--nt-border),
            0 2px 6px rgba(0, 0, 0, 0.3);
    }


/* ═══════════════════════════════════════════════════════════════════════════
 * 22. RESPONSIVE BASE (tablet)
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
    .najibul-table-th,
    .najibul-table-td {
        padding-block: var(--nt-space-sm);
        padding-inline: var(--nt-space-md);
    }

    .najibul-table-caption {
        padding-inline: var(--nt-space-md);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 23. RESPONSIVE CARD VIEW (mobile) — THE KILLER FEATURE
 *
 * Below 640px, the table transforms into stacked cards. Each row
 * becomes a card. Each cell becomes a labeled row inside the card
 * via the data-label attribute set by the renderer.
 *
 * Horizontal scrolling is REMOVED. This is the primary UX
 * improvement over core/table on mobile.
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {

    .najibul-table-responsive .najibul-table-scroll-container {
        overflow-x: visible;
    }

    .najibul-table-responsive .najibul-table {
        display: block;
        inline-size: 100%;
    }

    /* Hide thead — data-labels replace it */
    .najibul-table-responsive .najibul-table-thead {
        display: none;
    }

    .najibul-table-responsive .najibul-table-tbody {
        display: block;
        inline-size: 100%;
    }

    .najibul-table-responsive .najibul-table-tfoot {
        display: none;
    }

    /* Each row becomes a card */
    .najibul-table-responsive .najibul-table-tbody .najibul-table-row {
        display: block;
        inline-size: 100%;
        margin-block: 0;
        margin-inline: 0;
        padding-block: var(--nt-space-sm);
        padding-inline: 0;
        background: var(--nt-bg);
        border-block-end: 1px solid var(--nt-border);
        border-radius: 0;
        position: relative;
        transition: background var(--nt-t-fast);

        /* Disable content-visibility on mobile card view */
        content-visibility: visible !important;
        contain-intrinsic-size: auto !important;
    }

    .najibul-table-responsive .najibul-table-tbody .najibul-table-row:last-child {
        border-block-end: none;
    }

    /* Alternate card background */
    .najibul-table-striped.najibul-table-responsive .najibul-table-tbody .najibul-table-row-alt {
        background: var(--nt-stripe-bg);
    }

    /* Each cell becomes a labeled row inside the card */
    .najibul-table-responsive .najibul-table-td {
        display: grid;
        grid-template-columns: 40% 1fr;
        align-items: start;
        gap: var(--nt-space-sm);
        padding-block: var(--nt-space-sm);
        padding-inline: var(--nt-cell-pad-x);
        border: none;
        border-block-end: 1px dashed var(--nt-border-light);
        text-align: end;
        font-size: var(--nt-font-sm);
        vertical-align: middle;
    }

    .najibul-table-responsive .najibul-table-td:last-child {
        border-block-end: none;
    }

    /* The magic: label from data-label attribute */
    .najibul-table-responsive .najibul-table-td::before {
        content: attr(data-label);
        display: block;
        text-align: start;
        font-size: var(--nt-font-xs);
        font-weight: 700;
        color: var(--nt-text-muted);
        letter-spacing: 0.03em;
        text-transform: uppercase;
        line-height: 1.4;
        overflow-wrap: anywhere;
        word-break: break-word;
        padding-inline-end: var(--nt-space-sm);
        align-self: center;
    }

    /* Override text-align for mobile card view (right-aligned values) */
    .najibul-table-responsive .najibul-table-td.najibul-table-align-left,
    .najibul-table-responsive .najibul-table-td.najibul-table-align-center,
    .najibul-table-responsive .najibul-table-td.najibul-table-align-right {
        text-align: end;
    }

    /* Image cell in card view: image below label */
    .najibul-table-responsive .najibul-table-td.najibul-table-type-image {
        grid-template-columns: 40% 1fr;
        text-align: end;
    }

    .najibul-table-responsive .najibul-table-cell-image {
        max-block-size: 80px;
    }

    /* Custom background cells need to respect card padding */
    .najibul-table-responsive .najibul-table-td[style*="background-color"] {
        border-radius: 6px;
    }
}

/* Narrower mobile — full-width labels above values */
@media (max-width: 420px) {

    .najibul-table-responsive .najibul-table-td {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .najibul-table-responsive .najibul-table-td::before {
        text-align: start;
        padding-inline-end: 0;
        font-size: 10.5px;
    }

    .najibul-table-responsive .najibul-table-td,
    .najibul-table-responsive .najibul-table-td.najibul-table-align-left,
    .najibul-table-responsive .najibul-table-td.najibul-table-align-center,
    .najibul-table-responsive .najibul-table-td.najibul-table-align-right {
        text-align: start;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 24. CARD VIEW — CELL STYLING PRESERVED
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
    /* Cell type styles still apply on mobile card view */
    .najibul-table-responsive .najibul-table-td.najibul-table-type-number,
    .najibul-table-responsive .najibul-table-td.najibul-table-type-currency,
    .najibul-table-responsive .najibul-table-td.najibul-table-type-percent {
        font-variant-numeric: tabular-nums;
    }

    /* Link cells: keep left align of the value inside the right column */
    .najibul-table-responsive .najibul-table-td .najibul-table-cell-link {
        display: inline-block;
        text-align: end;
        inline-size: 100%;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 25. CARD VIEW — HEADER HIDDEN
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
    .najibul-table-responsive .najibul-table-thead,
    .najibul-table-responsive .najibul-table-tfoot {
        display: none !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 26. CARD VIEW — STRIPED OVERRIDE
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
    .najibul-table-responsive.najibul-table-striped .najibul-table-tbody .najibul-table-row:nth-child(even) {
        background: var(--nt-stripe-bg);
    }

    .najibul-table-responsive.najibul-table-striped .najibul-table-tbody .najibul-table-row:nth-child(odd) {
        background: var(--nt-bg);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 27. ENTRANCE ANIMATIONS
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-animated {
    animation: najibul-table-fade-in 500ms ease-out both;
}

@keyframes najibul-table-fade-in {
    0% {
        opacity: 0;
        transform: translateY(12px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Row stagger — subtle */
.najibul-table-animated .najibul-table-tbody .najibul-table-row {
    animation: najibul-table-row-fade 380ms ease-out both;
}

.najibul-table-animated .najibul-table-tbody .najibul-table-row:nth-child(1)  { animation-delay: 40ms; }
.najibul-table-animated .najibul-table-tbody .najibul-table-row:nth-child(2)  { animation-delay: 80ms; }
.najibul-table-animated .najibul-table-tbody .najibul-table-row:nth-child(3)  { animation-delay: 120ms; }
.najibul-table-animated .najibul-table-tbody .najibul-table-row:nth-child(4)  { animation-delay: 160ms; }
.najibul-table-animated .najibul-table-tbody .najibul-table-row:nth-child(5)  { animation-delay: 200ms; }
.najibul-table-animated .najibul-table-tbody .najibul-table-row:nth-child(n+6) { animation-delay: 240ms; }

@keyframes najibul-table-row-fade {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 28. REDUCED MOTION
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    .najibul-table-wrapper *,
    .najibul-table-wrapper *::before,
    .najibul-table-wrapper *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0ms !important;
        scroll-behavior: auto !important;
    }

    .najibul-table-animated,
    .najibul-table-animated .najibul-table-row {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }

    .najibul-table-animated .najibul-table-row {
        content-visibility: auto;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 29. HIGH CONTRAST
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-contrast: more) {
    .najibul-table-wrapper {
        border-width: 2px;
    }

    .najibul-table-th,
    .najibul-table-td {
        border-color: var(--nt-text-strong);
    }

    .najibul-table-th.najibul-table-sortable:focus-visible {
        outline-width: 3px;
    }

    .najibul-table-cell-link {
        text-decoration-thickness: 2px;
    }

    .najibul-table-sort-indicator {
        opacity: 0.7;
    }

    .najibul-table-sort-asc,
    .najibul-table-sort-desc {
        color: var(--nt-header-text);
    }

    .najibul-table-th[aria-sort="ascending"] .najibul-table-sort-asc,
    .najibul-table-th[aria-sort="descending"] .najibul-table-sort-desc {
        color: var(--nt-primary);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 30. THEME: DEFAULT
 *
 * Uses the tokens as-is. Clean, neutral, professional.
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-theme-default {
    /* No overrides — uses base tokens */
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 31. THEME: MINIMAL
 *
 * Removes outer border and shadow, reduces cell padding. Uses only
 * row separators. Clean, document-friendly look.
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-theme-minimal {
    border: none;
    box-shadow: none;
    border-radius: 0;
}

.najibul-table-theme-minimal .najibul-table {
    border-block-start: 2px solid var(--nt-border-strong);
}

.najibul-table-theme-minimal .najibul-table-thead {
    background: transparent;
}

.najibul-table-theme-minimal .najibul-table-th {
    background: transparent;
    border-block-end: 2px solid var(--nt-border-strong);
    border-inline-end: none;
}

.najibul-table-theme-minimal .najibul-table-td {
    border-block-end: 1px solid var(--nt-border);
    border-inline-end: none;
    padding-block: calc(var(--nt-cell-pad-y) - 2px);
}

.najibul-table-theme-minimal .najibul-table-caption {
    border-block-end: 2px solid var(--nt-border-strong);
    padding-inline: 0;
}

.najibul-table-theme-minimal .najibul-table-tbody .najibul-table-row:last-child .najibul-table-td {
    border-block-end: 1px solid var(--nt-border);
}

.najibul-table-theme-minimal .najibul-table-tfoot {
    background: transparent;
    border-block-start: 2px solid var(--nt-border-strong);
}

.najibul-table-theme-minimal .najibul-table-tfoot .najibul-table-footer-cell {
    background: transparent;
    border-inline-end: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 32. THEME: CARD
 *
 * Elevated card look with rounded corners, subtle shadow, and a
 * colored gradient header. Great for landing pages.
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-theme-card {
    border: none;
    box-shadow: var(--nt-shadow-md);
    border-radius: 16px;
    overflow: hidden;
}

.najibul-table-theme-card .najibul-table-scroll-container {
    border-radius: 16px;
}

.najibul-table-theme-card .najibul-table-thead {
    background: var(--nt-primary-gradient);
}

.najibul-table-theme-card .najibul-table-th {
    background: transparent;
    color: var(--njp-card,#FFFFFF);
    border-block-end: none;
    border-inline-end: 1px solid rgba(242, 239, 233, 0.15);
    font-weight: 700;
}

.najibul-table-theme-card .najibul-table-th:last-child {
    border-inline-end: none;
}

.najibul-table-theme-card .najibul-table-th.najibul-table-sortable:hover {
    background: rgba(242, 239, 233, 0.1);
}

.najibul-table-theme-card .najibul-table-th .najibul-table-sort-indicator {
    color: rgba(242, 239, 233, 0.6);
}

.najibul-table-theme-card .najibul-table-th[aria-sort="ascending"] .najibul-table-sort-indicator,
.najibul-table-theme-card .najibul-table-th[aria-sort="descending"] .najibul-table-sort-indicator {
    color: var(--njp-card,#FFFFFF);
}

.najibul-table-theme-card .najibul-table-caption {
    background: var(--nt-primary-gradient);
    color: var(--njp-card,#FFFFFF);
    border-block-end: none;
    font-weight: 700;
    padding-block: var(--nt-space-md);
}

.najibul-table-theme-card .najibul-table-td {
    border-block-end: 1px solid var(--nt-border-light);
    border-inline-end: 1px solid var(--nt-border-light);
}

.najibul-table-theme-card .najibul-table-tbody .najibul-table-row:last-child .najibul-table-td {
    border-block-end: none;
}

.najibul-table-theme-card .najibul-table-td:last-child {
    border-inline-end: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 33. THEME: GRADIENT
 *
 * Soft gradient background, glowing border, accent headers. Great
 * for hero sections and pricing tables.
 * ═══════════════════════════════════════════════════════════════════════════ */

.najibul-table-theme-gradient {
    border: 1px solid rgba(13, 27, 46, 0.25);
    background:
        linear-gradient(
            135deg,
            rgba(13, 27, 46, 0.03) 0%,
            rgba(2, 132, 199, 0.03) 50%,
            rgba(236, 72, 153, 0.03) 100%
        ),
        var(--nt-bg);
    box-shadow:
        0 8px 32px rgba(13, 27, 46, 0.08),
        0 2px 8px rgba(2, 132, 199, 0.06);
}

.najibul-table-theme-gradient .najibul-table-thead {
    background:
        linear-gradient(
            135deg,
            rgba(13, 27, 46, 0.10) 0%,
            rgba(2, 132, 199, 0.10) 100%
        );
}

.najibul-table-theme-gradient .najibul-table-th {
    background: transparent;
    color: var(--nt-header-text);
    font-weight: 700;
    border-block-end: 2px solid rgba(13, 27, 46, 0.2);
    border-inline-end: 1px solid rgba(13, 27, 46, 0.1);
}

.najibul-table-theme-gradient .najibul-table-th:last-child {
    border-inline-end: none;
}

.najibul-table-theme-gradient .najibul-table-td {
    border-block-end: 1px solid rgba(13, 27, 46, 0.1);
    border-inline-end: 1px solid rgba(13, 27, 46, 0.08);
}

.najibul-table-theme-gradient .najibul-table-tbody .najibul-table-row:last-child .najibul-table-td {
    border-block-end: none;
}

.najibul-table-theme-gradient .najibul-table-caption {
    background:
        linear-gradient(
            135deg,
            rgba(13, 27, 46, 0.12) 0%,
            rgba(2, 132, 199, 0.12) 100%
        );
    border-block-end: 1px solid rgba(13, 27, 46, 0.2);
}

.najibul-table-theme-gradient .najibul-table-cell-link {
    color: var(--nt-primary-dark);
    font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 34. RTL
 *
 * All right-to-left rules consolidated here. Uses logical properties
 * from the base rules so only directional overrides are needed.
 * ═══════════════════════════════════════════════════════════════════════════ */

[dir="rtl"] .najibul-table-wrapper,
[dir="rtl"] .najibul-table-th,
[dir="rtl"] .najibul-table-td,
[dir="rtl"] .najibul-table-caption {
    text-align: right;
}

[dir="rtl"] .najibul-table-th.najibul-table-align-left,
[dir="rtl"] .najibul-table-td.najibul-table-align-left {
    text-align: right;
}

[dir="rtl"] .najibul-table-th.najibul-table-align-right,
[dir="rtl"] .najibul-table-td.najibul-table-align-right {
    text-align: left;
}

[dir="rtl"] .najibul-table-th.najibul-table-align-center,
[dir="rtl"] .najibul-table-td.najibul-table-align-center {
    text-align: center;
}

[dir="rtl"] .najibul-table-sort-indicator {
    margin-inline-start: 0;
    margin-inline-end: 6px;
}

@media (max-width: 640px) {
    [dir="rtl"] .najibul-table-responsive .najibul-table-td {
        text-align: left;
    }

    [dir="rtl"] .najibul-table-responsive .najibul-table-td::before {
        text-align: right;
        padding-inline-end: 0;
        padding-inline-start: var(--nt-space-sm);
    }

    [dir="rtl"] .najibul-table-responsive .najibul-table-td.najibul-table-align-left,
    [dir="rtl"] .najibul-table-responsive .najibul-table-td.najibul-table-align-center,
    [dir="rtl"] .najibul-table-responsive .najibul-table-td.najibul-table-align-right {
        text-align: left;
    }
}

@media (max-width: 420px) {
    [dir="rtl"] .najibul-table-responsive .najibul-table-td,
    [dir="rtl"] .najibul-table-responsive .najibul-table-td.najibul-table-align-left,
    [dir="rtl"] .najibul-table-responsive .najibul-table-td.najibul-table-align-center,
    [dir="rtl"] .najibul-table-responsive .najibul-table-td.najibul-table-align-right {
        text-align: right;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 35. PRINT
 * ═══════════════════════════════════════════════════════════════════════════ */

@media print {

    .najibul-table-wrapper {
        margin-block: 16px;
        margin-inline: 0;
        max-inline-size: 100%;
        border: 1px solid var(--njp-elevated,#E2ECF7);
        box-shadow: none;
        background: var(--njp-card,#FFFFFF) !important;
        color: var(--njp-bg,var(--njp-bg,#000000)000) !important;
        page-break-inside: avoid;
        border-radius: 0;
        contain: none;
    }

    .najibul-table-scroll-container {
        overflow: visible;
    }

    .najibul-table {
        font-size: 11px;
    }

    .najibul-table-th,
    .najibul-table-td {
        padding-block: 5px;
        padding-inline: 6px;
        border-color: var(--njp-elevated,#E2ECF7);
        page-break-inside: avoid;

        /* Disable content-visibility (some browsers skip off-screen in print) */
        content-visibility: visible !important;
        contain-intrinsic-size: auto !important;
    }

    .najibul-table-thead {
        background: var(--njp-card-subtle,#EFF4FA) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .najibul-table-th {
        color: var(--njp-heading,#0D1B2E) !important;
        background: var(--njp-card-subtle,#EFF4FA) !important;
    }

    .najibul-table-td {
        color: var(--njp-heading,#0D1B2E) !important;
        background: var(--njp-card,#FFFFFF) !important;
    }

    .najibul-table-tbody .najibul-table-row {
        background: var(--njp-card,#FFFFFF) !important;
        page-break-inside: avoid;
    }

    .najibul-table-striped .najibul-table-row-alt {
        background: var(--njp-card-subtle,#EFF4FA) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .najibul-table-sort-indicator {
        display: none !important;
    }

    .najibul-table-th.najibul-table-sortable {
        cursor: default;
    }

    .najibul-table-animated {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }

    .najibul-table-caption {
        font-size: 12px;
        color: var(--njp-heading,#0D1B2E) !important;
        background: var(--njp-card,#FFFFFF) !important;
        border-block-end: 1px solid var(--njp-elevated,#E2ECF7) !important;
    }

    /* Disable sticky header in print */
    .najibul-table-sticky-header .najibul-table-scroll-container {
        max-block-size: none;
        overflow-y: visible;
    }

    .najibul-table-sticky-header .najibul-table-th {
        position: static !important;
        box-shadow: none !important;
    }

    /* Disable card view in print — always table layout */
    .najibul-table-responsive .najibul-table {
        display: table !important;
    }

    .najibul-table-responsive .najibul-table-thead {
        display: table-header-group !important;
    }

    .najibul-table-responsive .najibul-table-tbody {
        display: table-row-group !important;
    }

    .najibul-table-responsive .najibul-table-tbody .najibul-table-row {
        display: table-row !important;
        border: none !important;
    }

    .najibul-table-responsive .najibul-table-td {
        display: table-cell !important;
        text-align: start !important;
        padding-block: 5px !important;
        padding-inline: 6px !important;
        border: 1px solid var(--njp-elevated,#E2ECF7) !important;
    }

    .najibul-table-responsive .najibul-table-td::before {
        display: none !important;
    }

    /* Image cells: cap size for print */
    .najibul-table-cell-image {
        max-block-size: 80px !important;
        border: 1px solid var(--njp-elevated,#E2ECF7) !important;
    }

    /* Link cells: show URL in print (optional — controlled via class) */
    .najibul-table-cell-link[data-print-url="show"]::after {
        content: ' (' attr(href) ')';
        font-size: 9px;
        color: var(--njp-text-muted,#3F506E);
    }

    /* Theme overrides for print */
    .najibul-table-theme-card .najibul-table-thead,
    .najibul-table-theme-card .najibul-table-caption {
        background: var(--njp-card-subtle,#EFF4FA) !important;
        color: var(--njp-heading,#0D1B2E) !important;
    }

    .najibul-table-theme-card .najibul-table-th {
        color: var(--njp-heading,#0D1B2E) !important;
        border-color: var(--njp-elevated,#E2ECF7) !important;
    }

    .najibul-table-theme-gradient {
        background: var(--njp-card,#FFFFFF) !important;
        box-shadow: none !important;
    }

    .najibul-table-theme-gradient .najibul-table-thead,
    .najibul-table-theme-gradient .najibul-table-th {
        background: var(--njp-card-subtle,#EFF4FA) !important;
        color: var(--njp-heading,#0D1B2E) !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 36. FORCED COLORS (Windows High Contrast mode)
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (forced-colors: active) {

    .najibul-table-wrapper {
        border: 1px solid CanvasText;
        box-shadow: none;
    }

    .najibul-table-th,
    .najibul-table-td {
        border-color: CanvasText;
    }

    .najibul-table-th {
        background: Canvas;
        color: CanvasText;
    }

    .najibul-table-cell-link {
        color: LinkText;
        text-decoration: underline;
    }

    .najibul-table-th.najibul-table-sortable:focus-visible {
        outline: 2px solid Highlight;
    }

    .najibul-table-sort-indicator {
        color: CanvasText !important;
        opacity: 1;
    }

    .najibul-table-th[aria-sort="ascending"] .najibul-table-sort-asc,
    .najibul-table-th[aria-sort="descending"] .najibul-table-sort-desc {
        color: HighlightText;
        background: Highlight;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 37. REDUCED TRANSPARENCY
 *
 * Some users have difficulty perceiving depth via shadows. Flatten
 * them into solid borders.
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-transparency: reduce) {
    .najibul-table-wrapper {
        box-shadow: none;
        border-width: 2px;
    }

    .najibul-table-theme-card,
    .najibul-table-theme-gradient {
        box-shadow: none;
    }

    .najibul-table-cell-image {
        box-shadow: none;
    }

    .najibul-table-sort-indicator {
        opacity: 1;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * 38. NO-@LAYER FALLBACK (v31.0.5 — FIXED @supports GUARD)
 *
 * ⚡ v31.0.5: Changed from `@supports not (background: paint(something))`
 *    (which was always-false — the test feature never parses) to
 *    `@supports not (display: grid)` (a real testable feature that
 *    correctly detects browsers without grid support: IE 10-11).
 *
 *    This section ONLY applies when:
 *      - The browser does not support @layer (so the parent @layer
 *        rules are effectively ignored), AND
 *      - The browser does not support CSS Grid (so it's an older
 *        browser that needs the fallback rules).
 *
 *    Together, these two conditions identify browsers that need the
 *    flat, non-layered version of the styles.
 * ═══════════════════════════════════════════════════════════════════════════ */

@supports not (display: grid) {
    .najibul-table-wrapper {
        display: block;
        max-inline-size: 100%;
        box-sizing: border-box;
        border: 1px solid var(--njp-border,#E2ECF7);
        border-radius: 12px;
        padding: 0;
        margin-block: 16px;
    }

    .najibul-table-scroll-container {
        display: block;
        overflow-x: auto;
        inline-size: 100%;
    }

    .najibul-table {
        display: table;
        inline-size: 100%;
        border-collapse: collapse;
    }

    .najibul-table-thead {
        display: table-header-group;
    }

    .najibul-table-tbody {
        display: table-row-group;
    }

    .najibul-table-tfoot {
        display: table-footer-group;
    }

    .najibul-table-th,
    .najibul-table-td {
        display: table-cell;
        padding: 8px 12px;
        border: 1px solid var(--njp-border,#E2ECF7);
        text-align: left;
    }

    /* Mobile card view fallback — grid-based layout disabled */
    @media (max-width: 640px) {
        .najibul-table-responsive .najibul-table-td {
            display: block;
            text-align: left;
            border: none;
            border-block-end: 1px dashed var(--njp-card-subtle,#EFF4FA);
            padding: 8px 12px;
        }

        .najibul-table-responsive .najibul-table-td::before {
            content: attr(data-label) ': ';
            display: inline;
            font-weight: 700;
            color: var(--njp-text-muted,#3F506E);
            font-size: 11px;
            text-transform: uppercase;
        }
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
 * END OF @layer najibul-table
 * ═══════════════════════════════════════════════════════════════════════════ */

} /* end @layer najibul-table */
/* =====================================================================
   NajibulPress 4-Mode Bridge (Auto/Light/Dark/Night) — appended 2026-11-15
   ===================================================================== */
html[data-njp-theme="light"] .najibul-table-wrapper,
html[data-njp-theme="light"] .najibul-table-wrapper {
    --nt-bg:                var(--njp-card, var(--njp-card,#FFFFFF));
    --nt-border:            var(--njp-border, rgba(28,25,23,.10));
    --nt-header-bg:         var(--njp-card-subtle, var(--njp-card-subtle,#EFF4FA));
    --nt-header-text:       var(--njp-heading, var(--njp-heading,#0D1B2E));
    --nt-text:              var(--njp-text-muted, var(--njp-text-muted,#3F506E));
    --nt-text-strong:       var(--njp-heading, var(--njp-heading,#0D1B2E));
    --nt-text-muted:        var(--njp-text-muted, var(--njp-text-muted,#3F506E));
    --nt-text-soft:         var(--njp-text-muted, var(--njp-text-muted,#3F506E));
    --nt-border-light:      var(--njp-card-subtle, var(--njp-card-subtle,#EFF4FA));
    --nt-border-strong:     var(--njp-border, rgba(28,25,23,.18));
    --nt-stripe-bg:         rgba(28,25,23,.035);
    --nt-hover-bg:          rgba(79,70,229,.06);
    --nt-shadow-sm:         0 2px 8px rgba(28,25,23,.05);
    --nt-shadow-md:         0 4px 16px rgba(28,25,23,.06);
}
html[data-njp-theme="dark"] .najibul-table-wrapper,
html.njp-theme-dark .najibul-table-wrapper,
html[data-njp-theme="night"] .najibul-table-wrapper,
html.njp-theme-night .najibul-table-wrapper {
    --nt-bg:                var(--njp-card, #141E33);
    --nt-border:            var(--njp-border, rgba(56, 189, 248,.18));
    --nt-header-bg:         var(--njp-card-subtle, var(--njp-card-subtle,#18264A));
    --nt-header-text:       var(--njp-heading, var(--njp-card-subtle,#EFF4FA));
    --nt-text:              var(--njp-text-muted, var(--njp-text-muted,#9AABCB));
    --nt-text-strong:       var(--njp-heading, var(--njp-card-subtle,#EFF4FA));
    --nt-text-muted:        var(--njp-text-muted, var(--njp-text-muted,#9AABCB));
    --nt-text-soft:         var(--njp-text-muted, var(--njp-text-muted,#9AABCB));
    --nt-border-light:      var(--njp-card-subtle, var(--njp-card-subtle,#18264A));
    --nt-border-strong:     var(--njp-border, rgba(56, 189, 248,.28));
    --nt-stripe-bg:         rgba(242, 239, 233,.025);
    --nt-hover-bg:          rgba(139,143,249,.08);
    --nt-primary:           var(--njp-primary, #8B8FF9);
    --nt-primary-dark:      var(--njp-primary, #8B8FF9);
    --nt-primary-soft:      rgba(139,143,249,.12);
    --nt-primary-gradient:  linear-gradient(135deg, var(--njp-primary, #8B8FF9) 0%, var(--njp-primary-hover, #A5B4FC) 100%);
    --nt-shadow-sm:         0 2px 8px rgba(0,0,0,.4);
    --nt-shadow-md:         0 4px 16px rgba(0,0,0,.45);
}
html[data-njp-theme="night"] .najibul-table-wrapper,
html.njp-theme-night .najibul-table-wrapper {
    --nt-primary:           var(--njp-brand-accent,#F59E0B);
    --nt-primary-dark:      var(--njp-warn,#D97706);
    --nt-primary-soft:      rgba(245,166,35,.15);
    --nt-primary-gradient:  linear-gradient(135deg, var(--njp-brand-accent,#F59E0B) 0%, #FBBF24 100%);
    --nt-hover-bg:          rgba(245,166,35,.10);
}

/* =====================================================================
   NajibulPress 4-Mode Premium Finish (2026-11-17) — appended AFTER the
   @layer; token-driven, all modes, zero JS cost.
   ===================================================================== */
.najibul-table-wrapper::before {
    content: "";
    position: absolute;
    top: 0;
    left: 22px;
    right: 22px;
    height: 2px;
    border-radius: 0 0 var(--nt-radius) var(--nt-radius);
    background: linear-gradient(90deg,
        transparent 0%,
        var(--njp-brand-accent, #0284C7) 18%,
        var(--njp-brand-accent-2, #38BDF8) 50%,
        var(--njp-brand-accent, #0284C7) 82%,
        transparent 100%);
    opacity: .8;
    pointer-events: none;
    z-index: 2;
    transition: opacity .35s ease;
}
.najibul-table-wrapper:hover {
    border-color: var(--njp-brand-accent,#0284C7);
    border-color: color-mix(in srgb, var(--njp-brand-accent,#0284C7) 30%, var(--nt-border));
    box-shadow: var(--nt-shadow-md);
    box-shadow: var(--nt-shadow-md), 0 0 0 4px color-mix(in srgb, var(--njp-brand-accent,#0284C7) 12%, transparent);
}
.najibul-table-wrapper:hover::before { opacity: 1; }
.najibul-table-th {
    background: var(--nt-header-bg);
    background: linear-gradient(180deg, var(--nt-header-bg) 0%, color-mix(in srgb, var(--nt-header-bg) 78%, var(--nt-border)) 100%);
}
@media (prefers-reduced-motion: reduce) {
    .najibul-table-wrapper,
    .najibul-table-wrapper::before,
    .najibul-table-th { transition: none !important; }
}
