/**
 * All of the CSS for your public-facing functionality should be
 * included in this file.
 */
/* table-layout: fixed lets DataTables <col> widths control column sizing for scrollX alignment */
.dt-scroll-head table.jgct_dataTable,
.dt-scroll-body table.jgct_dataTable {
    table-layout: fixed;
}

.jgct_datatable_wrapper {
    position: relative;
    margin: 0 auto;
    padding-bottom: 20px;
}

.jgct_datatable_scrollable {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Let DataTables manage table width for scrollX layout */
table.dataTable {
    width: auto;
}

table.dataTable th,
table.dataTable td {
    white-space: normal;
    /* Allow text wrapping */
    word-wrap: break-word;
    /* Wrap long words */
    overflow: hidden;
    text-overflow: ellipsis;
    /* Optional: Truncate text with ellipsis if too long */
    max-width: 200px;
    /* Set a reasonable max width for each cell */
    border-right: 1px solid #ccc;
    font-size: 0.8em;
}

.jgct_datatable_scrollable table.jgct_dataTable th, .jgct_datatable_scrollable table.jgct_dataTable th.dt-type-numeric {text-align: center;}
.jgct_datatable_scrollable .dt-scroll-body {cursor: grab; user-select: none;}
.jgct_datatable_scrollable .dt-scroll-body:active {cursor: grabbing;}
.jgct_datatable_scrollable table.dataTable>tbody>tr {background-color: #f9f9f9;}

/* Sticky first column */
.content-area .site-main .jgct_datatable_scrollable table.jgct_dataTable th:first-child,
.content-area .site-main .jgct_datatable_scrollable table.jgct_dataTable td:first-child {
    position: sticky;
    left: 0;
    border-right: 1px solid #ccc;
    z-index: 2;
    /*width: 55%; /* Increased width for the first column */
    /* Ensure readability with a larger minimum width */
    text-align: center;
    background-color: #fff;
    padding: 0;
}

/* Replace dataTables CSS */
.jgct_datatable_wrapper table.dataTable.nowrap th,
.jgct_datatable_wrapper table.dataTable.nowrap td {
    white-space: unset;
    line-height: 20px;
    text-align: center;
}

.jgct_datatable_wrapper table.dataTable.nowrap th .button,
.jgct_datatable_wrapper table.dataTable.nowrap td .button {
    background-color: unset !important;
    color: var(--button_colour) !important;
    font-size: 16px !important;
}

.jgct_dataTable tbody tr td a {
    display: block;
    width: 100%;
    height: 100%;
    padding: 8px 0;
}

.jgct_datatable_wrapper table.dataTable.nowrap th a:hover,
.jgct_datatable_wrapper table.dataTable.nowrap td a:hover {
    box-shadow: unset !important;
}

table.dataTable thead th:first-child,
table.dataTable tbody td:first-child {
    padding: 8px 5px;
}

.jgct_datatable_wrapper table.dataTable.nowrap th img,
.jgct_datatable_wrapper table.dataTable.nowrap td img {
    height: auto;
    max-width: 100%;
    transform: unset;
}

/* Let DataTables manage scroll-head inner width via inline style */
.dt-scroll-headInner {
    width: auto !important;
}

@media (max-width: 768px) {
    /* Sticky first column */
    .content-area .site-main .jgct_datatable_scrollable table.jgct_dataTable th:first-child,
    .content-area .site-main .jgct_datatable_scrollable table.jgct_dataTable td:first-child {
        min-width: 30vw;
    }
}

/* Sticky Table Header */
.jgct_sticky_header_enabled .dt-scroll-head.jgct-sticky-active,
.jgct_sticky_header_enabled .dataTables_scrollHead.jgct-sticky-active {
    position: fixed !important;
    z-index: 100;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.jgct_sticky_header_enabled .dt-scroll-head.jgct-sticky-active table thead th,
.jgct_sticky_header_enabled .dataTables_scrollHead.jgct-sticky-active table thead th {
    background-color: #fff;
}

/* Placeholder to prevent content jump when header becomes fixed */
.jgct-sticky-placeholder {
    display: none;
}

.jgct-sticky-placeholder.jgct-sticky-active {
    display: block;
}

.dt-paging  button {
    background-color: unset !important;
    color: var(--button_colour) !important;
    font-size: 16px !important;
}

/* Product badges (Sale / New / Low stock) shown after the product name */
.jgct_dataTable .jgct_badges {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

.jgct_dataTable .jgct_badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    line-height: 1.6;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    white-space: nowrap;
    color: #fff;
    background-color: #6b7280;
}

.jgct_dataTable .jgct_badge_sale {
    background-color: #c0392b;
}

.jgct_dataTable .jgct_badge_new {
    background-color: #1776a6;
}

.jgct_dataTable .jgct_badge_low_stock {
    background-color: #b8860b;
}

/* Sale dropdown: button in a category's price cell, cards in a child row (since 1.21.0) */
.jgct_dataTable tbody tr td .jgct_sale_toggle {
    box-sizing: border-box;
    height: auto;
    min-height: 0;
    font-family: inherit;
    letter-spacing: normal;
    text-shadow: none;
    box-shadow: none;
    white-space: nowrap;
    display: flex;
    width: fit-content;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 8px auto 0;
    padding: 3px 9px;
    border: 0;
    border-radius: 13px;
    background: #c0392b;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 17px;
    text-transform: uppercase;
    cursor: pointer;
}

.jgct_dataTable tbody tr td .jgct_sale_toggle:hover,
.jgct_dataTable tbody tr td .jgct_sale_toggle:focus-visible,
.jgct_dataTable tbody tr td .jgct_sale_toggle[aria-expanded="true"] {
    background: #9f2f25;
    color: #fff;
}

.jgct_dataTable .jgct_sale_arrow {
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
}

.jgct_dataTable .jgct_sale_toggle[aria-expanded="true"] .jgct_sale_arrow {
    transform: translateY(2px) rotate(225deg);
}

.jgct_dataTable tr.jgct_sale_cards_row > td {
    padding: 12px;
    background: #f2f2f2;
    text-align: left;
    white-space: normal;
}

.jgct_dataTable .jgct_sale_cards {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.jgct_dataTable .jgct_sale_cards[data-count="1"] { grid-template-columns: minmax(0, 1fr); }
.jgct_dataTable .jgct_sale_cards[data-count="2"],
.jgct_dataTable .jgct_sale_cards[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/*
 * position: relative makes each card the containing block for any "stretched link" rule
 * (a::after { position: absolute; inset: 0 }) a theme or custom CSS applies to table links,
 * so a card's links cover that card only and not the whole child row.
 */
.jgct_dataTable .jgct_sale_card {
    position: relative;
    display: grid;
    grid-template-columns: 160px 1fr;
    min-width: 0;
    background: #fff;
    border: 1px solid #969696;
    text-align: center;
}

/* A lone card sits against the table's own rules, so only its sides are drawn. */
.jgct_dataTable .jgct_sale_cards[data-count="1"] .jgct_sale_card {
    border-top: 0;
    border-bottom: 0;
}

.jgct_dataTable .jgct_sale_card_head {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    border-right: 1px solid #ccc;
}

.jgct_dataTable .jgct_sale_card_name {
    font-size: 15px;
    font-weight: 700;
}

/* The generic table-cell link rule (block, 100% height, 8px padding) would stretch the card links. */
.jgct_dataTable tbody tr td .jgct_sale_card a {
    display: inline-block;
    width: auto;
    height: auto;
    padding: 0;
}

.jgct_dataTable tbody tr td .jgct_sale_card a.jgct_sale_card_image {
    display: block;
    line-height: 0;
}

.jgct_datatable_wrapper table.dataTable.nowrap td .jgct_sale_card_image img {
    display: block;
    width: auto;
    max-width: 90px;
    height: auto;
    max-height: 56px;
    margin: auto;
    object-fit: contain;
}

/* One grid for every row (specs, stock, price) so any spare card height is shared out evenly. */
.jgct_dataTable .jgct_sale_card_body {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 1fr;
    min-width: 0;
    background: #fff;
}

.jgct_dataTable .jgct_sale_card_specs,
.jgct_dataTable .jgct_sale_card_footer {
    display: contents;
}

.jgct_dataTable .jgct_sale_card_footer .jgct_sale_spec {
    grid-column: 1 / -1;
}

.jgct_dataTable .jgct_sale_card_footer .jgct_sale_spec:first-child {
    border-top: 1px solid #ccc;
}

.jgct_dataTable .jgct_sale_spec {
    display: grid;
    grid-template-columns: minmax(80px, 42%) 1fr;
    min-height: 44px;
    border-right: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
}

.jgct_dataTable .jgct_sale_spec:nth-child(even),
.jgct_dataTable .jgct_sale_card_footer .jgct_sale_spec {
    border-right: 0;
}

.jgct_dataTable .jgct_sale_card_footer .jgct_sale_spec:last-child {
    border-bottom: 0;
}

.jgct_dataTable .jgct_sale_spec_empty {
    background: #f1f1f1;
}

.jgct_dataTable .jgct_sale_spec_label,
.jgct_dataTable .jgct_sale_spec_value {
    display: flex;
    align-items: center;
    padding: 7px 9px;
    line-height: 17px;
}

.jgct_dataTable .jgct_sale_spec_label {
    background: #f2f2f2;
    color: #444;
    font-size: 12.5px;
    font-weight: 600;
    text-align: left;
}

.jgct_dataTable .jgct_sale_spec_value {
    justify-content: center;
    font-size: 13.5px;
    overflow-wrap: anywhere;
}

.jgct_dataTable .jgct_sale_spec_value del {
    color: #2d3387;
    white-space: nowrap;
}

.jgct_dataTable .jgct_sale_spec_value strong {
    margin-left: 6px;
    color: #f00;
    font-size: 15px;
    white-space: nowrap;
}

.jgct_dataTable .jgct_sale_pill {
    display: inline-block;
    margin-left: 7px;
    padding: 1px 7px;
    border-radius: 10px;
    background: #c0392b;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    white-space: nowrap;
}

@media (max-width: 760px) {
    .jgct_dataTable tr.jgct_sale_cards_row > td {
        padding: 8px;
    }

    .jgct_dataTable .jgct_sale_cards,
    .jgct_dataTable .jgct_sale_cards[data-count] {
        position: sticky;
        left: 0;
        grid-template-columns: 1fr;
        width: 100%;
        max-width: calc(100vw - 40px);
        gap: 10px;
    }

    /* Stack each card: image + name + badges across the top, specs underneath. */
    .jgct_dataTable .jgct_sale_card { grid-template-columns: 1fr; width: 100%; }

    .jgct_dataTable .jgct_sale_card_head {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 6px 10px;
        padding: 8px 10px;
        border-right: 0;
        border-bottom: 1px solid #ccc;
        text-align: left;
    }

    .jgct_dataTable .jgct_sale_card_head .jgct_sale_card_image { order: -1; }
    .jgct_dataTable .jgct_sale_card_head .jgct_sale_card_name { flex: 1 1 0; min-width: 0; }

    .jgct_dataTable .jgct_sale_card_body { grid-template-columns: 1fr; }
    .jgct_dataTable .jgct_sale_spec { grid-template-columns: minmax(90px, 40%) 1fr; min-height: 36px; }
    .jgct_dataTable .jgct_sale_spec,
    .jgct_dataTable .jgct_sale_spec:nth-child(even) { border-right: 0; }
    .jgct_dataTable .jgct_sale_spec_empty { display: none; }

    /* Price: let the old price, new price and pill wrap instead of overflowing. */
    .jgct_dataTable .jgct_sale_spec_value { flex-wrap: wrap; gap: 2px 4px; }
    .jgct_dataTable .jgct_sale_spec_value strong,
    .jgct_dataTable .jgct_sale_pill { margin-left: 0; }

    .jgct_dataTable tbody tr td .jgct_sale_toggle { padding: 3px 8px; font-size: 10px; }
}

@media (max-width: 768px) {
    .jgct_dataTable .jgct_badges {
        margin-left: 4px;
    }

    .jgct_dataTable .jgct_badge {
        font-size: 10px;
        padding: 1px 6px;
    }
}

/* Product page comparison table (since 1.20.0). */
.jgct_product_compare {
    clear: both;
    margin: 2em 0;
}

.jgct_product_compare .jgct_product_compare_title {
    margin-bottom: 0.6em;
}

/* Inset box-shadow, as DataTables paints its striping and sorted-column tints the same way.
   The extra ancestor selector outranks DataTables' odd-row sorted-column rule. */
.jgct_product_compare table.dataTable.jgct_dataTable > tbody > tr.jgct_current_product > td {
    box-shadow: inset 0 0 0 9999px var(--jgct-compare-highlight, #fff8d6);
    font-weight: 700;
}

.jgct_product_compare table.dataTable.jgct_dataTable > tbody > tr.jgct_current_product > td:first-child {
    border-left: 4px solid #d4a017;
}

/* Sale price in the Price column: regular price on one line, sale price on the next. */
.jgct_dataTable td .jgct_price_was,
.jgct_dataTable td .jgct_price_now {
    display: block;
    white-space: nowrap;
}

.jgct_dataTable td .jgct_price_now {
    margin-top: 6px;
    font-weight: 600;
}

/*
 * Cells holding a sale price get room above and below. A theme may turn table links into
 * inline-flex (which puts the two prices side by side), so the link around them is forced
 * into a centred column.
 */
.jgct_dataTable td.col-price:has(.jgct_price_was) {
    padding: 12px 8px;
}

.jgct_dataTable td.col-price a:has(> .jgct_price_was) {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    width: 100%;
}
