/**
 * AK Pagecreator Table Block - Default Styles
 * Using :where() for lowest specificity - easily overridable by themes
 */

/* Base table styles */
:where(.akpc-table) {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    background-color: transparent;
}

:where(.akpc-table th),
:where(.akpc-table td) {
    padding: 0.75rem;
    vertical-align: top;
    border-top: 1px solid #dee2e6;
    text-align: left;
}

:where(.akpc-table thead th) {
    vertical-align: bottom;
    border-bottom: 2px solid #dee2e6;
    font-weight: bold;
    background-color: #f8f9fa;
}

:where(.akpc-table tbody + tbody) {
    border-top: 2px solid #dee2e6;
}

/* Striped rows variant */
:where(.akpc-table--striped tbody tr:nth-of-type(odd)) {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Bordered table variant */
:where(.akpc-table--bordered .akpc-table) {
    border: 1px solid #dee2e6;
}

:where(.akpc-table--bordered th),
:where(.akpc-table--bordered td) {
    border: 1px solid #dee2e6;
}

:where(.akpc-table--bordered thead th),
:where(.akpc-table--bordered thead td) {
    border-bottom-width: 2px;
}

/* Hover effect variant */
:where(.akpc-table--hover tbody tr:hover) {
    background-color: rgba(0, 0, 0, 0.075);
}

/* Compact table variant */
:where(.akpc-table--compact th),
:where(.akpc-table--compact td) {
    padding: 0.3rem;
}

/* Sortable table variant */
:where(.akpc-table--sortable th.sortable) {
    cursor: pointer;
    user-select: none;
    position: relative;
}

:where(.akpc-table--sortable th.sortable:hover) {
    background-color: #e9ecef;
}

:where(.akpc-table--sortable .sort-indicator) {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.3;
}

:where(.akpc-table--sortable .sort-indicator):before {
    content: "↕";
}

:where(.akpc-table--sortable th.sortable.sort-asc .sort-indicator):before {
    content: "↑";
    opacity: 1;
}

:where(.akpc-table--sortable th.sortable.sort-desc .sort-indicator):before {
    content: "↓";
    opacity: 1;
}

/* Responsive: Default (horizontal scroll) */
:where(.akpc-table--default) {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

:where(.akpc-table--default table) {
    min-width: 100%;
}

/* Responsive: Stack columns on mobile */
@media (max-width: 767px) {
    :where(.akpc-table--stack) {
        border: 0;
    }
    
    :where(.akpc-table--stack thead) {
        display: none;
    }
    
    :where(.akpc-table--stack tr) {
        display: block;
        border: 1px solid #ccc;
        margin-bottom: 10px;
        padding: 10px;
        border-radius: 4px;
    }
    
    :where(.akpc-table--stack td) {
        display: block;
        text-align: right;
        border: none;
        border-bottom: 1px solid #eee;
        padding: 10px 0;
    }
    
    :where(.akpc-table--stack td):before {
        content: attr(data-label) ": ";
        float: left;
        font-weight: bold;
        text-transform: uppercase;
    }
    
    :where(.akpc-table--stack td:last-child) {
        border-bottom: 0;
    }
}

/* Responsive: Collapse to accordion on mobile */
@media (max-width: 767px) {
    :where(.akpc-table--collapse .akpc-table) {
        display: none;
    }
    
    :where(.table-accordion) {
        display: none;
    }

	:where(.akpc-table--collapse .akpc-table + .table-accordion) {
		display: block;
	}
    
    :where(.table-accordion-item) {
        border: 1px solid #ddd;
        margin-bottom: 5px;
        border-radius: 4px;
    }
    
    :where(.table-accordion-header) {
        background-color: #f5f5f5;
        padding: 10px 15px;
        cursor: pointer;
        font-weight: bold;
        border-bottom: 1px solid #ddd;
    }
    
    :where(.table-accordion-header):after {
        content: "+";
        float: right;
    }
    
    :where(.table-accordion-header.active):after {
        content: "-";
    }
    
    :where(.table-accordion-content) {
        display: none;
        padding: 15px;
    }
    
    :where(.table-accordion-content.active) {
        display: block;
    }
    
    :where(.table-accordion-row) {
        margin-bottom: 10px;
        padding-bottom: 10px;
        border-bottom: 1px solid #eee;
    }
    
    :where(.table-accordion-row:last-child) {
        border-bottom: none;
        margin-bottom: 0;
    }
    
    :where(.table-accordion-cell) {
        display: block;
        margin-bottom: 5px;
    }
    
    :where(.table-accordion-cell strong) {
        display: inline-block;
        min-width: 100px;
        font-weight: bold;
    }
}

@media (min-width: 768px) {
    :where(.table-accordion) {
        display: none !important;
    }
}