/* ===================================
   CUSTOM TABLE STYLES FOR MOBILE
   - Horizontal scrolling on mobile
   - Dropdown z-index fixes
   - Professional styling
   =================================== */

/* Horizontal Scrollbar for ALL Tables on Mobile */
.table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    display: block;
    width: 100%;
}

/* Custom Scrollbar Styling */
.table-responsive::-webkit-scrollbar {
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #243A8F;
    border-radius: 10px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #1a2a6f;
}

/* Fix Dropdown Z-Index Issue */
.dropdown-menu {
    position: absolute !important;
    z-index: 1050 !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
}

.dropdown.show .dropdown-menu {
    z-index: 9999 !important;
}

.table {
    position: relative;
    z-index: 1;
}

.table tbody {
    position: relative;
    z-index: 1;
}

.table tbody tr {
    position: relative;
    z-index: 1;
}

/* Important: Prevent action buttons from overlapping dropdown */
.table tbody tr .dropdown-toggle {
    position: relative;
    z-index: 10;
}

.table tbody tr.dropdown-row-active {
    z-index: 100 !important;
}

/* When dropdown is open, increase row z-index */
.table tbody tr:has(.dropdown.show) {
    z-index: 100 !important;
    position: relative;
}

.table tbody tr .dropdown.show {
    position: static !important;
    z-index: 9999 !important;
}

.table tbody tr .dropdown.show .dropdown-menu {
    z-index: 9999 !important;
    position: absolute !important;
}

/* Ensure dropdowns don't get cut off at bottom of page */
.table tbody tr:last-child .dropdown,
.table tbody tr:nth-last-child(2) .dropdown {
    position: static;
}

.table tbody tr:last-child .dropdown-menu,
.table tbody tr:nth-last-child(2) .dropdown-menu {
    transform: translateY(-100%);
    top: auto !important;
    bottom: 0 !important;
}

/* Mobile Table Adjustments */
@media (max-width: 768px) {
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: scroll;
    }

    .table {
        min-width: 800px; /* Prevent table from shrinking too much */
        margin-bottom: 0;
    }

    /* Make action buttons smaller on mobile */
    .btn-sm {
        font-size: 0.7rem !important;
        padding: 0.25rem 0.5rem !important;
    }

    /* Dropdown toggle on mobile */
    .dropdown-toggle {
        font-size: 0.7rem !important;
        padding: 0.3rem 0.6rem !important;
    }

    /* Dropdown menu on mobile */
    .dropdown-menu {
        font-size: 0.85rem;
        min-width: 180px;
    }

    /* Table text sizes */
    .table .text-xs {
        font-size: 0.7rem !important;
    }

    .table .text-xxs {
        font-size: 0.65rem !important;
    }

    .table .text-sm {
        font-size: 0.8rem !important;
    }
}

/* Tablet Adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .table {
        min-width: 100%;
    }
}

/* Dropdown Item Hover Effect */
.dropdown-item {
    transition: all 0.2s ease;
    padding: 0.5rem 1rem;
}

.dropdown-item:hover {
    background-color: #f8f9fa;
    padding-left: 1.75rem;
}

/* Dropdown Divider Styling */
.dropdown-divider {
    margin: 0.5rem 0;
    border-top: 1px solid #e9ecef;
}

/* Dropdown Header Styling */
.dropdown-header {
    padding: 0.5rem 1rem;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #243A8F !important;
    background-color: #f8f9fa;
}

/* Icon Colors in Dropdown */
.dropdown-item i.text-primary { color: #3B82F6 !important; }
.dropdown-item i.text-info { color: #0EA5E9 !important; }
.dropdown-item i.text-warning { color: #F59E0B !important; }
.dropdown-item i.text-success { color: #22C55E !important; }
.dropdown-item i.text-secondary { color: #6C757D !important; }
.dropdown-item.text-danger i { color: #EF4444 !important; }

/* Dropdown Menu Styling */
.dropdown-menu {
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.1);
    padding: 0.5rem 0;
}

/* Smooth Transitions */
.btn, .dropdown-toggle {
    transition: all 0.3s ease;
}

/* Card Table Container */
.card .table-responsive {
    border-radius: 0 0 12px 12px;
}

/* Empty State Styling */
.table tbody tr td[colspan] {
    padding: 2rem 1rem;
}

/* Badge Styling in Tables */
.table .badge {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Rajdhani Font for Vehicle/ID Numbers */
.table td h6[style*="Rajdhani"],
.table td .font-weight-bold {
    letter-spacing: 0.5px;
}

/* Print Styles */
@media print {
    .table-responsive {
        overflow-x: visible !important;
    }

    .table {
        min-width: 100% !important;
    }

    .dropdown,
    .btn-group {
        display: none !important;
    }
}

/* Fix for Bootstrap Dropdown in last rows */
.table-responsive .table tbody tr:last-child,
.table-responsive .table tbody tr:nth-last-child(2),
.table-responsive .table tbody tr:nth-last-child(3) {
    position: static;
}

/* Ensure dropdown button visibility */
.dropdown-toggle {
    z-index: 10;
    position: relative;
}

/* Prevent dropdown menu from being hidden behind cards */
.card-body {
    overflow: visible !important;
}

/* Filter Row Mobile Responsiveness */
@media (max-width: 576px) {
    .row.g-2 > * {
        margin-bottom: 0.5rem;
    }

    .form-control-sm,
    .form-select-sm {
        font-size: 0.875rem;
    }
}
