/* Data Table Panel Styles */

#data-table-panel {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Table Controls */
.table-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
    flex: 1 1 520px;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 6px 12px 6px 36px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    color: #374151;
    transition: border-color 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.reset-sort-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.reset-sort-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.reset-sort-btn:active {
    transform: scale(0.98);
}

.reset-sort-btn svg {
    flex-shrink: 0;
}

.search-input::placeholder {
    color: #9ca3af;
}

.page-size-selector {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
    color: #374151;
    background: #ffffff;
    cursor: pointer;
    transition: border-color 0.2s;
}

.page-size-selector:hover {
    border-color: #9ca3af;
}

.page-size-selector:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Export Buttons */
.export-buttons {
    display: flex;
    gap: 6px;
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #ffffff;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
}

.export-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.export-btn svg {
    width: 16px;
    height: 16px;
}

/* Table Wrapper */
.table-wrapper {
    overflow-x: auto;
    margin: -20px;
    padding: 20px;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead {
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    border-bottom: 2px solid #e5e7eb;
}

.data-table th {
    padding: 12px 16px;
    text-align: center;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

.data-table th.sortable:hover {
    background: #f3f4f6;
}

.data-table th.sortable {
    position: relative;
}

.data-table th.sortable i {
    margin-left: 6px;
    color: #9ca3af;
    font-size: 13px;
    transition: color 0.2s;
}

/* Active sorted column - make it prominent */
.data-table th.sorted-asc,
.data-table th.sorted-desc {
    background: #dbeafe !important;
    color: #1e40af;
    font-weight: 700;
}

.data-table th.sorted-asc i,
.data-table th.sorted-desc i {
    color: #2563eb;
    font-weight: 900;
}

/* Legacy support for .sort-icon class */
.data-table th.sortable .sort-icon {
    margin-left: 4px;
    color: #9ca3af;
    font-size: 12px;
}

.data-table th.sorted-asc .sort-icon,
.data-table th.sorted-desc .sort-icon {
    color: #3b82f6;
}

.data-table tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.15s;
}

.data-table tbody tr:hover {
    background: #f9fafb;
}

.data-table tbody tr.highlighted {
    background: #eff6ff;
}

.data-table tbody tr.highlighted:hover {
    background: #dbeafe;
}

.data-table td {
    padding: 12px 16px;
    color: #111827;
}

.table-row {
    cursor: pointer;
}

.rank-cell {
    font-weight: 600;
    color: #6b7280;
    width: 60px;
    text-align: center;
}

.province-cell {
    font-weight: 500;
}

.value-cell {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Total Row Styling */
.data-table tfoot {
    background: #e0f2fe;
    border-top: 2px solid #3b82f6;
    border-bottom: 2px solid #3b82f6;
}

.data-table tfoot tr.total-row td {
    padding: 12px 16px;
    font-weight: 700;
    background-color: #e0f2fe;
    color: #1e40af;
}

.data-table tfoot tr.total-row td.total-label {
    font-size: 14px;
    text-align: center;
    letter-spacing: 0.5px;
    white-space: nowrap;
    min-width: 80px;
}

.data-table tfoot tr.total-row td.total-value {
    font-variant-numeric: tabular-nums;
    text-align: center;
}

/* Table Footer */
.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    gap: 16px;
    flex-wrap: wrap;
}

.table-info {
    font-size: 13px;
    color: #6b7280;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #ffffff;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-btn svg {
    width: 16px;
    height: 16px;
}

.page-numbers {
    display: flex;
    gap: 4px;
}

.page-number-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #ffffff;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
}

.page-number-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.page-number-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #ffffff;
}

/* Loading State */
.table-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: #6b7280;
}

.table-loading .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.table-loading p {
    margin-top: 16px;
    font-size: 14px;
}

/* Empty State */
.table-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: #9ca3af;
}

.table-empty .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.table-empty p {
    font-size: 14px;
}

/* Responsive */
@media (max-width: 768px) {
    .table-controls {
        width: 100%;
    }

    .search-box {
        width: 100%;
        min-width: unset;
    }

    .export-buttons {
        width: 100%;
    }

    .export-btn {
        flex: 1;
        justify-content: center;
    }

    .table-footer {
        flex-direction: column;
        align-items: flex-start;
    }

    .pagination {
        width: 100%;
        justify-content: center;
    }

    .data-table {
        font-size: 13px;
    }

    .data-table th,
    .data-table td {
        padding: 10px 12px;
    }
}

@media (max-width: 480px) {
    .page-numbers {
        max-width: 200px;
        overflow-x: auto;
        scrollbar-width: thin;
    }

    .page-numbers::-webkit-scrollbar {
        height: 4px;
    }

    .page-numbers::-webkit-scrollbar-thumb {
        background: #d1d5db;
        border-radius: 2px;
    }
}
