/* Pool Cleaner Price Tracker Styles - Fixed Dynamic Columns */

/* Color scheme - Lake Blue #4682B4 and Ocean Blue #0077BE */

.pool-cleaner-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-family: Arial, sans-serif;
    font-size: 14px;
    table-layout: auto;
}

.pool-cleaner-table th, .pool-cleaner-table td {
    padding: 8px;
    border: 1px solid #ddd;
    text-align: center;
    vertical-align: top;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pool-cleaner-table th {
    background-color: #f5f5f5;
    font-weight: bold;
    font-size: 13px;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.2;
    padding: 6px 4px;
}

.pool-cleaner-table td {
    white-space: nowrap;
}

/* Specific column width constraints and text wrapping for problematic columns */

/* Column 1: Check Price - Keep original styling */
.pool-cleaner-table th:nth-child(1), .pool-cleaner-table td:nth-child(1) {
    min-width: 120px;
    width: 120px;
    white-space: nowrap;
}

/* Column 2: Brand and Model - Allow wrapping, set max width */
.pool-cleaner-table th:nth-child(2), .pool-cleaner-table td:nth-child(2) {
    max-width: 140px;
    width: 140px;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.2;
}

/* Column 3: Pool Cleaner Category - Allow wrapping, narrow width */
.pool-cleaner-table th:nth-child(3), .pool-cleaner-table td:nth-child(3) {
    max-width: 90px;
    width: 90px;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.2;
}

/* Column 4: Pricing Tier - Keep compact */
.pool-cleaner-table th:nth-child(4), .pool-cleaner-table td:nth-child(4) {
    max-width: 80px;
    width: 80px;
}

/* Column 5: Recommended Pool Size - Prevent awkward text wrapping */
.pool-cleaner-table th:nth-child(5), .pool-cleaner-table td:nth-child(5) {
    max-width: 120px;
    width: 120px;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.2;
}

/* Various other column adjustments */
.pool-cleaner-table th:nth-child(8), .pool-cleaner-table td:nth-child(8),
.pool-cleaner-table th:nth-child(9), .pool-cleaner-table td:nth-child(9),
.pool-cleaner-table th:nth-child(10), .pool-cleaner-table td:nth-child(10),
.pool-cleaner-table th:nth-child(11), .pool-cleaner-table td:nth-child(11) {
    max-width: 100px;
    width: 100px;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.2;
}

.pool-cleaner-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.pool-cleaner-table tr:hover {
    background-color: #f1f1f1;
}

.pool-cleaner-table td a {
    text-decoration: none;
    color: inherit;
}

.check-price-button {
    background-color: #4682B4 !important; /* Lake Blue */
    color: white !important;
    padding: 8px 15px !important;
    border: none !important;
    border-radius: 15px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    display: inline-block !important;
    text-decoration: none !important;
    text-align: center !important;
    transition: background-color 0.3s;
    -webkit-appearance: none;
    appearance: none;
    line-height: 1.5 !important;
    height: auto !important;
    min-width: 100px !important;
    box-sizing: border-box !important;
}

.check-price-button:hover {
    background-color: #3A6D9A !important;
    opacity: 0.9;
}

.responsive-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.pool-cleaner-filter {
    background-color: #f5f5f5;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
    border: 1px solid #ddd;
}

.pool-cleaner-filter h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #000000;
    text-align: center;
}

.filter-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 15px;
}

.filter-left {
    display: flex;
    flex-direction: column;
    width: 75%;
    gap: 15px;
}

.filter-right {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    width: 20%;
    margin-top: 0;
}

/* Row 1: Primary filter (Pool Cleaner Category) centered */
.filter-row-primary {
    display: flex;
    justify-content: center;
    align-items: center;
}

.filter-group-primary {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 300px;
}

.filter-group-primary label {
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
    font-size: 13px;
    text-align: center;
}

.filter-group-primary select {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 14px;
    text-align: center;
    width: 100%;
    min-width: 300px;
}

/* Row 2: Three filters */
.filter-row-secondary {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
    align-items: end;
}

/* Row 3: Two filters + empty space */
.filter-row-tertiary {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
    align-items: end;
}

/* Row 4: Advanced Data Checkbox */
.filter-row-quaternary {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #ddd;
}

.filter-group-checkbox {
    display: flex;
    align-items: center;
}

.filter-group-checkbox label {
    display: flex;
    align-items: center;
    font-weight: bold;
    color: #555;
    font-size: 14px;
    cursor: pointer;
}

.filter-group-checkbox input[type="checkbox"] {
    margin-right: 8px;
    transform: scale(1.2);
}

.filter-group-checkbox input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.filter-group-checkbox label:has(input[type="checkbox"]:disabled) {
    opacity: 0.5;
    cursor: not-allowed;
}

.filter-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 200px;
}

.filter-group label {
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
    font-size: 13px;
    text-align: center;
}

.filter-group select {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    font-size: 14px;
    text-align: center;
    width: 100%;
    min-width: 200px;
}

.filter-group-empty {
    /* Empty space in row 3 */
}

.filter-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 180px;
    position: relative;
    height: 140px;
    margin-top: 45px;
}

.apply-filter-button {
    color: white !important;
    padding: 8px 15px !important;
    border: none !important;
    border-radius: 15px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    display: inline-block !important;
    text-decoration: none !important;
    text-align: center !important;
    transition: background-color 0.3s;
    -webkit-appearance: none;
    appearance: none;
    line-height: 1.5 !important;
    height: auto !important;
    width: 100% !important;
    min-width: 150px !important;
    box-sizing: border-box !important;
    background-color: #0077BE !important; /* Ocean Blue */
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
}

.reset-button {
    color: white !important;
    padding: 8px 15px !important;
    border: none !important;
    border-radius: 15px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    display: inline-block !important;
    text-decoration: none !important;
    text-align: center !important;
    transition: background-color 0.3s;
    -webkit-appearance: none;
    appearance: none;
    line-height: 1.5 !important;
    height: auto !important;
    width: 100% !important;
    min-width: 150px !important;
    box-sizing: border-box !important;
    background-color: #4682B4 !important; /* Lake Blue */
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
}

#loading-indicator {
    font-style: italic;
    color: #666;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
}

.apply-filter-button:hover {
    background-color: #00649E !important;
    opacity: 0.9;
}

.reset-button:hover {
    background-color: #3A6D9A !important;
    opacity: 0.9;
}

/* ===== DYNAMIC COLUMN VISIBILITY LOGIC ===== */

/* CRITICAL FIX: Default state - All columns visible for SEO (no category classes applied) */
.pool-cleaner-table th,
.pool-cleaner-table td {
    display: table-cell;
}

/* When specific category is selected, hide all columns except always-show and category-specific defaults */

/* Robotic Pool Cleaners & Robotic Skimmers - Show robotic default columns only */
.show-robotic .pool-cleaner-table th,
.show-robotic .pool-cleaner-table td {
    display: none; /* Hide all first */
}

.show-robotic .always-show,
.show-robotic .robotic-default {
    display: table-cell !important; /* Show always-show and robotic defaults */
}

/* Robotic + Advanced Data - Also show robotic advanced columns */
.show-robotic.show-advanced .robotic-advanced {
    display: table-cell !important;
}

/* Suction-Side Cleaners - Show suction default columns only */
.show-suction .pool-cleaner-table th,
.show-suction .pool-cleaner-table td {
    display: none; /* Hide all first */
}

.show-suction .always-show,
.show-suction .suction-default {
    display: table-cell !important; /* Show always-show and suction defaults */
}

/* Suction + Advanced Data - Also show suction advanced columns */
.show-suction.show-advanced .suction-advanced {
    display: table-cell !important;
}

/* Pressure-Side Cleaners - Show pressure default columns only */
.show-pressure .pool-cleaner-table th,
.show-pressure .pool-cleaner-table td {
    display: none; /* Hide all first */
}

.show-pressure .always-show,
.show-pressure .pressure-default {
    display: table-cell !important; /* Show always-show and pressure defaults */
}

/* Pressure + Advanced Data - Also show pressure advanced columns */
.show-pressure.show-advanced .pressure-advanced {
    display: table-cell !important;
}

/* Handheld Pool Vacuum - Show handheld default columns only */
.show-handheld .pool-cleaner-table th,
.show-handheld .pool-cleaner-table td {
    display: none; /* Hide all first */
}

.show-handheld .always-show,
.show-handheld .handheld-default {
    display: table-cell !important; /* Show always-show and handheld defaults */
}

/* Handheld + Advanced Data - Also show handheld advanced columns */
.show-handheld.show-advanced .handheld-advanced {
    display: table-cell !important;
}

/* Mobile Responsive */
@media screen and (max-width: 768px) {
    .filter-container {
        flex-direction: column;
        gap: 20px;
    }

    .filter-left {
        width: 100%;
    }

    .filter-right {
        width: 100%;
        justify-content: center;
        margin-top: 0;
    }

    .filter-row-primary {
        justify-content: center;
    }

    .filter-group-primary {
        min-width: 100%;
        max-width: 100%;
    }

    .filter-group-primary select {
        min-width: 100%;
    }

    .filter-row-secondary,
    .filter-row-tertiary {
        display: flex;
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
        min-width: 100%;
        align-items: stretch;
    }

    .filter-group select {
        min-width: 100%;
    }

    .filter-group-empty {
        display: none;
    }

    .filter-row-quaternary {
        justify-content: center;
        margin-top: 15px;
    }

    .filter-actions {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
        align-items: center;
        justify-content: center;
        height: auto;
        margin-top: 0;
        position: static;
        gap: 15px;
    }

    .apply-filter-button, .reset-button {
        position: static !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        width: 100% !important;
        margin: 0 auto;
    }

    #loading-indicator {
        position: static !important;
        bottom: auto !important;
        margin-top: 10px;
    }

    .pool-cleaner-table {
        font-size: 12px;
    }

    .pool-cleaner-table th, .pool-cleaner-table td {
        padding: 6px;
        font-size: 11px;
    }

    .pool-cleaner-table th {
        line-height: 1.1;
        padding: 4px 2px;
    }

    .check-price-button {
        padding: 6px 10px !important;
        font-size: 12px !important;
        min-width: 80px !important;
    }

    /* Mobile adjustments for wrapped columns */
    .pool-cleaner-table th:nth-child(2), .pool-cleaner-table td:nth-child(2),
    .pool-cleaner-table th:nth-child(3), .pool-cleaner-table td:nth-child(3),
    .pool-cleaner-table th:nth-child(8), .pool-cleaner-table td:nth-child(8),
    .pool-cleaner-table th:nth-child(9), .pool-cleaner-table td:nth-child(9),
    .pool-cleaner-table th:nth-child(10), .pool-cleaner-table td:nth-child(10),
    .pool-cleaner-table th:nth-child(11), .pool-cleaner-table td:nth-child(11) {
        min-width: 80px;
        font-size: 10px;
        line-height: 1.1;
    }
}

/* Ensure text in dropdowns is centered */
.filter-group select,
.filter-group-primary select {
    text-align-last: center;
    -moz-text-align-last: center;
    -webkit-text-align-last: center;
}

/* Ensure all dropdowns have consistent width */
.filter-group select,
.filter-group-primary select {
    min-width: 220px;
    max-width: 220px;
}

@media screen and (max-width: 768px) {
    .filter-group select,
    .filter-group-primary select {
        min-width: 100%;
        max-width: 100%;
    }
}

/* Hover effects for table rows */
.pool-cleaner-table tbody tr:hover {
    background-color: #f1f1f1 !important;
    cursor: pointer;
}

/* Styling for empty cells */
.pool-cleaner-table td:empty::after {
    content: "—";
    color: #999;
}