/**
 * PTT - Posts to Table
 * Frontend Styles
 *
 * Brand colors from brand-design.md:
 * - Brand Blue: #0066FF
 * - Charcoal: #1A1A1A
 * - Light Gray: #F5F5F5
 */

:root {
    /* Primary Colors */
    --ptt-brand-blue: #0066FF;
    --ptt-brand-blue-hover: #0052CC;
    --ptt-brand-blue-active: #0047B3;
    --ptt-charcoal: #1A1A1A;
    --ptt-light-gray: #F5F5F5;
    --ptt-white: #FFFFFF;
    --ptt-border: #E0E0E0;

    /* Accent Colors */
    --ptt-success: #00C853;
    --ptt-warning: #FF6B00;
    --ptt-error: #E53935;

    /* Text Colors */
    --ptt-text-primary: #1A1A1A;
    --ptt-text-secondary: #666666;
    --ptt-text-tertiary: #999999;
    --ptt-text-disabled: #CCCCCC;

    /* Spacing */
    --ptt-space-xs: 4px;
    --ptt-space-sm: 8px;
    --ptt-space-md: 16px;
    --ptt-space-lg: 24px;
    --ptt-space-xl: 32px;

    /* Border Radius */
    --ptt-radius-sm: 4px;
    --ptt-radius-md: 8px;
    --ptt-radius-lg: 12px;

    /* Font */
    --ptt-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* =========================================
   Container
   ========================================= */
.ptt-container {
    width: 100%;
    margin: var(--ptt-space-lg) 0;
    font-family: var(--ptt-font-family);
    background: #f1f3f5;
    /* Premium grey background */
    padding: 24px;
    border-radius: 16px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 100% !important;
}

@media screen and (max-width: 767px) {
    .ptt-container {
        padding: 12px !important;
        margin: var(--ptt-space-md) 0 !important;
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
        touch-action: pan-y !important;
        /* Force vertical scroll Only */
        overflow: hidden !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        display: flex !important;
        flex-direction: column !important;
        position: relative !important;
    }
}

/* Ensure inner elements don't cause horizontal scroll on the container itself */
.ptt-container:not(.ptt-fullscreen) {
    overflow: hidden !important;
    max-width: 100% !important;
}

.ptt-container:not(.ptt-fullscreen) .ptt-toolbar-container,
.ptt-container:not(.ptt-fullscreen) .ptt-table-wrapper,
.ptt-container:not(.ptt-fullscreen) .dataTables_wrapper {
    width: 100% !important;
    max-width: 100% !important;
}

/* Table Wrapper - The actual card container */
.ptt-table-wrapper {
    background: var(--ptt-white);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    overflow-x: auto;
    /* Internal horizontal scroll */
    width: 100%;
    margin-bottom: var(--ptt-space-md);
}

.ptt-container.ptt-fullscreen .ptt-table-wrapper {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    margin-bottom: 0;
}

/* =========================================
   Table Styles
   ========================================= */
.ptt-table {
    width: 100% !important;
    border-collapse: collapse !important;
    background: transparent !important;
    border: none !important;
    overflow: visible;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: none !important;
    margin: 0 !important;
    vertical-align: top !important;
    /* Force top alignment */
}

/* Table Header */
.ptt-table thead {
    background: var(--ptt-light-gray);
}

.ptt-table thead th {
    padding: var(--ptt-space-md);
    text-align: left;
    font-weight: 600;
    color: var(--ptt-charcoal);
    border-bottom: 2px solid var(--ptt-border);
    white-space: nowrap;
}

.ptt-table thead th:first-child {
    border-top-left-radius: var(--ptt-radius-md);
}

.ptt-table thead th:last-child {
    border-top-right-radius: var(--ptt-radius-md);
}

/* Sortable Headers */
.ptt-table thead th.sorting,
.ptt-table thead th.sorting_asc,
.ptt-table thead th.sorting_desc {
    cursor: pointer;
    position: relative;
    padding-right: 30px;
    transition: background-color 0.2s ease;
}

.ptt-table thead th.sorting:hover,
.ptt-table thead th.sorting_asc:hover,
.ptt-table thead th.sorting_desc:hover {
    background: #EAEAEA;
}

.ptt-table thead th.sorting_asc,
.ptt-table thead th.sorting_desc {
    color: var(--ptt-brand-blue);
}

/* Table Body */
.ptt-table tbody tr {
    transition: background-color 0.15s ease;
}

.ptt-table tbody tr:nth-child(even) {
    background: var(--ptt-light-gray);
}

.ptt-table tbody tr:hover {
    background: #E8F4FF;
}

.ptt-table tbody td {
    padding: var(--ptt-space-md);
    border-bottom: 1px solid var(--ptt-border);
    color: var(--ptt-text-primary);
    vertical-align: top !important;
}

.ptt-table tbody tr:last-child td {
    border-bottom: none;
}

/* =========================================
   Column-Specific Styles
   ========================================= */
.ptt-col-id {
    width: 60px;
    text-align: center;
    color: var(--ptt-text-tertiary);
    font-family: monospace;
}

.ptt-col-image {
    width: 80px;
    text-align: center;
}

.ptt-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--ptt-radius-sm);
    border: 1px solid var(--ptt-border);
}

/* Image Size Overrides */
.ptt-table.ptt-img-size-medium .ptt-col-image {
    width: 150px !important;
    min-width: 150px !important;
}

.ptt-table.ptt-img-size-medium .ptt-thumbnail {
    width: 150px !important;
    height: auto !important;
    object-fit: contain !important;
}

.ptt-table.ptt-img-size-large .ptt-col-image {
    width: 300px !important;
    min-width: 300px !important;
}

.ptt-table.ptt-img-size-large .ptt-thumbnail {
    width: 300px !important;
    height: auto !important;
    object-fit: contain !important;
}

.ptt-table.ptt-img-size-full .ptt-col-image {
    width: auto !important;
    min-width: 250px !important;
}

.ptt-table.ptt-img-size-full .ptt-thumbnail {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain !important;
}

.ptt-no-image {
    display: inline-block;
    width: 60px;
    height: 60px;
    line-height: 60px;
    text-align: center;
    background: var(--ptt-light-gray);
    border-radius: var(--ptt-radius-sm);
    color: var(--ptt-text-disabled);
    font-size: 10px;
}

.ptt-col-title {
    font-weight: 500;
    max-width: 200px;
    width: 200px;
    overflow-wrap: break-word;
    white-space: normal !important;
}

.ptt-title-link {
    color: var(--ptt-charcoal);
    text-decoration: none;
    transition: color 0.2s ease;
    white-space: normal !important;
    display: inline-block;
    max-width: 100%;
}

.ptt-title-link:hover {
    color: var(--ptt-brand-blue);
    text-decoration: underline;
}

.ptt-col-content {
    max-width: 300px;
    color: var(--ptt-text-secondary);
}

.ptt-col-date {
    white-space: nowrap;
    color: var(--ptt-text-secondary);
}

.ptt-col-author {
    white-space: nowrap;
}

/* Categories, Tags, Author Links */
.ptt-category-link,
.ptt-tag-link,
.ptt-author-link {
    color: var(--ptt-brand-blue);
    text-decoration: none;
    transition: color 0.2s ease;
}

.ptt-category-link:hover,
.ptt-tag-link:hover,
.ptt-author-link:hover {
    text-decoration: underline;
}

.ptt-category,
.ptt-tag,
.ptt-author {
    color: var(--ptt-text-primary);
}

.ptt-no-category,
.ptt-no-tags {
    color: var(--ptt-text-disabled);
}

.ptt-col-categories,
.ptt-col-tags {
    min-width: 100px;
    line-height: 1.6;
}

.ptt-category,
.ptt-tag,
.ptt-category-link,
.ptt-tag-link {
    display: inline-block;
    vertical-align: top;
}

/* =========================================
   DataTables Overrides
   ========================================= */

/* =========================================
   Toolbar & DataTables Controls
   ========================================= */

/* Main Toolbar Container */
.ptt-toolbar-container {
    background: var(--ptt-white);
    border: none !important;
    /* Premium: no border */
    border-radius: 12px;
    margin-bottom: var(--ptt-space-sm);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    overflow: visible;
    font-family: var(--ptt-font-family);
}

/* Row 1: Main Controls (30/60/10) */
.ptt-toolbar-main {
    display: flex;
    align-items: center;
    padding: var(--ptt-space-md);
    gap: var(--ptt-space-md);
    background: #ffffff;
}

.ptt-main-left {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

.ptt-main-center {
    flex: 1 1 0%;
    min-width: 0;
    display: flex;
    align-items: center;
}

.ptt-main-right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

/* Full Screen Button Adjustments */
.ptt-main-left .ptt-fullscreen-toggle {
    width: 100%;
    justify-content: center;
}

/* Search Bar Placeholder */
.ptt-search-placeholder .dataTables_filter {
    width: 100%;
    margin-bottom: 0 !important;
}

.ptt-search-placeholder .dataTables_filter label {
    display: flex;
    align-items: center;
    width: 100%;
}

.ptt-search-placeholder .dataTables_filter input {
    width: 100% !important;
    margin-left: 0 !important;
    height: 44px !important;
    background: var(--ptt-light-gray) !important;
    border: 1px solid transparent !important;
    border-radius: var(--ptt-radius-md) !important;
    padding: 0 var(--ptt-space-md) 0 40px !important;
    box-shadow: none !important;
}

.ptt-search-placeholder .dataTables_filter input:focus {
    background: var(--ptt-white) !important;
    border-color: var(--ptt-brand-blue) !important;
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1) !important;
}

/* Toggle Button Style */
.ptt-filter-toggle {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ptt-light-gray);
    border: 1px solid transparent;
    border-radius: var(--ptt-radius-md);
    color: var(--ptt-text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.ptt-filter-toggle:hover {
    background: #EAEAEA;
    color: var(--ptt-charcoal);
    border-color: var(--ptt-border);
}

.ptt-filter-toggle.active {
    background: var(--ptt-brand-blue);
    color: var(--ptt-white);
}

.ptt-filter-toggle svg {
    width: 20px !important;
    height: 20px !important;
    display: block !important;
    min-width: 20px;
    min-height: 20px;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
    fill: none !important;
    stroke: currentColor !important;
}

/* Row 2: Collapsible Panel */
.ptt-toolbar-collapsible {
    padding: var(--ptt-space-md);
    background: #fafafa;
    border-top: 1px solid var(--ptt-border);
    overflow: visible !important;
    /* Allow calendar to show over boundaries */
}

/* Filters Grid (Row 1 of Panel) */
.ptt-filters-grid {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    /* Allow wrapping to prevent off-canvas overflow */
    gap: 15px !important;
    padding-bottom: 10px !important;
    border-bottom: 1px dashed #eee !important;
    margin-bottom: 10px !important;
    width: 100% !important;
}

.ptt-filters-grid>.ptt-filter-group {
    flex: 1 1 calc(25% - 15px) !important;
    min-width: 200px !important;
    /* Prevent squishing */
    max-width: 100% !important;
}

.ptt-filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--ptt-space-xs);
}

.ptt-filter-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--ptt-text-tertiary);
    letter-spacing: 0.05em;
}

.ptt-filter-select {
    height: 40px;
    padding: 0 var(--ptt-space-sm);
    border: 1px solid var(--ptt-border);
    border-radius: var(--ptt-radius-md);
    background: var(--ptt-white);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.ptt-filter-select:focus {
    border-color: var(--ptt-brand-blue);
}

/* Date Picker Fixes */
.ptt-date-input-wrapper {
    position: relative !important;
    display: block !important;
    width: 100% !important;
}

.flatpickr-wrapper {
    display: block !important;
    width: 100% !important;
}

.ptt-date-icon {
    position: absolute !important;
    right: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    pointer-events: none !important;
    font-size: 14px !important;
    opacity: 0.5 !important;
    z-index: 1 !important;
    background: transparent !important;
}

.ptt-filter-date.ptt-filter-select,
.flatpickr-input,
.flatpickr-mobile {
    padding-right: 40px !important;
    box-sizing: border-box !important;
    width: 100% !important;
    /* Force full width on desktop too */
}

/* Hide ALL native calendar icons across all browsers - ULTRA AGGRESSIVE */
.ptt-container input::-webkit-calendar-picker-indicator,
.ptt-container input::-webkit-inner-spin-button,
.ptt-container input::-webkit-clear-button,
.ptt-container input::-ms-clear,
.ptt-container input::-ms-reveal,
.ptt-filter-date::-webkit-calendar-picker-indicator,
.flatpickr-input::-webkit-calendar-picker-indicator,
.flatpickr-mobile::-webkit-calendar-picker-indicator {
    display: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: none !important;
    border: none !important;
}

/* Force removal of any native background icons and appearance */
.ptt-filter-date,
.flatpickr-input,
.flatpickr-mobile {
    background-image: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    box-shadow: none !important;
}

.ptt-date-input-wrapper input.ptt-filter-date {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding-right: 40px !important;
    /* Space for icon */
    box-sizing: border-box !important;
}

/* Reset for internal calendar inputs (year, etc.) that might be inherited from parent wrapper */
.flatpickr-calendar input {
    width: auto !important;
    padding-right: 0 !important;
    box-sizing: content-box !important;
}

/* Icon positioning restored for absolute calendar layout */
.ptt-date-icon {
    position: absolute !important;
    right: 12px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    height: auto !important;
    line-height: normal !important;
    pointer-events: none !important;
    font-size: 14px !important;
    opacity: 0.5 !important;
    z-index: 5 !important;
    background: transparent !important;
    display: block !important;
}

/* Force flatpickr input to have no background image that might be injected by browser */
.ptt-filter-date,
.flatpickr-input {
    background-image: none !important;
}

/* Ensure flatpickr popup is on top and not clipped */
.flatpickr-calendar {
    z-index: 9999999999 !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid var(--ptt-border) !important;
    background: var(--ptt-white) !important;
    margin-top: 0 !important;
}

/* Force container to allow overflow when popup is active */
.ptt-container.ptt-filters-overflow-visible,
.ptt-container.ptt-filters-overflow-visible .ptt-toolbar-collapsible,
.ptt-container.ptt-filters-overflow-visible .ptt-filters-grid,
.ptt-container.ptt-filters-overflow-visible .ptt-filter-group {
    overflow: visible !important;
}

/* Also override fullscreen mode's overflow when calendar is open */
.ptt-container.ptt-fullscreen.ptt-filters-overflow-visible {
    overflow: visible !important;
}

/* Secondary Actions (Row 2 of Panel) */
.ptt-secondary-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 10px !important;
    justify-content: flex-start !important;
    padding-top: 0 !important;
    border-top: none !important;
}

.ptt-filter-reset-wrap {
    flex: 0 0 auto !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    height: 32px !important;
    gap: 0 !important;
}

/* Reset Button — subtle outlined style */
.ptt-filter-reset {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    height: 32px !important;
    padding: 0 14px !important;
    margin: 0 !important;
    background: transparent !important;
    border: 1px solid var(--ptt-border) !important;
    border-radius: var(--ptt-radius-sm) !important;
    color: var(--ptt-text-secondary) !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    white-space: nowrap !important;
    box-shadow: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: 1 !important;
    vertical-align: middle !important;
    box-sizing: border-box !important;
}

.ptt-filter-reset:hover {
    background: var(--ptt-light-gray) !important;
    border-color: var(--ptt-text-tertiary) !important;
    color: var(--ptt-text-primary) !important;
}

/* Highlighted state when filters or search are active */
.ptt-filter-reset.has-active-filters {
    background: var(--ptt-brand-blue) !important;
    border-color: var(--ptt-brand-blue) !important;
    color: var(--ptt-white) !important;
    box-shadow: 0 2px 8px rgba(0, 102, 255, 0.25) !important;
}

.ptt-filter-reset.has-active-filters:hover {
    background: var(--ptt-brand-blue-hover) !important;
    border-color: var(--ptt-brand-blue-hover) !important;
}

.ptt-length-placeholder,
.ptt-buttons-placeholder {
    flex: 0 1 auto !important;
    display: flex !important;
    align-items: center !important;
    margin-bottom: 0 !important;
    min-width: 0 !important;
}

/* Compact Show Entries inside collapsible panel */
.ptt-secondary-actions .dataTables_length {
    margin: 0 !important;
    float: none !important;
}

.ptt-secondary-actions .dataTables_length label {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    margin: 0 !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    color: var(--ptt-text-secondary) !important;
    white-space: nowrap !important;
}

.ptt-secondary-actions .dataTables_length select {
    height: 32px !important;
    padding: 0 8px !important;
    border: 1px solid var(--ptt-border) !important;
    border-radius: var(--ptt-radius-sm) !important;
    background: var(--ptt-white) !important;
    font-size: 12px !important;
    color: var(--ptt-text-primary) !important;
    cursor: pointer !important;
    outline: none !important;
    min-width: 50px !important;
}

/* Compact Export Buttons inside collapsible panel */
.ptt-secondary-actions .dt-buttons {
    display: flex !important;
    gap: 6px !important;
    margin: 0 !important;
    float: none !important;
}

.ptt-secondary-actions .ptt-export-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    height: 32px !important;
    padding: 0 10px !important;
    background: var(--ptt-white) !important;
    border: 1px solid var(--ptt-border) !important;
    border-radius: var(--ptt-radius-sm) !important;
    color: var(--ptt-text-secondary) !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    box-shadow: none !important;
    white-space: nowrap !important;
    line-height: 1 !important;
}

.ptt-secondary-actions .ptt-export-btn:hover {
    background: var(--ptt-light-gray) !important;
    border-color: var(--ptt-text-tertiary) !important;
    color: var(--ptt-text-primary) !important;
}

.ptt-secondary-actions .ptt-export-btn .ptt-btn-icon {
    font-size: 13px !important;
    line-height: 1 !important;
    opacity: 0.7 !important;
}

/* Hide original DT wrapper controls since we move them */
.dataTables_wrapper .ptt-table-controls {
    display: none !important;
}


.dataTables_wrapper .dataTables_length select {
    padding: 0 var(--ptt-space-md);
    height: 40px;
    border: 1px solid var(--ptt-border);
    border-radius: var(--ptt-radius-md);
    font-size: 14px;
    background: var(--ptt-white);
    color: var(--ptt-text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.dataTables_wrapper .dataTables_length select:hover {
    border-color: var(--ptt-brand-blue-hover);
    background: #fafafa;
}

/* Info */
.dataTables_wrapper .dataTables_info {
    color: var(--ptt-text-tertiary);
    font-size: 14px;
    padding-top: var(--ptt-space-md);
}

/* Pagination */
.dataTables_wrapper .dataTables_paginate {
    padding-top: var(--ptt-space-md);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: var(--ptt-space-sm) var(--ptt-space-md);
    margin: 0 2px;
    border: 1px solid var(--ptt-border);
    border-radius: var(--ptt-radius-sm);
    background: var(--ptt-white);
    color: var(--ptt-text-primary) !important;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--ptt-light-gray) !important;
    border-color: var(--ptt-border);
    color: var(--ptt-charcoal) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--ptt-brand-blue) !important;
    border-color: var(--ptt-brand-blue);
    color: var(--ptt-white) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--ptt-brand-blue-hover) !important;
    border-color: var(--ptt-brand-blue-hover);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    color: var(--ptt-text-disabled) !important;
    cursor: not-allowed;
    background: var(--ptt-light-gray) !important;
    border-color: var(--ptt-border);
}

/* Empty State */
.dataTables_wrapper .dataTables_empty {
    padding: var(--ptt-space-xl);
    text-align: center;
    color: var(--ptt-text-tertiary);
}

/* =========================================
   Responsive Styles
   ========================================= */
@media screen and (max-width: 992px) {
    .ptt-filters-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: var(--ptt-space-sm) !important;
    }

    .ptt-toolbar-container {
        padding: var(--ptt-space-xs) var(--ptt-space-xs) !important;
    }

    .ptt-filter-group {
        flex: 0 0 auto !important;
        height: auto !important;
        gap: 4px !important;
        min-width: unset !important;
        margin-bottom: var(--ptt-space-sm) !important;
    }

    .ptt-filter-label {
        font-size: 11px;
        margin-bottom: 2px;
    }

    .ptt-table-controls {
        display: flex !important;
        flex-direction: row !important;
        /* Row for the first two */
        flex-wrap: wrap !important;
        align-items: center !important;
        padding: var(--ptt-space-sm) var(--ptt-space-md) !important;
    }

    /* FS Button and Length on same row */
    .ptt-table-controls .ptt-fullscreen-btn-wrap,
    .ptt-table-controls .dataTables_length {
        flex: 1 1 50% !important;
        max-width: 50% !important;
        margin-bottom: var(--ptt-space-sm) !important;
    }

    .ptt-table-controls .ptt-fullscreen-btn-wrap {
        padding-right: var(--ptt-space-xs);
    }

    .ptt-table-controls .dataTables_length {
        padding-left: var(--ptt-space-xs);
        text-align: right;
    }

    .ptt-table-controls .dataTables_length label {
        justify-content: flex-end;
    }

    /* Search on its own row below */
    .ptt-table-controls .dataTables_filter {
        flex: 1 1 100% !important;
        width: 100% !important;
        margin-top: 0 !important;
    }

    .ptt-table-controls .dataTables_filter input {
        width: 100% !important;
        min-width: unset !important;
        margin-left: 0 !important;
    }
}

@media screen and (max-width: 768px) {
    .ptt-container {
        margin: var(--ptt-space-md) 0;
    }

    .ptt-table thead th,
    .ptt-table tbody td {
        padding: var(--ptt-space-sm) var(--ptt-space-md);
    }

    .ptt-col-content {
        max-width: 200px;
    }

    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        text-align: center;
    }
}

/* =========================================
   Responsive DataTables Styles
   ========================================= */

/* The control icon (+) */
table.dataTable.dtr-inline.collapsed>tbody>tr>td.dtr-control,
table.dataTable.dtr-inline.collapsed>tbody>tr>th.dtr-control {
    position: relative;
    padding-left: 35px !important;
    cursor: pointer;
}

table.dataTable.dtr-inline.collapsed>tbody>tr>td.dtr-control:before,
table.dataTable.dtr-inline.collapsed>tbody>tr>th.dtr-control:before {
    top: 50% !important;
    left: 10px !important;
    height: 18px !important;
    width: 18px !important;
    margin-top: -9px !important;
    display: block;
    position: absolute;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    background-color: var(--ptt-brand-blue) !important;
    text-align: center;
    text-indent: 0 !important;
    line-height: 18px !important;
    content: '+' !important;
    font-family: Arial, sans-serif !important;
    font-size: 14px !important;
    font-weight: bold !important;
    transition: all 0.2s ease;
}

/* Hover effect */
table.dataTable.dtr-inline.collapsed>tbody>tr:hover td.dtr-control:before {
    background-color: var(--ptt-brand-blue-hover) !important;
    transform: scale(1.1);
}

/* Expanded state (-) */
table.dataTable.dtr-inline.collapsed>tbody>tr.parent>td.dtr-control:before,
table.dataTable.dtr-inline.collapsed>tbody>tr.parent>th.dtr-control:before {
    content: '-' !important;
    background-color: var(--ptt-error) !important;
    transform: rotate(180deg);
}

/* Detail row styling */
table.dataTable>tbody>tr.child ul.dtr-details {
    display: block;
    list-style-type: none;
    margin: 0;
    padding: var(--ptt-space-md);
    background: #fdfdfd;
}

table.dataTable>tbody>tr.child ul.dtr-details>li {
    border-bottom: 1px solid var(--ptt-border);
    padding: var(--ptt-space-sm) 0;
    display: flex;
    justify-content: space-between;
}

table.dataTable>tbody>tr.child ul.dtr-details>li:last-child {
    border-bottom: none;
}

table.dataTable>tbody>tr.child span.dtr-title {
    font-weight: 600;
    color: var(--ptt-text-secondary);
    min-width: 120px;
    display: inline-block;
}

table.dataTable>tbody>tr.child span.dtr-data {
    color: var(--ptt-text-primary);
    text-align: justify;
}

/* =========================================
   No Wrap Mode
   ========================================= */
.ptt-table[data-wrap="false"] tbody td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* (Consolidated into ptt-toolbar-container block above) */


/* =========================================
   Status Column
   ========================================= */
.ptt-col-status {
    white-space: nowrap;
}

.ptt-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--ptt-radius-sm);
    font-size: 12px;
    font-weight: 500;
    text-transform: capitalize;
}

.ptt-status-publish {
    background: #E8F5E9;
    color: #2E7D32;
}

.ptt-status-draft {
    background: #FFF3E0;
    color: #EF6C00;
}

.ptt-status-pending {
    background: #E3F2FD;
    color: #1565C0;
}

.ptt-status-private {
    background: #F3E5F5;
    color: #7B1FA2;
}

.ptt-status-future {
    background: #E0F7FA;
    color: #00838F;
}

.ptt-status-trash {
    background: #FFEBEE;
    color: #C62828;
}

/* =========================================
   Excerpt Column
   ========================================= */
.ptt-col-excerpt {
    max-width: 300px;
    color: var(--ptt-text-secondary);
}

/* =========================================
   Loading Indicator (New Premium Design)
   ========================================= */
.ptt-loading-container {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 10px;
}

.ptt-loading-bar {
    position: absolute;
    top: -2px;
    /* Sits right at the bottom of the header */
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(0, 200, 83, 0.1);
    /* Subtle green track */
    overflow: hidden;
}

.ptt-loading-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 30%;
    background: var(--ptt-success);
    box-shadow: 0 0 10px var(--ptt-success);
    animation: ptt-loading-slide 1.5s infinite ease-in-out;
}

.ptt-loading-text {
    font-size: 11px;
    font-weight: 800;
    color: var(--ptt-success);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-top: 12px;
    opacity: 0.9;
    animation: ptt-pulse 1.5s infinite ease-in-out;
}

@keyframes ptt-loading-slide {
    0% {
        left: -30%;
    }

    100% {
        left: 100%;
    }
}

@keyframes ptt-pulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

/* DataTables processing indicator override */
.dataTables_wrapper .dataTables_processing {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    z-index: 100 !important;
}

/* =========================================
   Scroll Mode
   ========================================= */
.ptt-container .dataTables_wrapper {
    overflow-x: auto;
    padding-bottom: 20px;
}

/* =========================================
   Filter Responsive
   ========================================= */
@media screen and (max-width: 768px) {
    .ptt-filters-row {
        flex-direction: column;
        align-items: stretch;
    }

    .ptt-filter-group {
        width: 100%;
    }

    .ptt-filter-select {
        width: 100%;
    }

    .ptt-filter-reset-wrap {
        align-self: stretch;
    }

    .ptt-filter-reset {
        width: 100%;
    }
}

/* =========================================
   Full Screen Modal Mode
   ========================================= */

.ptt-fullscreen-btn-wrap {
    display: contents;
    /* Allow button to be part of the flex row */
}

.ptt-fullscreen-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--ptt-space-sm);
    padding: 0 var(--ptt-space-md);
    height: 40px;
    background: var(--ptt-brand-blue);
    border: 1px solid var(--ptt-brand-blue);
    border-radius: var(--ptt-radius-md);
    color: var(--ptt-white);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 102, 255, 0.2);
    white-space: nowrap;
}

.ptt-fullscreen-toggle:hover {
    background: var(--ptt-brand-blue-hover);
    border-color: var(--ptt-brand-blue-hover);
    color: var(--ptt-white);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.3);
}

.ptt-fullscreen-toggle:active {
    transform: translateY(0);
}

.ptt-btn-icon {
    font-size: 16px;
}

/* Modal Overlay State */
body.ptt-modal-open {
    overflow: hidden !important;
}

/* Full Screen Mode - Ultra Robust (v1.1.72) */
.ptt-container.ptt-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 2147483640 !important;
    background: #ffffff !important;
    /* Force white background to kill gaps */
    padding: 0 !important;
    /* No container padding */
    margin: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    max-width: none !important;
    max-height: none !important;
    transform: none !important;
    filter: none !important;
    animation: pttFadeIn 0.2s ease-out;
}

/* Toolbar Alignment - Restricted width to match table wrapper */
.ptt-fullscreen .ptt-toolbar-container {
    flex: 0 0 auto !important;
    width: 100% !important;
    max-width: 1600px !important;
    background: #fff !important;
    border-radius: 0 !important;
    /* Square for seamless merging */
    border-bottom: 1px solid var(--ptt-border) !important;
    margin: 0 !important;
    padding: 15px 20px !important;
    box-shadow: none !important;
    /* Kill shadow gap */
    box-sizing: border-box;
    z-index: 20 !important;
    position: relative;
}

@keyframes pttFadeIn {
    from {
        opacity: 0;
        transform: scale(0.99);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Hide body scrollbar when modal is open */
body.ptt-modal-open {
    overflow: hidden !important;
    height: 100vh !important;
}

/* Table Wrapper - Constrained width and internal scrolling */
.ptt-fullscreen .ptt-table-wrapper {
    flex: 1 !important;
    width: 100% !important;
    max-width: 1600px !important;
    background: #fff;
    border-radius: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    box-shadow: none !important;
    min-height: 0;
    position: relative;
    z-index: 10 !important;
}

/* DataTables Flex Layout for internal scrolling */
.ptt-fullscreen .dataTables_wrapper {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    padding: 0 10px 10px 10px !important;
    min-height: 0;
}

.ptt-fullscreen .dataTables_scroll {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    min-height: 0;
}

.ptt-fullscreen .dataTables_scrollHead {
    flex: 0 0 auto !important;
}

.ptt-fullscreen .dataTables_scrollBody {
    flex: 1 1 auto !important;
    overflow: auto !important;
    max-height: none !important;
    min-height: 0;
}

/* Exit button reset */
.ptt-fullscreen .ptt-fullscreen-toggle {
    background: #f44336 !important;
    color: #ffffff !important;
    border: none !important;
}

.ptt-fullscreen .ptt-fullscreen-toggle:hover {
    background: #d32f2f !important;
}

/* Force Scroll mode behavior in fullscreen */
.ptt-fullscreen .ptt-table {
    min-width: 1400px !important;
    width: 100% !important;
    display: table !important;
}

/* Force all columns to show, overriding Responsive extension */
.ptt-fullscreen .ptt-table th,
.ptt-fullscreen .ptt-table td {
    display: table-cell !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Hide the child row created by Responsive extension if any */
.ptt-fullscreen .ptt-table tr.child,
.ptt-fullscreen .ptt-table td.child {
    display: none !important;
}

/* Hide responsive collapse icons in fullscreen */
.ptt-fullscreen table.dataTable.dtr-inline.collapsed>tbody>tr>td.dtr-control:before,
.ptt-fullscreen table.dataTable.dtr-inline.collapsed>tbody>tr>td.dtr-control:after {
    display: none !important;
}

.ptt-fullscreen table.dataTable.dtr-inline.collapsed>tbody>tr>td.dtr-control {
    padding-left: var(--ptt-space-md) !important;
}

/* =========================================
   Content Read More Toggle
   ========================================= */
.ptt-table td.ptt-col-content,
.ptt-table td.ptt-col-excerpt {
    max-width: 400px;
    min-width: 200px;
    vertical-align: top;
}

.ptt-content-column {
    display: flex;
    flex-direction: column;
    gap: var(--ptt-space-xs);
    width: 100%;
}

.ptt-content-main {
    max-height: 4.5em;
    /* Show about 3 lines */
    overflow: hidden;
    position: relative;
    line-height: 1.5;
    transition: max-height 0.4s ease-in-out;
    white-space: normal !important;
}

.ptt-content-column.expanded .ptt-content-main {
    max-height: none !important;
    /* Reveal all */
}

.ptt-read-more {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    color: var(--ptt-brand-blue) !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    cursor: pointer;
    width: fit-content;
    display: inline-flex;
    align-items: center;
    box-shadow: none !important;
    text-transform: none !important;
    min-height: auto !important;
}

.ptt-read-more:hover {
    color: var(--ptt-brand-blue-hover) !important;
    text-decoration: underline !important;
}

.ptt-read-more::after {
    content: '↓';
    margin-left: 4px;
    font-size: 14px;
}

.ptt-content-column.expanded .ptt-read-more::after {
    content: '↑';
}

/* =========================================
   Table Controls & Mobile 50/50 Split
   ========================================= */
.ptt-table-controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ptt-space-md);
    align-items: center;
    margin-bottom: var(--ptt-space-md);
    padding: var(--ptt-space-md);
    background: #fff;
    border: 1px solid var(--ptt-border);
    border-radius: var(--ptt-radius-md);
}

.ptt-table-controls .dataTables_length,
.ptt-table-controls .dataTables_filter {
    margin: 0 !important;
    float: none !important;
}

.ptt-table-controls .dataTables_length label,
.ptt-table-controls .dataTables_filter label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 500;
}

.ptt-table-controls .dataTables_filter input {
    border-radius: 25px !important;
    padding: 8px 15px 8px 38px !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239BA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: 12px center !important;
    background-size: 18px !important;
    border: 1px solid var(--ptt-border) !important;
    background-color: var(--ptt-white) !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
    transition: all 0.2s ease !important;
    min-width: 200px !important;
    outline: none !important;
}

.ptt-table-controls .dataTables_filter input:focus {
    border-color: var(--ptt-brand-blue) !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1) !important;
}

/* Date Filter Styling */
.ptt-date-filter-group {
    min-width: 0 !important;
}

.ptt-date-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.ptt-date-input-wrapper .ptt-filter-date {
    padding-right: 35px !important;
    cursor: pointer !important;
    background: var(--ptt-white) !important;
}

.ptt-date-icon {
    position: absolute;
    right: 12px;
    font-size: 16px;
    pointer-events: none;
    opacity: 0.6;
}

/* Flatpickr Premium Overrides */
.flatpickr-calendar {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
    border: 1px solid var(--ptt-border) !important;
    border-radius: var(--ptt-radius-md) !important;
    z-index: 1000001 !important;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: var(--ptt-brand-blue) !important;
    border-color: var(--ptt-brand-blue) !important;
}

.flatpickr-day.inRange {
    background: rgba(37, 99, 235, 0.1) !important;
    box-shadow: -5px 0 0 rgba(37, 99, 235, 0.1), 5px 0 0 rgba(37, 99, 235, 0.1) !important;
}

/* DT Buttons Styling */
.ptt-table-controls .dt-buttons {
    display: flex !important;
    gap: 8px !important;
    margin: 0 !important;
    float: none !important;
}

.ptt-table-controls .ptt-export-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    padding: 8px 14px !important;
    background: var(--ptt-white) !important;
    border: 1px solid var(--ptt-border) !important;
    border-radius: var(--ptt-radius-sm) !important;
    color: var(--ptt-text-main) !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

.ptt-table-controls .ptt-export-btn:hover {
    background: #F9FAFB !important;
    border-color: #D1D5DB !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
}

.ptt-table-controls .ptt-export-btn:active {
    transform: translateY(0) !important;
    box-shadow: none !important;
}

.ptt-table-controls .ptt-export-btn .ptt-btn-icon {
    font-size: 16px !important;
    line-height: 1 !important;
    opacity: 0.7 !important;
}

.ptt-table-controls .ptt-btn-print:hover {
    color: var(--ptt-brand-blue) !important;
    border-color: var(--ptt-brand-blue) !important;
}

.ptt-table-controls .ptt-btn-excel:hover {
    color: #166534 !important;
    /* Green for Excel */
    border-color: #166534 !important;
}

@media screen and (max-width: 768px) {
    .ptt-toolbar-main {
        flex-wrap: wrap !important;
        gap: 12px !important;
    }

    .ptt-main-left {
        order: 2 !important;
        flex: 1 !important;
    }

    .ptt-main-center {
        order: 1 !important;
        flex: 0 0 100% !important;
    }

    .ptt-main-right {
        order: 3 !important;
        flex: 0 0 auto !important;
    }

    /* FS Button fills majority of bottom row */
    .ptt-main-left .ptt-fullscreen-toggle {
        width: 100% !important;
        justify-content: center !important;
        padding: 8px !important;
        height: 44px !important;
        margin: 0 !important;
    }

    .ptt-table-controls .dataTables_length label {
        width: 100% !important;
        justify-content: space-between !important;
    }

    .ptt-table-controls .dataTables_length select {
        flex: 1 !important;
        margin: 0 !important;
        height: 38px !important;
    }

    .ptt-table-controls .dataTables_filter {
        flex: 0 0 100% !important;
        width: 100% !important;
        margin-top: 5px !important;
    }

    .ptt-table-controls .dataTables_filter label {
        width: 100% !important;
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .ptt-table-controls .dataTables_filter input {
        width: 100% !important;
        margin: 5px 0 0 0 !important;
        height: 40px !important;
        min-width: 0 !important;
    }

    .ptt-table-controls .dt-buttons {
        flex: 0 0 100% !important;
        width: 100% !important;
        margin-top: 5px !important;
        justify-content: space-between !important;
    }

    .ptt-table-controls .ptt-export-btn {
        flex: 1 !important;
        justify-content: center !important;
        padding: 10px 5px !important;
        font-size: 12px !important;
    }

    .ptt-date-filter-group {
        flex: 0 0 100% !important;
        width: 100% !important;
    }

    /* Ensure all filter groups take full width on mobile to prevent overflow */
    .ptt-filters-grid .ptt-filter-group {
        flex: 0 0 100% !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        padding-right: 15px !important;
        /* Add padding to prevent touching border */
        box-sizing: border-box !important;
    }

    .ptt-date-input-wrapper {
        width: 100% !important;
    }

    .ptt-date-input-wrapper input {
        width: 100% !important;
    }
}

/* =========================================
   Export Loading State
   ========================================= */
.ptt-export-btn.ptt-exporting {
    background-color: #f8f9fa !important;
    color: #6c757d !important;
    cursor: wait !important;
    opacity: 0.8 !important;
}

.ptt-spin {
    display: inline-block !important;
    animation: ptt-spin 2s infinite linear !important;
}

@keyframes ptt-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(359deg);
    }
}

/* =========================================
   WooCommerce Price Stacking
   ========================================= */
/* Target the custom wrapper for guaranteed specificity */
.ptt-table .ptt-wc-price {
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 2px !important;
    line-height: 1.2 !important;
}

/* Ensure the inner price span doesn't override display */
.ptt-table .ptt-wc-price .price {
    display: contents !important;
    /* or display: block if contents is risky, but contents lets del/ins be direct children of our flex wrapper if structure allows. 
       Actually, usually WC outputs <span class="price"><del>...</del><ins>...</ins></span>. 
       So .ptt-wc-price > .price > del/ins.
       If .ptt-wc-price is the flex container, .price is the flex item.
       We want del/ins to be stacked.
       So .price should be the flex container.
       Let's allow .ptt-wc-price to just be a block/inline-block and make .price the flex column.
    */
}

.ptt-table .ptt-wc-price .price {
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 2px !important;
}

.ptt-table .ptt-wc-price .price del,
.ptt-table .ptt-wc-price .price ins {
    display: block !important;
    margin: 0 !important;
}

.ptt-table .ptt-wc-price .price del {
    order: 1 !important;
    opacity: 0.7;
    font-size: 0.9em;
}

.ptt-table .ptt-wc-price .price ins {
    order: 2 !important;
    text-decoration: none !important;
    font-weight: bold;
}

/* =========================================
   Image Lightbox
   ========================================= */
.ptt-table[data-ptt-lightbox="true"] .ptt-thumbnail {
    cursor: zoom-in;
    transition: opacity 0.2s ease;
}

.ptt-table[data-ptt-lightbox="true"] .ptt-thumbnail:hover {
    opacity: 0.85;
}

.ptt-lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483647 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 15, 15, 0.97);
    /* Deep dark background to hide layout shifts */
    opacity: 0;
    transition: opacity 0.3s ease;
    cursor: zoom-out;
    backdrop-filter: blur(5px);
    /* Soften the background */
}

.ptt-lightbox-overlay.ptt-lightbox-active {
    opacity: 1;
}

.ptt-lightbox-img-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    min-height: 100px;
}

.ptt-lightbox-image {
    max-width: 92vw;
    max-height: 92vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    cursor: default;
    user-select: none;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease;
}

/* Premium Lightbox Loader */
.ptt-lightbox-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid var(--ptt-brand-blue, #0066ff);
    border-radius: 50%;
    animation: ptt-spin 0.8s linear infinite;
    display: none;
    z-index: 5;
}

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

.ptt-lightbox-overlay.is-loading .ptt-lightbox-loader {
    display: block;
}

.ptt-lightbox-overlay.is-loading .ptt-lightbox-image {
    opacity: 0.3;
    /* Keep it subtle while loading */
}

.ptt-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 60px;
    padding: 20px 15px;
    cursor: pointer;
    z-index: 2;
    transition: all 0.2s ease;
    border-radius: 8px;
    line-height: 0.8;
}

.ptt-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.ptt-lightbox-prev {
    left: 20px;
}

.ptt-lightbox-next {
    right: 20px;
}

.ptt-lightbox-close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    font-size: 32px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 3;
}

.ptt-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

@media (max-width: 768px) {
    .ptt-lightbox-nav {
        padding: 10px 5px;
        font-size: 40px;
    }

    .ptt-lightbox-prev {
        left: 10px;
    }

    .ptt-lightbox-next {
        right: 10px;
    }

    /* Lightbox Rotate Control (Mobile Only) v1.2.83 */
    .ptt-lightbox-rotate {
        position: absolute;
        top: 24px;
        right: 85px;
        /* Stay to the left of the close button */
        background: rgba(255, 255, 255, 0.15);
        border: 1px solid rgba(255, 255, 255, 0.2);
        color: #fff;
        font-size: 20px;
        width: 48px;
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        cursor: pointer;
        transition: all 0.2s ease;
        z-index: 10;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }

    .ptt-lightbox-rotate:hover {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(1.1);
    }

    .ptt-lightbox-img-wrapper {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Roated State Logic */
    .ptt-lightbox-overlay.ptt-lightbox-rotated .ptt-lightbox-image {
        transform: rotate(90deg);
        max-width: 95vh !important;
        max-height: 95vw !important;
        width: auto !important;
        height: auto !important;
        object-fit: contain;
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    }

    /* Hide nav arrows when rotated to maximize space */
    .ptt-lightbox-overlay.ptt-lightbox-rotated .ptt-lightbox-nav {
        opacity: 0.3;
    }
}

/* Hide Rotate button on Desktop */
@media (min-width: 769px) {
    .ptt-lightbox-rotate {
        display: none !important;
    }

    .ptt-lightbox-img-wrapper {
        display: block;
        text-align: center;
    }
}

/* =========================================
   WooCommerce Buttons
   ========================================= */
.ptt-wc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
    transition: all 0.2s ease;
    white-space: nowrap;
    border: 1px solid transparent;
    cursor: pointer;
    line-height: 1;
}

/* Primary Button - Add to Cart / Select Options */
.ptt-wc-btn-cart,
.ptt-wc-btn-select {
    background-color: var(--ptt-brand-blue);
    color: var(--ptt-white) !important;
}

.ptt-wc-btn-cart:hover,
.ptt-wc-btn-select:hover {
    background-color: var(--ptt-brand-blue-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 102, 255, 0.2);
}

.ptt-wc-btn-cart:active,
.ptt-wc-btn-select:active {
    transform: translateY(0);
}

/* Secondary Button - View Product */
.ptt-wc-btn-view {
    background-color: var(--ptt-white);
    color: var(--ptt-brand-blue) !important;
    border-color: var(--ptt-brand-blue);
}

.ptt-wc-btn-view:hover {
    background-color: rgba(0, 102, 255, 0.05);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 102, 255, 0.1);
}

/* Adjust Stock Badge for matching quality */
.ptt-wc-stock {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.ptt-wc-stock-instock {
    background-color: rgba(0, 200, 83, 0.1);
    color: var(--ptt-success);
}

.ptt-wc-stock-outofstock {
    background-color: rgba(229, 57, 53, 0.1);
    color: var(--ptt-error);
}

.ptt-wc-stock-onbackorder {
    background-color: rgba(255, 107, 0, 0.1);
    color: var(--ptt-warning);
}

/* Alignment Utilities */
.ptt-wc-align-center {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    /* Keep horizontal center for buttons/badges, or adjust if needed */
    gap: 8px;
    width: 100%;
    padding: 0;
}

/* Style for the 'View cart' link added by WooCommerce AJAX */
.ptt-wc-add-to-cart-wrapper .added_to_cart {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--ptt-text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.ptt-wc-add-to-cart-wrapper .added_to_cart:hover {
    color: var(--ptt-brand-blue);
}

/* Ensure table cells are top aligned for consistency */
.ptt-table td {
    vertical-align: top !important;
    padding: var(--ptt-space-md) !important;
}

/* Premium Button Shine Effect */
.ptt-wc-btn {
    position: relative;
    overflow: hidden;
}

.ptt-wc-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(45deg);
    transition: all 0.3s ease;
    opacity: 0;
}

.ptt-wc-btn:hover::after {
    opacity: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}

/* Price Display Branding */
.ptt-wc-regular-price,
.ptt-wc-sale-price,
.ptt-wc-price {
    font-weight: 700;
    color: var(--ptt-charcoal);
    font-size: 14px;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    /* Horizontally center */
    justify-content: flex-start !important;
    width: 100%;
}

.ptt-wc-price ins {
    order: 1 !important;
    /* Discounted price TOP */
    text-decoration: none !important;
    font-weight: 700;
    color: var(--ptt-brand-blue) !important;
    font-size: 16px;
    display: block !important;
    line-height: 1.1;
    margin-bottom: 2px;
}

.ptt-wc-price del {
    order: 2 !important;
    /* Strikethrough price BOTTOM */
    opacity: 0.5;
    font-size: 12px;
    font-weight: 500;
    display: block !important;
    line-height: 1.1;
    text-decoration: line-through;
    margin: 0;
}

/* Specific wrapper centering */
.ptt-wc-price-wrapper.ptt-wc-align-center {
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
}

.ptt-wc-sale-price {
    color: var(--ptt-error);
}

.ptt-wc-price .woocommerce-Price-amount {
    color: inherit;
    text-align: center;
}

/* Fix for DataTables child toggle overlap */
.ptt-table td.dtr-control {
    position: relative;
    padding-left: 35px !important;
}

.ptt-table .dtr-control::before {
    left: 10px !important;
    top: 14px !important;
    /* Top aligned with text */
}

/* Fix for the weird horizontal bar in scrolled tables caused by hidden header padding */
.dataTables_scrollBody thead th,
.dataTables_scrollBody thead td {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Fix for filter panel animation */
.ptt-toolbar-collapsible.ptt-animating {
    overflow: hidden !important;
}

/* =========================================
   Sticky Header Implementation (v1.2.48)
   ========================================= */

/* Shared Sticky Styles */
.dataTables_scrollHead {
    background-color: #f8f9fa !important;
    z-index: 100 !important;
    position: relative;
}

.dataTables_scrollHeadInner,
.dataTables_scrollHead th,
.dataTables_scrollHead td {
    background-color: #f8f9fa !important;
    z-index: 100 !important;
    position: relative;
    /* Context for z-index */
}

/* 1. Normal View Sticky Header (Desktop/Tablet) */
@media screen and (min-width: 768px) {

    /* To make sticky work on window scroll, ancestors MUST have overflow visible */
    .ptt-container:not(.ptt-fullscreen),
    .ptt-table-wrapper:not(.ptt-fullscreen),
    .ptt-container:not(.ptt-fullscreen) .dataTables_wrapper,
    .ptt-container:not(.ptt-fullscreen) .dataTables_scroll {
        overflow: visible !important;
    }

    /* BUT the header and body containers must maintain their clipping/scrolling */
    .dataTables_scrollHead {
        overflow: hidden !important;
        position: sticky !important;
        top: 0 !important;
        width: 100% !important;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
        /* Soft shadow when stuck */
    }

    .dataTables_scrollBody {
        overflow-x: auto !important;
        overflow-y: visible !important;
        /* Allows sticky header to refer to window */
    }

    /* WP Admin Bar Handling */
    body.admin-bar .dataTables_scrollHead {
        top: 6px !important;
    }
}

/* 2. Fullscreen View Sticky Styles (v1.2.54) */
/* In Flexbox mode, we don't need overflow:visible; it would break internal scroll */

.ptt-fullscreen .dataTables_scrollHead {
    position: relative !important;
    /* Let flex stack it naturally */
    z-index: 30 !important;
    background-color: #ffffff !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08) !important;
    border-bottom: 1px solid var(--ptt-border) !important;
    margin: 0 !important;
    flex: 0 0 auto !important;
}

.ptt-fullscreen .dataTables_scrollHeadInner,
.ptt-fullscreen .dataTables_scrollHeadInner table {
    background-color: #ffffff !important;
    margin: 0 !important;
}

.ptt-fullscreen .dataTables_scrollHead th {
    background-color: #ffffff !important;
    color: var(--ptt-charcoal) !important;
}

.ptt-fullscreen .dataTables_scrollBody {
    flex: 1 1 auto !important;
    overflow: auto !important;
    position: relative !important;
    z-index: 1 !important;
    margin-top: 0 !important;
}

.ptt-fullscreen .ptt-table td {
    vertical-align: top !important;
    padding-top: var(--ptt-space-md) !important;
    /* Give rows some breathing room */
}

/* =========================================
   Mobile Stability & Scroll Fixes (v1.3.1)
   ========================================= */
@media screen and (max-width: 767px) {

    /* Prevent the 'pixel wobble' - table slightly wider than viewport */
    .ptt-container,
    .ptt-table-wrapper,
    .dataTables_wrapper,
    .dataTables_scroll,
    .dataTables_scrollHead,
    .dataTables_scrollBody {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Standard view: Block horizontal swipe 'wobble' */
    .ptt-container:not(.ptt-fullscreen) .dataTables_wrapper,
    .ptt-container:not(.ptt-fullscreen) .ptt-table {
        touch-action: pan-y !important;
        overflow-x: hidden !important;
        width: 100% !important;
        margin: 0 !important;
    }

    /* Fullscreen view: RESTORE horizontal navigation/swipe */
    .ptt-container.ptt-fullscreen .dataTables_wrapper,
    .ptt-container.ptt-fullscreen .ptt-table,
    .ptt-container.ptt-fullscreen .dataTables_scrollBody {
        touch-action: auto !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Fix the '30px overflow' bug found in live debugging */
    /* Many themes force content-box on DataTables elements */
    .dataTables_info,
    .dataTables_paginate,
    .dataTables_wrapper * {
        box-sizing: border-box !important;
        max-width: 100% !important;
    }



    /* Ensure child cells don't expand table beyond its bounds */
    .ptt-table th,
    .ptt-table td {
        word-wrap: break-word !important;
        word-break: break-all !important;
        /* Aggressive but safe for mobile */
        overflow-wrap: break-word !important;
    }
}

/* =========================================
   AJAX Loading Indicator (v1.3.1)
   ========================================= */
/* Aggressive override to force centering and visibility across themes */
.ptt-container .dataTables_processing,
.dataTables_wrapper .dataTables_processing {
    position: fixed !important;
    top: 40% !important;
    /* Slightly higher for better visual balance */
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 2147483647 !important;
    width: 110px !important;
    height: auto !important;
    min-height: 80px !important;
    margin: 0 !important;
    padding: 15px !important;
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: blur(10px) !important;
    border-radius: 16px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    display: none;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Force our layout only when DataTables intends to show it */
.ptt-container .dataTables_processing:not([style*="display: none"]),
.dataTables_wrapper .dataTables_processing:not([style*="display: none"]) {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Hide any theme-standard spinners/circles inside the DT processing div */
.dataTables_processing>div:not(.ptt-loading-container) {
    display: none !important;
}

.ptt-loading-container {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
}

/* Premium Triple-Dot Pulsing (v1.2.87) */
.ptt-loading-dots {
    display: flex !important;
    gap: 6px !important;
    margin-bottom: 12px !important;
}

.ptt-loading-dots span {
    width: 8px !important;
    height: 8px !important;
    background-color: var(--ptt-brand-blue) !important;
    border-radius: 50% !important;
    animation: ptt-dot-pulse 1.4s infinite ease-in-out both !important;
}

.ptt-loading-dots span:nth-child(1) {
    animation-delay: -0.32s !important;
}

.ptt-loading-dots span:nth-child(2) {
    animation-delay: -0.16s !important;
}

@keyframes ptt-dot-pulse {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.3;
    }

    40% {
        transform: scale(1.0);
        opacity: 1;
    }
}

.ptt-loading-text {
    font-size: 10px !important;
    font-weight: 800 !important;
    color: var(--ptt-charcoal) !important;
    letter-spacing: 1.5px !important;
    text-transform: uppercase !important;
}