/* Excel-like table sorting and filtering */
.excel-table {
    position: relative;
}

/* Minimum table height - always show at least 5 rows */
.excel-table tbody {
    min-height: 250px; /* Approximately 5 rows × 50px each */
    display: table-row-group;
}

.excel-table tbody tr {
    min-height: 50px;
}

.excel-table tbody tr td {
    vertical-align: middle;
    padding: 12px 8px;
}

/* Empty rows styling when less than 5 rows of data */
.excel-table tbody tr.empty-row {
    height: 50px;
    background-color: #fdfdfd;
    border-bottom: 1px solid #f0f0f0;
}

.excel-table tbody tr.empty-row td {
    border-left: 1px solid #f0f0f0;
    border-right: 1px solid #f0f0f0;
    background-color: transparent;
    color: transparent;
    padding: 12px 8px;
}

.excel-table tbody tr.empty-row:hover {
    background-color: #f8f9fa;
}

/* Ensure consistent row height for all rows */
.excel-table tbody tr {
    height: 50px;
}

.excel-table tbody tr td {
    height: 50px;
    box-sizing: border-box;
}

.excel-table th {
    position: relative;
    padding-right: 20px !important;
    cursor: pointer;
    user-select: none;
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

.excel-table th:hover {
    background-color: #e9ecef;
}

/* Excel-style dropdown arrow - single arrow in top-right corner */
.excel-table th .excel-dropdown-arrow {
    position: absolute;
    right: 4px;
    top: 4px;
    width: 20px;
    height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    /* REAL-TIME TRANSITIONS: Smooth color changes for hierarchy */
    transition: all 0.3s ease-in-out;
}

.excel-table th .excel-dropdown-arrow:hover {
    background-color: #dee2e6;
}

.excel-table th .excel-dropdown-arrow.active {
    background-color: #0d6efd;
}

.excel-table th .excel-dropdown-arrow::after {
    content: '▼';
    font-size: 14px;
    color: #6c757d;
    line-height: 1;
}

.excel-table th .excel-dropdown-arrow:hover::after {
    color: #495057;
}

.excel-table th .excel-dropdown-arrow.active::after {
    color: white;
}

/* Sort indicators on dropdown arrow */
.excel-table th .excel-dropdown-arrow.sort-asc::after {
    content: '▲';
    color: #0d6efd;
}

.excel-table th .excel-dropdown-arrow.sort-desc::after {
    content: '▼';
    color: #0d6efd;
}

/* Hide old controls */
.excel-table th .table-header-controls,
.excel-table th .sort-arrow,
.excel-table th .filter-dropdown-btn {
    display: none;
}

/* Sort indicators with hierarchy - Primary (1st level) */
.excel-table th.sort-asc.sort-primary .excel-dropdown-arrow::after {
    content: '1▲';
    color: #ffffff;
    font-weight: bold;
    text-shadow: 0 0 3px rgba(13, 110, 253, 0.8);
    font-size: 10px;
}

.excel-table th.sort-desc.sort-primary .excel-dropdown-arrow::after {
    content: '1▼';
    color: #ffffff;
    font-weight: bold;
    text-shadow: 0 0 3px rgba(13, 110, 253, 0.8);
    font-size: 10px;
}

.excel-table th.sort-primary .excel-dropdown-arrow {
    background-color: #0d6efd !important;
    border-color: #0a58ca !important;
    box-shadow: 0 0 5px rgba(13, 110, 253, 0.5);
}

/* Sort indicators with hierarchy - Secondary (2nd level) */
.excel-table th.sort-asc.sort-secondary .excel-dropdown-arrow::after {
    content: '2▲';
    color: #ffffff;
    font-weight: normal;
    font-size: 10px;
}

.excel-table th.sort-desc.sort-secondary .excel-dropdown-arrow::after {
    content: '2▼';
    color: #ffffff;
    font-weight: normal;
    font-size: 10px;
}

.excel-table th.sort-secondary .excel-dropdown-arrow {
    background-color: #6c757d !important;
    border-color: #5c636a !important;
}

/* Sort indicators with hierarchy - Tertiary (3rd level) */
.excel-table th.sort-asc.sort-tertiary .excel-dropdown-arrow::after {
    content: '3▲';
    color: #ffffff;
    font-weight: normal;
    opacity: 0.8;
    font-size: 10px;
}

.excel-table th.sort-desc.sort-tertiary .excel-dropdown-arrow::after {
    content: '3▼';
    color: #ffffff;
    font-weight: normal;
    opacity: 0.8;
    font-size: 10px;
}

.excel-table th.sort-tertiary .excel-dropdown-arrow {
    background-color: #adb5bd !important;
    border-color: #9ca3af !important;
}

/* Sort indicators with hierarchy - Quaternary (4th+ level) */
.excel-table th.sort-asc.sort-quaternary .excel-dropdown-arrow::after {
    content: '4+▲';
    color: #6c757d;
    font-weight: normal;
    opacity: 0.6;
    font-size: 9px;
}

.excel-table th.sort-desc.sort-quaternary .excel-dropdown-arrow::after {
    content: '4+▼';
    color: #6c757d;
    font-weight: normal;
    opacity: 0.6;
    font-size: 9px;
}

.excel-table th.sort-quaternary .excel-dropdown-arrow {
    background-color: #e9ecef !important;
    border-color: #dee2e6 !important;
}

/* Hover effects for sorted columns */
.excel-table th.sort-primary .excel-dropdown-arrow:hover {
    background-color: #0b5ed7 !important;
    transform: scale(1.05);
}

.excel-table th.sort-secondary .excel-dropdown-arrow:hover {
    background-color: #5c636a !important;
    transform: scale(1.05);
}

.excel-table th.sort-tertiary .excel-dropdown-arrow:hover {
    background-color: #9ca3af !important;
    transform: scale(1.05);
}

.excel-table th.sort-quaternary .excel-dropdown-arrow:hover {
    background-color: #dee2e6 !important;
    transform: scale(1.05);
}

/* Filtered column indicator */
.excel-table th.filtered {
    background-color: #e3f2fd;
}

.excel-table th.filtered .excel-dropdown-arrow {
    background-color: #2196f3;
}

.excel-table th.filtered .excel-dropdown-arrow::after {
    color: white;
}

/* Excel-style filter dropdown */
.filter-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #ccc;
    box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    min-width: 180px;
    max-height: 250px;
    overflow-y: auto;
    display: none;
    font-size: 12px;
}

.filter-dropdown.show {
    display: block;
}

/* Excel-style filter options */
.filter-option {
    padding: 4px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-option:hover {
    background-color: #e6f3ff;
}

.filter-option input[type="checkbox"] {
    margin: 0;
    width: 13px;
    height: 13px;
}

.filter-option label {
    cursor: pointer;
    margin: 0;
    flex: 1;
}

/* Top action bar with icons */
.dropdown-top-bar {
    display: flex;
    gap: 3px;
    padding: 4px 6px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #ccc;
    justify-content: flex-start;
}

.icon-btn {
    min-width: 28px;
    height: 24px;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
    font-size: 11px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    padding: 0 4px;
    white-space: nowrap;
}

.icon-btn:hover {
    background: #e6f3ff;
    border-color: #0066cc;
}

.icon-btn.ok-btn {
    background: #0066cc;
    color: white;
    border-color: #0066cc;
}

.icon-btn.ok-btn:hover {
    background: #0052a3;
}

.icon-btn.cancel-btn {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
    min-width: 50px;
    font-size: 9px;
}

.icon-btn.cancel-btn:hover {
    background: #c82333;
    border-color: #bd2130;
}

/* Clear filters bar in dropdown menu - Węższy i WYRAZISTY zielony */
.clear-filters-bar {
    background: linear-gradient(135deg, #4caf50 0%, #43a047 100%);
    border: 1px solid #388e3c;
    border-radius: 3px;
    padding: 4px 8px;
    margin: 0 0 6px 0;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: #ffffff;
    position: relative;
    overflow: hidden;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.clear-filters-bar:hover {
    background: linear-gradient(135deg, #66bb6a 0%, #4caf50 100%);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(76, 175, 80, 0.4);
    color: #ffffff;
    border-color: #2e7d32;
}

.clear-filters-bar:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(76, 175, 80, 0.5);
    background: linear-gradient(135deg, #43a047 0%, #388e3c 100%);
}

.clear-filters-bar i {
    margin-right: 4px;
    font-size: 10px;
}

.clear-filters-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    transition: left 0.4s;
}

.clear-filters-bar:hover::before {
    left: 100%;
}

/* Dropdown separator */
.dropdown-separator {
    height: 1px;
    background-color: #ccc;
    margin: 4px 0;
}

/* Search box */
.filter-search {
    padding: 6px 8px;
    border-bottom: 1px solid #ccc;
}

.filter-search input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #ccc;
    border-radius: 2px;
    font-size: 11px;
}

/* Filter options container */
.filter-options-container {
    max-height: 150px;
    overflow-y: auto;
}

/* Kaskadowe filtrowanie - informacja */
.cascade-info {
    padding: 4px 8px;
    background-color: #e6f3ff;
    border-bottom: 1px solid #ccc;
    font-size: 10px;
    color: #0066cc;
    font-style: italic;
}

.select-all-option {
    border-bottom: 1px solid #ddd;
    background-color: #f8f9fa;
    font-weight: 500;
}





/* Row highlighting for filtered results */
.excel-table tbody tr.filtered-out {
    display: none;
}

.excel-table tbody tr.highlight {
    background-color: #fff3cd;
}

/* Loading state */
.excel-table.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .excel-table th {
        padding-right: 25px !important;
    }
    
    .filter-dropdown {
        min-width: 180px;
        right: -20px;
    }
}

/* Mobile-specific styles for better table readability */
@media (max-width: 768px) {
    /* Excel table mobile improvements */
    .excel-table {
        background-color: #ffffff !important;
    }
    
    .excel-table th {
        background-color: #ffffff !important;
        color: #000000 !important;
        border-bottom: 2px solid #000000 !important;
        font-weight: 700 !important;
    }
    
    .excel-table th:hover {
        background-color: #f0f8ff !important;
        color: #000000 !important;
    }
    
    .excel-table tbody tr {
        background-color: #ffffff !important;
    }
    
    .excel-table tbody tr td {
        background-color: #ffffff !important;
        color: #000000 !important;
        border-bottom: 1px solid #cccccc !important;
    }
    
    .excel-table tbody tr:hover {
        background-color: #f0f8ff !important;
    }
    
    .excel-table tbody tr:hover td {
        background-color: #f0f8ff !important;
        color: #000000 !important;
    }
    
    /* Empty rows mobile styling */
    .excel-table tbody tr.empty-row {
        background-color: #ffffff !important;
        border-bottom: 1px solid #eeeeee !important;
    }
    
    .excel-table tbody tr.empty-row td {
        background-color: #ffffff !important;
        border-left: 1px solid #eeeeee !important;
        border-right: 1px solid #eeeeee !important;
    }
    
    .excel-table tbody tr.empty-row:hover {
        background-color: #f8f9fa !important;
    }
    
    .excel-table tbody tr.empty-row:hover td {
        background-color: #f8f9fa !important;
    }
    
    /* Dropdown arrow mobile improvements */
    .excel-table th .excel-dropdown-arrow {
        background-color: #ffffff !important;
        border: 1px solid #cccccc !important;
    }
    
    .excel-table th .excel-dropdown-arrow:hover {
        background-color: #f0f8ff !important;
        border-color: #0066cc !important;
    }
    
    .excel-table th .excel-dropdown-arrow::after {
        color: #000000 !important;
    }
    
    .excel-table th .excel-dropdown-arrow:hover::after {
        color: #0066cc !important;
    }
    
    /* Filter dropdown mobile improvements */
    .filter-dropdown {
        background-color: #ffffff !important;
        border: 2px solid #000000 !important;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3) !important;
    }
    
    .filter-option {
        color: #000000 !important;
        background-color: #ffffff !important;
    }
    
    .filter-option:hover {
        background-color: #f0f8ff !important;
        color: #0066cc !important;
    }
    
    .filter-option label {
        color: #000000 !important;
    }
    
    .filter-option:hover label {
        color: #0066cc !important;
    }
    
    /* Top action bar mobile improvements */
    .dropdown-top-bar {
        background-color: #f8f9fa !important;
        border-bottom: 2px solid #000000 !important;
    }
    
    .icon-btn {
        background-color: #ffffff !important;
        color: #000000 !important;
        border: 2px solid #cccccc !important;
    }
    
    .icon-btn:hover {
        background-color: #f0f8ff !important;
        color: #0066cc !important;
        border-color: #0066cc !important;
    }
    
    .icon-btn.ok-btn {
        background-color: #0066cc !important;
        color: #ffffff !important;
        border-color: #0066cc !important;
    }
    
    .icon-btn.ok-btn:hover {
        background-color: #0052a3 !important;
    }
    
    .icon-btn.cancel-btn {
        background-color: #dc3545 !important;
        color: #ffffff !important;
        border-color: #dc3545 !important;
    }
    
    .icon-btn.cancel-btn:hover {
        background-color: #c82333 !important;
    }
    
    /* Clear filters bar mobile improvements */
    .clear-filters-bar {
        background: #28a745 !important;
        color: #ffffff !important;
        border: 2px solid #1e7e34 !important;
    }
    
    .clear-filters-bar:hover {
        background: #218838 !important;
        color: #ffffff !important;
        border-color: #1e7e34 !important;
    }
    
    /* Search box mobile improvements */
    .filter-search {
        background-color: #ffffff !important;
        border-bottom: 2px solid #000000 !important;
    }
    
    .filter-search input {
        background-color: #ffffff !important;
        color: #000000 !important;
        border: 2px solid #cccccc !important;
    }
    
    .filter-search input:focus {
        border-color: #0066cc !important;
        box-shadow: 0 0 0 0.2rem rgba(0, 102, 204, 0.25) !important;
    }
    
    /* Cascade info mobile improvements */
    .cascade-info {
        background-color: #e6f3ff !important;
        color: #0066cc !important;
        border-bottom: 2px solid #cccccc !important;
    }
    
    .select-all-option {
        background-color: #f8f9fa !important;
        color: #000000 !important;
        border-bottom: 2px solid #cccccc !important;
    }
    
    /* Filtered column indicator mobile */
    .excel-table th.filtered {
        background-color: #e3f2fd !important;
        color: #000000 !important;
    }
    
    .excel-table th.filtered .excel-dropdown-arrow {
        background-color: #2196f3 !important;
        border-color: #1976d2 !important;
    }
    
    .excel-table th.filtered .excel-dropdown-arrow::after {
        color: #ffffff !important;
    }
}

/* Custom scrollbar for filter dropdown - WebKit only */
@supports (-webkit-appearance: none) {
    .filter-dropdown::-webkit-scrollbar {
        width: 6px;
    }

    .filter-dropdown::-webkit-scrollbar-track {
        background: #f1f1f1;
    }

    .filter-dropdown::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 3px;
    }

    .filter-dropdown::-webkit-scrollbar-thumb:hover {
        background: #a8a8a8;
    }
}