/* Custom Table Styles - Excel-like compact table with consistent row heights */
/* Reusable across all admin pages */

/* Base table styles (all screens) */
.custom-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 0;
}

/* Mobile table styles */
@media (max-width: 768px) {
    .custom-table thead {
        display: none;
    }

    .custom-table tbody tr {
        display: block;
        margin-bottom: 0.75rem;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        background: white;
        padding: 0.75rem;
    }

    .custom-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.5rem 0;
        border: none !important;
        font-size: 0.85rem;
    }

    .custom-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #666;
        margin-right: 1rem;
        font-size: 0.8rem;
    }

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

/* Desktop custom table style */
@media (min-width: 769px) {
    .custom-table {
        font-size: 0.75rem !important;
    }

    /* Header */
    .custom-table thead tr {
        background: linear-gradient(135deg, #007B8A 0%, #005F6B 100%) !important;
    }
    .custom-table thead th {
        color: #fff !important;
        font-weight: 600 !important;
        font-size: 0.72rem !important;
        text-transform: uppercase !important;
        letter-spacing: 0.6px !important;
        padding: 0.65rem 0.85rem !important;
        border: none !important;
        white-space: nowrap !important;
        background: transparent !important;
    }
    .custom-table thead th:first-child {
        border-top-left-radius: 0 !important;
    }
    .custom-table thead th:last-child {
        border-top-right-radius: 0 !important;
    }

    /* Body rows */
    .custom-table tbody tr {
        border-bottom: 1px solid #eef0f3 !important;
        transition: background 0.15s ease, transform 0.15s ease;
        height: 38px !important;
    }
    .custom-table tbody tr:nth-child(even) {
        background-color: #f7fbfc !important;
    }
    .custom-table tbody tr:nth-child(odd) {
        background-color: #ffffff !important;
    }
    .custom-table tbody tr:hover {
        background-color: #e8f5f7 !important;
        transform: none;
    }
    .custom-table tbody tr:last-child {
        border-bottom: none !important;
    }

    /* Cells */
    .custom-table tbody td {
        padding: 0.2rem 0.85rem !important;
        vertical-align: middle !important;
        border: none !important;
        color: #343a40 !important;
    }

    /* Left accent on hover */
    .custom-table tbody tr:hover td:first-child {
        border-left: 3px solid #007B8A !important;
    }

    /* Checkbox column */
    .custom-table .col-check {
        width: 42px !important;
        text-align: center !important;
    }

    /* Number columns */
    .custom-table .col-num {
        text-align: center !important;
        font-weight: 600 !important;
        color: #007B8A !important;
    }

    /* Actions column */
    .custom-table .col-actions {
        width: 110px !important;
        text-align: center !important;
    }

    /* Subtle divider between header and body */
    .custom-table tbody tr:first-child td {
        border-top: 2px solid #e0f0f2 !important;
    }
}

/* Table row hover effect */
.table-row-hover {
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.table-row-hover:hover {
    background-color: #f8f9fa !important;
    transform: translateX(5px);
    border-left-color: #007B8A;
}

/* Table overflow fixes for dropdowns */
.table-responsive {
    overflow: visible !important;
}

tbody {
    overflow: visible !important;
}

table {
    overflow: visible !important;
}

/* Dropdown positioning in table cells */
td:last-child {
    position: relative;
    overflow: visible !important;
}

td:last-child .btn-group {
    position: relative;
}

/* Dropdown positioning - use fixed to escape table overflow constraints */
td:last-child .dropdown-menu {
    position: fixed !important;
    z-index: 99999 !important;
    max-height: 70vh;
    overflow-y: auto;
    margin-top: 0.125rem;
}

/* Calculate dropdown position dynamically */
td:last-child .dropdown-menu.show {
    position: fixed !important;
}

/* Position above when near bottom */
td:last-child .dropdown-menu.dropup {
    margin-top: 0;
    margin-bottom: 0.125rem;
}

/* Card overflow fixes */
.card.shadow-sm {
    overflow: visible !important;
}

.card.shadow-sm .table {
    overflow: visible !important;
}

.card-body {
    overflow: visible !important;
}
