/* Responsive Tables */

.table-responsive-custom {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Table Stack on Mobile */
@media (max-width: 768px) {
    .table-stack {
        border: 0;
    }

    .table-stack thead {
        display: none;
    }

    .table-stack tbody {
        display: block;
        width: 100%;
    }

    .table-stack tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 6px;
        overflow: hidden;
    }

    .table-stack td {
        display: block;
        text-align: right;
        padding: 10px;
        border: none;
        border-bottom: 1px solid #f1f1f1;
        position: relative;
        padding-left: 50%;
    }

    .table-stack td:before {
        content: attr(data-label);
        position: absolute;
        left: 6px;
        font-weight: 600;
        text-transform: uppercase;
        font-size: 12px;
        color: #666;
    }

    .table-stack td:last-child {
        border-bottom: none;
    }

    /* Dark mode table stack */
    body.dark-mode .table-stack tr {
        border-color: #30363d;
    }

    body.dark-mode .table-stack td {
        border-bottom-color: #30363d;
    }

    body.dark-mode .table-stack td:before {
        color: #8b949e;
    }
}

/* Horizontal Scroll Indicator */
.table-responsive::-webkit-scrollbar {
    height: 6px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #555;
}

body.dark-mode .table-responsive::-webkit-scrollbar-track {
    background: #30363d;
}

body.dark-mode .table-responsive::-webkit-scrollbar-thumb {
    background: #6e7681;
}

/* Sticky Table Headers */
.table-sticky-header thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: white;
}

body.dark-mode .table-sticky-header thead {
    background-color: #161b22;
}

/* Expandable Table Rows */
.table-expandable tbody tr {
    cursor: pointer;
}

.table-expandable tbody tr:hover {
    background-color: #f5f5f5;
}

body.dark-mode .table-expandable tbody tr:hover {
    background-color: #1c2128;
}

.table-expandable .expand-row {
    display: none;
}

.table-expandable .expand-row.show {
    display: table-row;
}

.table-expandable .expand-content {
    background-color: #f9f9f9;
    padding: 15px;
    border-left: 3px solid #003366;
}

body.dark-mode .table-expandable .expand-content {
    background-color: #0d1117;
    border-left-color: #1f6feb;
}

/* Compact Table */
.table-compact {
    font-size: 12px;
}

.table-compact th,
.table-compact td {
    padding: 6px 8px;
}

/* Condensed Table */
.table-condensed {
    margin-bottom: 0;
}

.table-condensed th,
.table-condensed td {
    padding: 4px;
}

/* Striped Table */
.table-striped-custom tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02);
}

body.dark-mode .table-striped-custom tbody tr:nth-of-type(odd) {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Bordered Table Improvements */
.table-bordered-custom {
    border: 1px solid #ddd;
}

.table-bordered-custom thead th {
    border-bottom: 2px solid #ddd;
}

.table-bordered-custom tbody td {
    border-right: 1px solid #ddd;
}

.table-bordered-custom tbody td:last-child {
    border-right: none;
}

body.dark-mode .table-bordered-custom {
    border-color: #30363d;
}

body.dark-mode .table-bordered-custom thead th {
    border-bottom-color: #30363d;
}

body.dark-mode .table-bordered-custom tbody td {
    border-right-color: #30363d;
}

/* Hover Table */
.table-hover tbody tr {
    transition: background-color 0.2s ease;
}

.table-hover tbody tr:hover {
    background-color: #f1f1f1;
}

body.dark-mode .table-hover tbody tr:hover {
    background-color: #1c2128;
}

/* Small Text in Tables */
.table small {
    font-size: 11px;
    color: #666;
}

body.dark-mode .table small {
    color: #8b949e;
}

/* Badge in Tables */
.table .badge {
    display: inline-block;
    white-space: nowrap;
}

/* Action Buttons in Tables */
.table .btn-group-sm {
    display: flex;
    gap: 4px;
}

.table .btn-action {
    padding: 4px 8px;
    font-size: 11px;
}

/* Dropdown in Tables */
.table .dropdown-toggle::after {
    display: none;
}

.table .dropdown-toggle {
    font-size: 12px;
}

/* Checkbox in Tables */
.table input[type="checkbox"] {
    cursor: pointer;
}

.table thead input[type="checkbox"] {
    cursor: pointer;
}

/* Fixed Column Tables */
.table-fixed {
    table-layout: fixed;
    width: 100%;
}

.table-fixed td {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Vertical Align */
.table .align-middle {
    vertical-align: middle;
}

.table .align-top {
    vertical-align: top;
}

.table .align-bottom {
    vertical-align: bottom;
}

/* Column Width Classes */
.col-xs { width: 40px; }
.col-sm { width: 80px; }
.col-md { width: 120px; }
.col-lg { width: 150px; }

/* Mobile Specific Table Styles */
@media (max-width: 480px) {
    .table-stack td {
        padding: 8px;
        font-size: 12px;
    }

    .table-stack td:before {
        font-size: 11px;
    }

    .table-compact {
        font-size: 11px;
    }

    .table-compact th,
    .table-compact td {
        padding: 4px 6px;
    }

    .btn-action {
        padding: 3px 6px !important;
        font-size: 10px !important;
    }
}

/* Print Styles */
@media print {
    .table-responsive {
        overflow: visible;
    }

    .table-responsive > .table {
        display: table;
    }

    .table-stack {
        display: table;
    }

    .table-stack thead {
        display: table-header-group;
    }

    .table-stack tbody {
        display: table-row-group;
    }

    .table-stack tr {
        display: table-row;
        page-break-inside: avoid;
    }

    .table-stack td {
        display: table-cell;
        border: 1px solid #ddd;
    }

    .table-stack td:before {
        display: none;
    }
}
