/* Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

body {
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
}

/* Application Loading Screen Styles */
.app-loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    animation: fadeIn 0.5s ease-in;
}

.loading-content {
    text-align: center;
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    width: 90%;
}

.loading-spinner-large {
    width: 60px;
    height: 60px;
    border: 6px solid #e9ecef;
    border-top: 6px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px auto;
}

.loading-content h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.4rem;
    font-weight: 600;
}

.loading-content p {
    color: #666;
    margin-bottom: 20px;
    font-size: 14px;
}

.loading-progress-container {
    margin-top: 20px;
}

.loading-progress-bar-large {
    width: 100%;
    height: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.loading-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.loading-percentage {
    font-size: 14px;
    font-weight: 600;
    color: #007bff;
}

/* Ready to Search Indicator */
.ready-indicator {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    margin: 0 20px 20px 20px;
    animation: slideDown 0.5s ease-out;
}

.ready-content {
    display: flex;
    align-items: center;
    padding: 15px 20px;
}

.ready-checkmark {
    font-size: 24px;
    color: #28a745;
    margin-right: 15px;
    font-weight: bold;
}

.ready-content h3 {
    color: #155724;
    margin: 0 0 5px 0;
    font-size: 1.1rem;
}

.ready-content p {
    color: #155724;
    margin: 0;
    font-size: 14px;
}

/* Search container disabled state */
.search-container.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Header */
.header {
    background: linear-gradient(135deg, #0062cc, #1e88e5);
    color: white;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.header h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 300;
}

.header p {
    margin-top: 10px;
    opacity: 0.9;
}

/* Search Container */
.search-container {
    background-color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 0 20px 20px 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    transition: opacity 0.3s ease;
}

label {
    font-weight: 600;
    color: #555;
}

input[type="text"] {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    flex: 1;
    min-width: 200px;
    max-width: 400px;
    transition: all 0.2s ease;
}

input[type="text"]:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

input[type="text"]:disabled {
    background-color: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
}

button:hover:not(:disabled) {
    background-color: #0056b3;
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

#clear-btn {
    background-color: #6c757d;
}

#clear-btn:hover {
    background-color: #545b62;
}

.download-all-btn {
    background-color: #28a745;
    margin-left: auto;
}

.download-all-btn:hover:not(:disabled) {
    background-color: #218838;
}

/* Clear Filters Button */
.clear-filters-btn {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.clear-filters-btn:hover {
    background-color: #c82333;
}

/* Loading hint styles */
.keyboard-hints span {
    color: #666;
    font-size: 12px;
}

.keyboard-hints .ready-hint {
    color: #28a745;
    font-weight: 600;
}

/* Status Message */
.status-count {
    background-color: #e3f2fd;
    color: #0d47a1;
    padding: 10px 20px;
    border-radius: 4px;
    margin: 0 20px 20px 20px;
    display: none;
    font-weight: 500;
}

/* Loading Indicators */
.loading {
    display: none;
    text-align: center;
    padding: 20px;
    font-style: italic;
    color: #666;
}

.no-results {
    background-color: #fff3cd;
    color: #856404;
    padding: 15px 20px;
    border-radius: 4px;
    margin: 20px;
    display: none;
}

/* Data Loading Status - Hidden from UI */
.data-status {
    display: none !important;
}

/* Progress Bar Styles */
.loading-progress-bar {
    width: 100%;
    height: 4px;
    background-color: #e0e0e0;
    border-radius: 2px;
    margin-top: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3);
    width: 0%;
    transition: width 0.2s ease;
    border-radius: 2px;
}

.search-btn-processing {
    opacity: 0.6;
    pointer-events: none;
    background-color: #6c757d !important;
}

/* Excel-like Table Styles */
.results-table-container {
    margin: 0 20px 20px 20px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
    background: white;
    display: none;
    position: relative; /* Important for filter positioning */
}

.excel-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 14px;
    table-layout: fixed;
}

.excel-table thead {
    background-color: #f2f2f2;
    position: sticky;
    top: 0;
    z-index: 10;
}

.excel-table th {
    background-color: #0062cc;
    color: white;
    font-weight: 600;
    text-align: left;
    padding: 12px 15px;
    border-right: 1px solid #e0e0e0;
    white-space: nowrap;
    position: relative;
}

.excel-table th:last-child {
    border-right: none;
}

/* Column width adjustments */
.excel-table th:nth-child(1) { width: 12%; }
.excel-table th:nth-child(2) { width: 20%; }
.excel-table th:nth-child(3) { width: 12%; }
.excel-table th:nth-child(4) { width: 12%; }
.excel-table th:nth-child(5) { width: 15%; }
.excel-table th:nth-child(6) { width: 15%; }
.excel-table th:nth-child(7) { width: 14%; }

.excel-table td {
    padding: 10px 15px;
    border-bottom: 1px solid #e0e0e0;
    border-right: 1px solid #e0e0e0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.excel-table td:last-child {
    border-right: none;
}

.excel-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.excel-table tbody tr:hover {
    background-color: #f2f8ff;
}

.excel-table-empty {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}

/* FIXED Column Filter Styles */
.column-filter-btn {
    background: none;
    border: none;
    color: white;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    margin-left: 8px;
    border-radius: 3px;
    transition: all 0.2s;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 11;
}

.column-filter-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.column-filter-btn.filter-active {
    background-color: rgba(255, 255, 255, 0.3);
}

.column-filter-btn.filter-applied {
    background-color: #28a745;
    color: white;
}

.column-filter-btn.filter-applied:hover {
    background-color: #218838;
}

/* COMPLETELY REWRITTEN Filter Dropdowns */
.filter-dropdowns-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.filter-dropdown {
    display: none;
    position: absolute;
    background: white;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 280px;
    max-height: 400px;
    pointer-events: all;
    font-size: 14px;
    z-index: 101;
    color: #333;
    overflow: hidden;
}

/* Desktop filter positioning is handled by JavaScript */

.filter-dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid #eee;
    background-color: #f8f9fa;
    border-radius: 6px 6px 0 0;
}

.filter-dropdown-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}


.filter-close-btn:hover {
    color: #333;
}

.filter-search-container {
    padding: 12px 14px;
    border-bottom: 1px solid #eee;
}

.filter-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
    color: #333;
}

.filter-search:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}

.filter-actions {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid #eee;
}

.filter-select-all,
.filter-clear-all,
.filter-apply-btn {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    color: #333;
}

.filter-apply-btn {
    background-color: #007bff;
    color: white;
    border: 1px solid #007bff;
}

.filter-apply-btn:hover {
    background-color: #0056b3;
    border-color: #0056b3;
}

.filter-select-all:hover,
.filter-clear-all:hover {
    background-color: #f8f9fa;
    border-color: #007bff;
}

.filter-values-container {
    max-height: 170px !important;
    overflow-y: auto;
    padding: 8px 0;
}

.filter-value-item {
    padding: 2px 14px;
}

.filter-value-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 6px 0;
    font-size: 13px;
    line-height: 1.4;
    color: #333;
}

.filter-value-label:hover {
    background-color: #f8f9fa;
}

.filter-value-checkbox {
    margin-right: 8px;
    cursor: pointer;
}

.filter-value-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #333;
}

.filter-value-count {
    margin-left: 8px;
    color: #666;
    font-size: 11px;
}

.filter-no-values {
    padding: 20px 14px;
    text-align: center;
    color: #666;
    font-style: italic;
}



/* Mobile Filter Modal - Only active on mobile */
.filter-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 8998;
    cursor: pointer;
    animation: fadeIn 0.2s ease;
}

.mobile-filter-modal {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: calc(100vw - 30px) !important;
    max-width: 380px !important;
    max-height: 80vh !important;
    z-index: 8999 !important;
    border-radius: 12px !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3) !important;
    overflow: hidden !important;
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 20px;
    padding: 15px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.top-pagination {
    display: none;
}

.rows-per-page-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rows-per-page-control label {
    font-size: 14px;
    white-space: nowrap;
}

.rows-per-page-selector {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    font-size: 14px;
}

.pagination-button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.pagination-button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.page-info {
    color: #666;
    font-size: 14px;
}

/* Error states */
.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 15px 20px;
    border-radius: 4px;
    margin: 20px;
    border: 1px solid #f5c6cb;
}

.warning-message {
    background-color: #fff3cd;
    color: #856404;
    padding: 15px 20px;
    border-radius: 4px;
    margin: 20px;
    border: 1px solid #ffeaa7;
}

.success-message {
    background-color: #d4edda;
    color: #155724;
    padding: 15px 20px;
    border-radius: 4px;
    margin: 20px;
    border: 1px solid #c3e6cb;
}

/* Loading states */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from { 
        opacity: 0;
        transform: translateY(-20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Keyboard shortcuts hint */
.keyboard-hints {
    font-size: 12px;
    color: #666;
    margin-top: 10px;
    text-align: center;
}

/* Scrollbar styling */
.filter-values-container::-webkit-scrollbar {
    width: 6px;
}

.filter-values-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.filter-values-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.filter-values-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* RESPONSIVE DESIGN */
@media (max-width: 1200px) {
    .excel-table {
        font-size: 13px;
    }
    
    .excel-table th,
    .excel-table td {
        padding: 8px 12px;
    }
    
    .filter-dropdown {
        width: 260px;
        max-height: 350px;
    }
}

@media (max-width: 900px) {
    .excel-table {
        font-size: 12px;
    }
    
    .excel-table th,
    .excel-table td {
        padding: 6px 8px;
    }
    
    .excel-table th:nth-child(1) { width: 10%; }
    .excel-table th:nth-child(2) { width: 18%; }
    .excel-table th:nth-child(3) { width: 10%; }
    .excel-table th:nth-child(4) { width: 10%; }
    .excel-table th:nth-child(5) { width: 14%; }
    .excel-table th:nth-child(6) { width: 14%; }
    .excel-table th:nth-child(7) { width: 24%; }
    
    .filter-dropdown {
        width: 240px;
        max-height: 300px;
    }
    
    .column-filter-btn {
        font-size: 10px;
        padding: 2px 4px;
        margin-left: 4px;
    }
}

/* MOBILE STYLES - 768px and below */
@media (max-width: 768px) {
    .search-container {
        flex-direction: column;
    }
    
    input[type="text"] {
        max-width: none;
    }
    
    .excel-table {
        font-size: 11px;
        min-width: 700px;
    }
    
    .excel-table th,
    .excel-table td {
        padding: 4px 6px;
    }
    
    .pagination-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .download-all-btn {
        margin-left: 0;
        width: 100%;
    }
    
    .results-table-container {
        overflow-x: auto;
    }
    
    /* Mobile Filter Enhancements */
    .mobile-filter-modal .filter-dropdown-header {
        padding: 18px !important;
        border-radius: 12px 12px 0 0 !important;
    }
    
    .mobile-filter-modal .filter-dropdown-header h4 {
        font-size: 17px !important;
        font-weight: 600 !important;
    }
    
    .mobile-filter-modal .filter-close-btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 20px !important;
        background-color: rgba(0, 0, 0, 0.05) !important;
    }
    
    .mobile-filter-modal .filter-search-container {
        padding: 18px !important;
    }
    
    .mobile-filter-modal .filter-search {
        padding: 14px !important;
        font-size: 16px !important; /* Prevent iOS zoom */
        border-radius: 8px !important;
    }
    
    .mobile-filter-modal .filter-actions {
        padding: 18px !important;
        gap: 14px !important;
    }
    
    .mobile-filter-modal .filter-select-all,
    .mobile-filter-modal .filter-clear-all {
        padding: 12px !important;
        font-size: 15px !important;
        font-weight: 500 !important;
        border-radius: 8px !important;
        min-height: 44px !important;
    }
    
    .mobile-filter-modal .filter-values-container {
        max-height: 28vh !important;
        padding: 10px 0 !important;
    }
    
    .mobile-filter-modal .filter-value-item {
        padding: 6px 18px !important;
    }
    
    .mobile-filter-modal .filter-value-label {
        padding: 14px 0 !important;
        font-size: 15px !important;
        min-height: 48px !important;
    }
    
    .mobile-filter-modal .filter-value-checkbox {
        margin-right: 14px !important;
        transform: scale(1.3) !important;
    }
    
    .mobile-filter-modal .filter-actions .filter-apply-btn {
        padding: 12px 16px !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        min-height: 44px !important;
        border-radius: 6px !important;
    }
    
    .loading-content {
        padding: 30px 20px;
        margin: 20px;
    }
    
    .ready-content {
        flex-direction: column;
        text-align: center;
    }
    
    .ready-checkmark {
        margin: 0 0 10px 0;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5rem;
    }
    
    .search-container {
        margin: 0 10px 10px 10px;
        padding: 10px;
    }
    
    .status-count,
    .no-results {
        margin: 0 10px 10px 10px;
    }
    
    .results-table-container {
        margin: 0 10px 10px 10px;
    }
    
    .pagination-controls {
        margin: 10px;
        padding: 10px;
    }
    
    .loading-content {
        padding: 25px 15px;
    }
    
    .loading-spinner-large {
        width: 50px;
        height: 50px;
        border-width: 5px;
    }
    
    .loading-content h3 {
        font-size: 1.2rem;
    }
    
    .mobile-filter-modal {
        width: calc(100vw - 20px) !important;
        max-width: none !important;
    }
    
    .mobile-filter-modal .filter-dropdown-header,
    .mobile-filter-modal .filter-search-container,
    .mobile-filter-modal .filter-actions {
        padding: 16px !important;
    }
    
    .mobile-filter-modal .filter-dropdown-header h4 {
        font-size: 16px !important;
    }
}