.csv-search-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.csv-search-form {
    text-align: center;
    margin: 0 auto 30px auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.search-inputs {
    margin: 0 auto 20px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
    max-width: 600px;
}

.discount-inputs {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 20px auto 0 auto;
    flex-wrap: wrap;
    width: 100%;
    max-width: 500px;
}

.discount-field {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 200px;
}

.discount-field label {
    font-weight: 500;
    color: #495057;
    margin-bottom: 8px;
    font-size: 14px;
}

.discount-input {
    width: 100%;
    max-width: 150px;
    padding: 10px 15px;
    font-size: 14px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    text-align: center;
}

.discount-input:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

.csv-search-input {
    width: 70%;
    max-width: 500px;
    padding: 15px 20px;
    font-size: 16px;
    border: 2px solid #e1e5e9;
    border-radius: 25px;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    margin: 0;
}

.csv-search-input:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

.csv-search-button {
    padding: 15px 25px;
    font-size: 16px;
    background-color: #007cba;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.csv-search-button:hover {
    background-color: #005a87;
    transform: translateY(-1px);
}

.csv-search-button:active {
    transform: translateY(0);
}

.csv-search-loading {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

.csv-search-results {
    margin-top: 30px;
}

.results-summary {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    color: #495057;
}

.results-summary p {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}

.discount-info {
    font-size: 14px !important;
    color: #007cba !important;
    font-weight: 400 !important;
    margin-top: 8px !important;
}

.results-table {
    overflow-x: auto;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    position: relative;
}

/* Replace arrowed helper text with a concise swipe hint (mobile-only) */
.results-table::after {
    display: none !important;
}

/* Mobile swipe hint element - hidden by default, shown on small screens */
.mobile-swipe-hint {
    display: none;
    text-align: center;
    font-size: 13px;
    color: #6c757d;
    background-color: rgba(248,249,250,0.95);
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 8px;
    width: auto;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 768px) {
    .mobile-swipe-hint {
        display: block !important;
    }
    
    /* Force absolute centering on mobile */
    .csv-search-container {
        text-align: center !important;
    }
    
    .csv-search-form {
        text-align: center !important;
    }
    
    .search-inputs {
        text-align: center !important;
    }
    
    .csv-search-input {
        text-align: center !important;
    }
}

.results-table table {
    width: 100%;
    min-width: 100%;
    border-collapse: collapse;
    background-color: white;
    table-layout: fixed;
}

.results-table th {
    background-color: #f8f9fa;
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
    cursor: pointer;
    position: relative;
    user-select: none;
    font-size: 14px;
}

.results-table th:hover {
    background-color: #e9ecef;
}

.results-table th.sortable::after {
    content: ' ↕';
    opacity: 0.5;
    font-size: 12px;
}

.results-table th.sort-asc::after {
    content: ' ↑';
    opacity: 1;
    color: #007cba;
}

.results-table th.sort-desc::after {
    content: ' ↓';
    opacity: 1;
    color: #007cba;
}

.results-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #e9ecef;
    color: #212529;
    font-size: 14px;
    line-height: 1.3;
}

/* Optimize column widths - using percentages for full width */
.results-table th:nth-child(1), /* VSSCo Description */
.results-table td:nth-child(1) {
    width: 25%;
    min-width: 180px;
}

.results-table th:nth-child(2), /* Supplier */
.results-table td:nth-child(2) {
    width: 12%;
    min-width: 100px;
}

.results-table th:nth-child(3), /* LIST PRICE */
.results-table td:nth-child(3) {
    width: 8%;
    min-width: 70px;
    text-align: center;
}

.results-table th:nth-child(4), /* SYMBIO Disc */
.results-table td:nth-child(4) {
    width: 8%;
    min-width: 70px;
    text-align: center;
}

.results-table th:nth-child(5), /* Active Ingredient */
.results-table td:nth-child(5) {
    width: 17%;
    min-width: 130px;
}

/* Price columns */
.results-table th:nth-child(6), /* Net Price */
.results-table td:nth-child(6) {
    width: 10%;
    min-width: 100px;
}

.results-table th:nth-child(7), /* 2x Net Price */
.results-table td:nth-child(7) {
    width: 10%;
    min-width: 100px;
}

.results-table th:nth-child(8), /* 3x Net Price */
.results-table td:nth-child(8) {
    width: 10%;
    min-width: 100px;
}

.results-table tr:hover {
    background-color: #f8f9fa;
}

.no-results {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-size: 16px;
    background-color: #f8f9fa;
    border-radius: 8px;
}

.csv-pagination {
    text-align: center;
    margin-top: 20px;
}

.pagination-info {
    margin-bottom: 15px;
    color: #6c757d;
    font-size: 14px;
}

.pagination-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.page-link {
    display: inline-block;
    padding: 8px 12px;
    text-decoration: none;
    color: #007cba;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    transition: all 0.3s ease;
    min-width: 40px;
    text-align: center;
}

.page-link:hover {
    background-color: #007cba;
    color: white;
    border-color: #007cba;
    text-decoration: none;
}

.current-page {
    display: inline-block;
    padding: 8px 12px;
    background-color: #007cba;
    color: white;
    border: 1px solid #007cba;
    border-radius: 4px;
    min-width: 40px;
    text-align: center;
    font-weight: 500;
}

/* Preferred row styling: make preferred items visually bold and underlined */
.preferred-row,
.preferred-row td {
    font-weight: 700 !important;
    color: #111 !important;
    text-decoration: underline !important;
    text-decoration-thickness: 2px !important;
    text-underline-offset: 3px !important;
}

/* Keep price-cell styling but ensure bold/underline carries through */
.preferred-row .price-cell {
    font-weight: 700 !important;
}

/* Key text shown above the results table to explain preferred styling */
.preferred-key {
    text-align: left;
    margin: 8px 12px 10px 12px;
    font-size: 14px;
    color: #495057;
    background: rgba(255,255,255,0.9);
}

/* Responsive design */
@media (max-width: 768px) {
    /* Prevent any element from making the page wider than viewport */
    * {
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }
    .csv-search-container {
        padding: 15px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    .csv-search-form {
        width: 100%;
        margin: 0 0 30px 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
    }
    
    .search-inputs {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 15px;
        width: 100%;
        margin: 0 0 20px 0;
        padding: 0;
    }
    
    .csv-search-input {
        width: 100%;
        margin: 0;
        padding: 15px 20px;
        text-align: center;
        box-sizing: border-box;
    }
    
    .csv-search-button {
        width: 100%;
        margin: 0;
        box-sizing: border-box;
    }
    
    .results-table {
        font-size: 14px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        width: 100% !important;
        max-width: 100vw !important;
        margin-bottom: 20px !important;
        box-sizing: border-box !important;
    }
    
    .results-table table {
        min-width: 800px !important; /* Ensure table doesn't get too compressed */
        table-layout: auto !important; /* Allow natural column sizing */
        width: auto !important;
    }
    
    .results-table th,
    .results-table td {
        padding: 8px 6px !important;
        white-space: nowrap !important; /* Prevent text wrapping in cells */
    }
    
    .pagination-links {
        gap: 5px;
    }
    
    .page-link,
    .current-page {
        padding: 6px 8px;
        min-width: 35px;
        font-size: 14px;
    }
}

/* Loading animation */
.csv-search-loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Search highlighting */
.highlighted {
    background-color: #fff3cd;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
    color: #856404;
}

/* Result row styling based on relevance */
.result-row[data-relevance="10"] {
    border-left: 4px solid #28a745; /* High relevance - exact match */
}

.result-row[data-relevance="3"] {
    border-left: 4px solid #ffc107; /* Medium relevance - partial match */
}

/* Enhanced table styling for better readability */
.results-table tr:nth-child(even) {
    background-color: #f8f9fa;
}

.results-table tr:nth-child(even):hover {
    background-color: #e9ecef;
}

/* Better spacing for larger result sets */
.results-table td {
    vertical-align: top;
    line-height: 1.4;
}

/* Improved pagination for larger result sets */
.pagination-links {
    margin-top: 20px;
}

.pagination-info {
    font-weight: 500;
    color: #495057;
}

/* Price column styling */
.price-column {
    background-color: #e3f2fd !important;
    color: #1565c0 !important;
    font-weight: 600 !important;
    text-align: center !important;
    font-size: 13px !important;
    padding: 12px 8px !important;
}

.price-cell {
    text-align: center !important;
    font-weight: 500 !important;
    color: #2e7d32 !important;
    background-color: #f1f8e9 !important;
    border-left: 2px solid #4caf50 !important;
    font-size: 13px !important;
    padding: 10px 8px !important;
}

/* Responsive adjustments for discount inputs */
@media (max-width: 768px) {
    .discount-inputs {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 15px;
        width: 100%;
        max-width: 300px;
        margin: 20px auto 0 auto;
    }
    
    .discount-field {
        min-width: 250px;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .discount-input {
        max-width: 200px;
        width: 100%;
        text-align: center;
    }
    
    .results-table {
        table-layout: auto;
    }
    
    .price-column {
        font-size: 11px;
        padding: 8px 4px !important;
    }
    
    .price-cell {
        font-size: 11px;
        padding: 6px 4px !important;
    }
    
    .results-table th,
    .results-table td {
        padding: 6px 4px;
        font-size: 12px;
    }
    
    /* Adjust column widths for mobile */
    .results-table th:nth-child(1), /* VSSCo Description */
    .results-table td:nth-child(1) {
        width: 25%;
        min-width: 120px;
    }
    
    .results-table th:nth-child(2), /* Supplier */
    .results-table td:nth-child(2) {
        width: 12%;
        min-width: 80px;
    }
    
    .results-table th:nth-child(3), /* LIST PRICE */
    .results-table td:nth-child(3) {
        width: 10%;
        min-width: 70px;
    }
    
    .results-table th:nth-child(4), /* SYMBIO Disc */
    .results-table td:nth-child(4) {
        width: 10%;
        min-width: 70px;
    }
    
    .results-table th:nth-child(5), /* Active Ingredient */
    .results-table td:nth-child(5) {
        width: 18%;
        min-width: 100px;
    }
    
    .results-table th:nth-child(6), /* Net Price */
    .results-table td:nth-child(6) {
        width: 8%;
        min-width: 80px;
    }
    
    .results-table th:nth-child(7), /* 2x Net Price */
    .results-table td:nth-child(7) {
        width: 8%;
        min-width: 80px;
    }
    
    .results-table th:nth-child(8), /* 3x Net Price */
    .results-table td:nth-child(8) {
        width: 8%;
        min-width: 80px;
    }
}

@media (max-width: 480px) {
    .csv-search-container {
        padding: 10px;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
    
    .csv-search-form {
        width: 100% !important;
        margin: 0 0 30px 0 !important;
        padding: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        box-sizing: border-box !important;
    }
    
    .search-inputs {
        width: 100% !important;
        margin: 0 0 20px 0 !important;
        padding: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        box-sizing: border-box !important;
    }
    
    .csv-search-input {
        width: 100% !important;
        margin: 0 !important;
        padding: 15px 20px !important;
        text-align: center !important;
        box-sizing: border-box !important;
    }
    
    .csv-search-button {
        width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }
    
    .discount-inputs {
        width: 100% !important;
        max-width: 300px !important;
        margin: 20px auto 0 auto !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
    }
    
    .results-table {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        width: 100% !important;
        max-width: 100vw !important;
        margin-bottom: 20px !important;
        box-sizing: border-box !important;
    }
    
    .results-table table {
        min-width: 700px !important; /* Slightly smaller for very small screens */
        table-layout: auto !important;
        width: auto !important;
    }
    
    .results-table th,
    .results-table td {
        padding: 4px 2px !important;
        font-size: 11px !important;
        white-space: nowrap !important;
    }
    
    .price-column {
        font-size: 10px;
        padding: 6px 2px !important;
    }
    
    .price-cell {
        font-size: 10px;
        padding: 4px 2px !important;
    }
}