/* Hubtal Modern Table Styles */
.wp-custom-blocks-table {
    --table-background: var(--wp--preset--color--background, #ffffff);
    --table-text: var(--wp--preset--color--foreground, #1f2937);
    --table-border: var(--wp--preset--color--border, #e5e7eb);
    --table-header-color: #f9fafb;
    --table-accent-color: #3b82f6;
    --table-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --table-radius: 8px;
    --table-spacing: 1.25rem;
    --table-cell-padding-x: 1.25rem;
    --table-cell-padding-y: 1rem;

    width: 100%;
    max-width: 100%;
    margin: 0 0 2rem;
    position: relative;
    font-family: inherit;
    box-sizing: border-box;
}


/* Wrapper and scrolling */
.wp-custom-blocks-table__wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
    border-radius: var(--table-radius);
    overflow: hidden;
    background: var(--table-background);
}

.wp-custom-blocks-table__wrapper--scroll {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.wp-custom-blocks-table__wrapper::-webkit-scrollbar {
    height: 8px;
}

.wp-custom-blocks-table__wrapper::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.wp-custom-blocks-table__wrapper::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.wp-custom-blocks-table__wrapper::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Base table styles */
.wp-custom-blocks-table__table {
    width: 100%;
    min-width: 100%;
    border-collapse: collapse;
    background: var(--table-background);
    color: var(--table-text);
    position: relative;
    table-layout: auto;
    box-sizing: border-box;
}

.wp-custom-blocks-table__table--fixed {
    table-layout: fixed;
    min-width: max-content; /* Allow table to be wider than container for scrolling */
}

.wp-custom-blocks-table__row {
    transition: background-color 0.2s ease;
}

.wp-custom-blocks-table__cell {
    padding: var(--table-cell-padding-y) var(--table-cell-padding-x);
    text-align: left;
    vertical-align: middle;
    line-height: 1.6;
    word-wrap: break-word;
    position: relative;
    font-size: 0.9375rem;
}

.wp-custom-blocks-table__header-cell {
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    background: var(--table-header-color, #f9fafb);
    position: sticky;
    top: 0;
    z-index: 10;
}

.wp-custom-blocks-table__row-number {
    width: 3rem;
    text-align: center;
    font-weight: 500;
    color: #6b7280;
    background: #f9fafb;
    border-right: 1px solid var(--table-border);
}

.wp-custom-blocks-table__caption {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: #6b7280;
    text-align: center;
    font-style: italic;
}

/* Row density variants */
.wp-custom-blocks-table--compact {
    --table-cell-padding-y: 0.625rem;
    --table-cell-padding-x: 1rem;
}

.wp-custom-blocks-table--comfortable {
    --table-cell-padding-y: 1rem;
    --table-cell-padding-x: 1.25rem;
}

.wp-custom-blocks-table--spacious {
    --table-cell-padding-y: 1.375rem;
    --table-cell-padding-x: 1.75rem;
}

/* Editor-only controls */
.wp-custom-blocks-table__row-controls {
    width: 40px;
    padding: 0.25rem;
    border: none;
    background: transparent;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.wp-custom-blocks-table__row:hover .wp-custom-blocks-table__row-controls {
    opacity: 1;
}

.wp-custom-blocks-table__delete-row {
    padding: 0.25rem;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s ease;
}

.wp-custom-blocks-table__delete-row:hover {
    background: #dc2626;
}

/* Column delete controls */
.wp-custom-blocks-table__header-cell:hover .wp-custom-blocks-table__delete-column {
    opacity: 1 !important;
}

.wp-custom-blocks-table__delete-column:hover {
    background: #dc2626 !important;
}

/* Column resize handles */
.wp-custom-blocks-table__resize-handle {
    position: absolute;
    top: 0;
    right: -4px;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    z-index: 15;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.wp-custom-blocks-table__resize-handle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 100%;
    background: #3b82f6;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.wp-custom-blocks-table__header-cell:hover .wp-custom-blocks-table__resize-handle {
    opacity: 1;
}

.wp-custom-blocks-table__resize-handle:hover::before,
.wp-custom-blocks-table__resize-handle.is-resizing::before {
    opacity: 1;
}

.wp-custom-blocks-table__resize-handle.is-resizing {
    opacity: 1;
}

/* Prevent text selection during resize */
body.is-resizing-column {
    user-select: none;
    cursor: col-resize !important;
}

body.is-resizing-column * {
    cursor: col-resize !important;
}


/* Sticky header */
.sticky-header .wp-custom-blocks-table__header-cell {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--table-header-color, #f9fafb);
    box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

/* ================================
   TABLE STYLE VARIANTS
================================ */

/* 1. Minimal Style - Clean and understated */
.wp-custom-blocks-table--minimal .wp-custom-blocks-table__wrapper {
    background: transparent;
    box-shadow: none;
}

.wp-custom-blocks-table--minimal .wp-custom-blocks-table__table {
    border: none;
}

.wp-custom-blocks-table--minimal .wp-custom-blocks-table__cell {
    border: none;
    border-bottom: 1px solid #f1f5f9;
    padding-top: 1.125rem;
    padding-bottom: 1.125rem;
}

.wp-custom-blocks-table--minimal .wp-custom-blocks-table__header-cell {
    background: transparent;
    border-bottom: 2px solid #e5e7eb;
    font-weight: 600;
    padding-bottom: 1rem;
}

.wp-custom-blocks-table--minimal .wp-custom-blocks-table__row:hover {
    background: rgba(249, 250, 251, 0.5);
}

/* 2. Bordered Style - Professional grid layout */
.wp-custom-blocks-table--bordered .wp-custom-blocks-table__wrapper {
    border: 1px solid var(--table-border);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.wp-custom-blocks-table--bordered .wp-custom-blocks-table__table {
    border: none;
}

.wp-custom-blocks-table--bordered .wp-custom-blocks-table__cell {
    border-right: 1px solid var(--table-border);
    border-bottom: 1px solid var(--table-border);
}

.wp-custom-blocks-table--bordered .wp-custom-blocks-table__cell:last-child {
    border-right: none;
}

.wp-custom-blocks-table--bordered .wp-custom-blocks-table__header-cell {
    background: var(--table-header-color);
    border-right: 1px solid var(--table-border);
    border-bottom: 1px solid var(--table-border);
}

.wp-custom-blocks-table--bordered .wp-custom-blocks-table__header-cell:last-child {
    border-right: none;
}

.wp-custom-blocks-table--bordered .wp-custom-blocks-table__row:last-child .wp-custom-blocks-table__cell {
    border-bottom: none;
}

/* 3. Striped Style - Alternating row colors for readability */
.wp-custom-blocks-table--striped .wp-custom-blocks-table__wrapper {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.wp-custom-blocks-table--striped .wp-custom-blocks-table__header-cell {
    background: var(--table-header-color);
    border-bottom: 2px solid var(--table-border);
}

.wp-custom-blocks-table--striped .wp-custom-blocks-table__cell {
    border: none;
}

.wp-custom-blocks-table--striped .wp-custom-blocks-table__body .wp-custom-blocks-table__row:nth-child(odd) {
    background: #ffffff;
}

.wp-custom-blocks-table--striped .wp-custom-blocks-table__body .wp-custom-blocks-table__row:nth-child(even) {
    background: #f9fafb;
}

.wp-custom-blocks-table--striped .wp-custom-blocks-table__row:hover {
    background: #f1f5f9 !important;
    transition: background-color 0.15s ease;
}

/* 4. Glassmorphism Style - Modern frosted glass effect */
.wp-custom-blocks-table--glass .wp-custom-blocks-table__wrapper {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

.wp-custom-blocks-table--glass .wp-custom-blocks-table__table {
    background: transparent;
}

.wp-custom-blocks-table--glass .wp-custom-blocks-table__cell {
    border: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.wp-custom-blocks-table--glass .wp-custom-blocks-table__header-cell {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--table-text);
    font-weight: 600;
}

.wp-custom-blocks-table--glass .wp-custom-blocks-table__row:hover {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
}

/* ================================
   HEADER STYLE VARIANTS
================================ */

.wp-custom-blocks-table--header-minimal .wp-custom-blocks-table__header-cell {
    background: transparent;
    border-bottom: 3px solid var(--table-accent-color);
    font-weight: 700;
}

.wp-custom-blocks-table--header-bold .wp-custom-blocks-table__header-cell {
    background: var(--table-accent-color);
    color: white;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ================================
   RESPONSIVE MOBILE MODES
================================ */

/* Card Layout Mobile */
@media (max-width: 768px) {
    .wp-custom-blocks-table__wrapper--card .wp-custom-blocks-table__table,
    .wp-custom-blocks-table__wrapper--card .wp-custom-blocks-table__head,
    .wp-custom-blocks-table__wrapper--card .wp-custom-blocks-table__body,
    .wp-custom-blocks-table__wrapper--card .wp-custom-blocks-table__foot,
    .wp-custom-blocks-table__wrapper--card .wp-custom-blocks-table__row {
        display: block;
    }

    .wp-custom-blocks-table__wrapper--card .wp-custom-blocks-table__head {
        display: none;
    }

    .wp-custom-blocks-table__wrapper--card .wp-custom-blocks-table__row {
        background: var(--table-background);
        border-radius: var(--table-radius);
        box-shadow: var(--table-shadow);
        margin-bottom: 1rem;
        padding: 1rem;
    }

    .wp-custom-blocks-table__wrapper--card .wp-custom-blocks-table__cell {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border: none;
        border-bottom: 1px solid #f1f5f9;
    }

    .wp-custom-blocks-table__wrapper--card .wp-custom-blocks-table__cell:last-child {
        border-bottom: none;
    }

    .wp-custom-blocks-table__wrapper--card .wp-custom-blocks-table__cell::before {
        content: attr(data-label) ': ';
        font-weight: 600;
        color: var(--table-accent-color);
        flex-shrink: 0;
        margin-right: 1rem;
    }

    /* Accordion Mobile */
    .wp-custom-blocks-table__wrapper--accordion .wp-custom-blocks-table__table,
    .wp-custom-blocks-table__wrapper--accordion .wp-custom-blocks-table__head,
    .wp-custom-blocks-table__wrapper--accordion .wp-custom-blocks-table__body,
    .wp-custom-blocks-table__wrapper--accordion .wp-custom-blocks-table__foot,
    .wp-custom-blocks-table__wrapper--accordion .wp-custom-blocks-table__row {
        display: block;
    }

    .wp-custom-blocks-table__wrapper--accordion .wp-custom-blocks-table__head {
        display: none;
    }

    .wp-custom-blocks-table__wrapper--accordion .wp-custom-blocks-table__row {
        border: 1px solid var(--table-border);
        border-radius: var(--table-radius);
        margin-bottom: 0.5rem;
        overflow: hidden;
    }

    .wp-custom-blocks-table__wrapper--accordion .wp-custom-blocks-table__row .wp-custom-blocks-table__cell:first-child {
        background: var(--table-header-color);
        font-weight: 600;
        padding: 1rem;
        cursor: pointer;
        position: relative;
    }

    .wp-custom-blocks-table__wrapper--accordion .wp-custom-blocks-table__row .wp-custom-blocks-table__cell:first-child::after {
        content: '+';
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
        font-size: 1.25rem;
        transition: transform 0.2s ease;
    }

    .wp-custom-blocks-table__wrapper--accordion .wp-custom-blocks-table__row.expanded .wp-custom-blocks-table__cell:first-child::after {
        transform: translateY(-50%) rotate(45deg);
    }

    .wp-custom-blocks-table__wrapper--accordion .wp-custom-blocks-table__row .wp-custom-blocks-table__cell:not(:first-child) {
        display: none;
        padding: 0.75rem 1rem;
        background: var(--table-background);
    }

    .wp-custom-blocks-table__wrapper--accordion .wp-custom-blocks-table__row.expanded .wp-custom-blocks-table__cell:not(:first-child) {
        display: block;
        border-top: 1px solid var(--table-border);
    }
}

/* Dark mode support - disabled by default, enabled with body class */
body.wp-custom-blocks-blocks-dark-mode .wp-custom-blocks-table {
    --table-background: #1f2937;
    --table-text: #f9fafb;
    --table-border: #374151;
    --table-header-color: #374151;
    --table-accent-color: #60a5fa;
}

body.wp-custom-blocks-blocks-dark-mode .wp-custom-blocks-table--glass .wp-custom-blocks-table__wrapper {
    background: rgba(31, 41, 55, 0.3);
    border: 1px solid #374151;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .wp-custom-blocks-table__cell {
        border: 1px solid currentColor;
    }

    .wp-custom-blocks-table__header-cell {
        background: currentColor;
        color: var(--table-background);
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .wp-custom-blocks-table__row,
    .wp-custom-blocks-table__cell,
    .wp-custom-blocks-table__sort-icon,
    .wp-custom-blocks-table__search-input {
        transition: none;
    }
}

/* Print styles */
@media print {
    .wp-custom-blocks-table__search,
    .wp-custom-blocks-table__row-controls,
    .wp-custom-blocks-table__sort-icon {
        display: none;
    }

    .wp-custom-blocks-table__wrapper {
        overflow: visible;
        box-shadow: none;
    }

    .wp-custom-blocks-table--glass {
        background: white !important;
        color: black !important;
    }

    .wp-custom-blocks-table__cell {
        border: 1px solid #000 !important;
    }
}