/**
 * Responsive Styles for Bull Category Archive Pages
 * Applies to all bull category listing pages (beef sires, Australian sires, international sires)
 * Version: 1.0
 */

/* ============================================
   1. RESET BUTTON - Responsive styling
   ============================================ */
#reset-button,
.reset-button,
.reset-filters,
button[id*="reset"],
.angus-button-secondary,
.australian-sires-button-secondary,
.international-sires-button-secondary {
    transition: all 0.3s ease !important;
}

/* ============================================
   2. VIEW AS TABLE BUTTON - Responsive styling
   ============================================ */
.view-as-table,
a.view-as-table,
.view-toggle a,
[class*="view-as-"] {
    display: inline-block !important;
    padding: 8px 16px !important;
    transition: all 0.3s ease !important;
    text-decoration: none !important;
    cursor: pointer !important;
}

.view-as-table.active,
.view-as-grid.active {
    background-color: #003c71 !important;
    color: white !important;
}

/* ============================================
   3. FILTER TOGGLE BUTTON - Mobile/Tablet
   ============================================ */
.filter-toggle-button {
    display: none;
    width: 100%;
    padding: 12px 20px;
    background-color: #003c71;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 15px;
    text-align: left;
    position: relative;
    transition: background-color 0.3s ease;
}

.filter-toggle-button:hover {
    background-color: #1a5090;
}

.filter-toggle-button:after {
    content: '▼';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.3s ease;
}

.filter-toggle-button.active:after {
    transform: translateY(-50%) rotate(180deg);
}

.filter-count-badge {
    display: inline-block;
    background-color: #ff6b6b;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin-left: 8px;
    min-width: 20px;
    text-align: center;
}

/* ============================================
   4. MOBILE RESPONSIVE (768px and below)
   ============================================ */
@media (max-width: 768px) {
    /* Show filter toggle button */
    .filter-toggle-button {
        display: block !important;
    }
    
    /* Reset button - full width on mobile */
    #reset-button,
    .reset-button,
    .reset-filters,
    button[id*="reset"],
    .angus-button-secondary,
    .australian-sires-button-secondary,
    .international-sires-button-secondary {
        width: 100% !important;
        margin: 10px 0 !important;
        padding: 12px 20px !important;
        font-size: 14px !important;
        display: block !important;
        float: none !important;
        clear: both !important;
        box-sizing: border-box !important;
    }
    
    /* View toggle buttons - side by side */
    .view-toggle {
        display: flex !important;
        gap: 10px !important;
        margin: 15px 0 !important;
    }
    
    .view-toggle a,
    .view-as-table,
    .view-as-grid {
        flex: 1 !important;
        text-align: center !important;
        padding: 10px !important;
        margin: 0 !important;
        display: block !important;
        box-sizing: border-box !important;
    }
    
    /* Product grid adjustments */
    .products-grid,
    .angus-products-grid,
    .australian-sires-products-grid,
    .international-sires-products-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    /* Filter sections inside collapsed wrapper */
    .filters-collapsible-wrapper {
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height 0.3s ease, opacity 0.3s ease;
    }
    
    .filters-collapsible-wrapper.expanded {
        max-height: 2000px;
        opacity: 1;
    }
    
    .filters-collapsible-wrapper.collapsed {
        max-height: 0;
        opacity: 0;
    }
    
    /* Ensure filters are properly styled when visible */
    .filters-collapsible-wrapper.expanded .filter-section {
        margin-bottom: 20px !important;
    }
    
    /* Range slider adjustments for mobile */
    .range-slider-container {
        padding: 10px 0 !important;
    }
    
    .irs {
        font-size: 12px !important;
    }
    
    /* Category title adjustments */
    h1.page-title,
    .category-title {
        font-size: 1.8rem !important;
        margin-bottom: 15px !important;
    }
}

/* ============================================
   5. TABLET RESPONSIVE (769px - 992px)
   ============================================ */
@media (min-width: 769px) and (max-width: 992px) {
    /* Show filter toggle button on tablets too */
    .filter-toggle-button {
        display: block !important;
    }
    
    /* Filters collapsible on tablets */
    .filters-collapsible-wrapper {
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height 0.3s ease, opacity 0.3s ease;
    }
    
    .filters-collapsible-wrapper.expanded {
        max-height: 2000px;
        opacity: 1;
    }
    
    /* Product grid - 2 columns on tablet */
    .products-grid,
    .angus-products-grid,
    .australian-sires-products-grid,
    .international-sires-products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
    }
    
    /* Buttons stay inline on tablets */
    #reset-button,
    .reset-button {
        width: auto !important;
        display: inline-block !important;
    }
}

/* ============================================
   6. DESKTOP (993px and above)
   ============================================ */
@media (min-width: 993px) {
    /* Hide filter toggle button on desktop */
    .filter-toggle-button {
        display: none !important;
    }

    /* Ensure filters are visible */
    .filters-collapsible-wrapper {
        max-height: none !important;
        opacity: 1 !important;
        overflow: visible !important;
    }

    /* Product grid - 3 columns on desktop */
    .products-grid,
    .angus-products-grid,
    .australian-sires-products-grid,
    .international-sires-products-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 30px !important;
    }
}

/* ============================================
   6b. LARGE DESKTOP (1500px and above)
   ============================================ */
/* H28 follow-up: now that the data-row + stats block are hidden the
   bull cards are short enough to read well in a 4-up layout on wide
   screens. Below 1500px the rule above still wins (same specificity,
   defined earlier) and we stay at 3 columns. */
@media (min-width: 1500px) {
    .products-grid,
    .angus-products-grid,
    .australian-sires-products-grid,
    .international-sires-products-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 30px !important;
    }
}

/* ============================================
   7. LOADING STATES
   ============================================ */
.products-loading {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.products-loading::after {
    content: 'Loading...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 40px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    font-weight: 600;
    z-index: 10;
}

/* ============================================
   8. ACCESSIBILITY
   ============================================ */
.filter-toggle-button:focus,
.view-as-table:focus,
.view-as-grid:focus,
#reset-button:focus {
    outline: 2px solid #4A90E2;
    outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   9. ACTIVE FILTER INDICATORS
   ============================================ */
.filter-section.has-active-filter {
    border-left: 3px solid #4CAF50;
    padding-left: 12px;
    background-color: rgba(76, 175, 80, 0.05);
}

.filter-toggle-button.has-active-filters {
    background-color: #4CAF50;
}

.filter-toggle-button.has-active-filters:hover {
    background-color: #45a049;
}

/* ============================================
   10. PRINT STYLES
   ============================================ */
@media print {
    .filter-toggle-button,
    .filters-collapsible-wrapper,
    .view-toggle,
    #reset-button {
        display: none !important;
    }
}