/* Angus Page Styles - No Divi Dependencies */
/* Version: 1.2 - Updated for WooCommerce integration */

/* Main Layout */
.angus-page-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 30px 5px;
    box-sizing: border-box;
    clear: both;
    overflow-x: hidden;
    width: 100%;
}

/* Ensure the content area takes full width */
.tax-product_cat.term-angus #primary.content-area,
.tax-product_cat.term-angus .content-area {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
}

.tax-product_cat.term-angus #main.site-main,
.tax-product_cat.term-angus .site-main {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Override WooCommerce styles */
.tax-product_cat.term-angus .woocommerce-products-header {
    display: none;
}

.tax-product_cat.term-angus .woocommerce-breadcrumb {
    display: none;
}

.angus-page-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 0px;
    width: 100%;
    clear: both;
}

.angus-sidebar {
    width: 25%;
    padding: 0 15px;
    box-sizing: border-box;
}

.angus-main-content {
    width: 75%;
    padding: 0 15px;
    box-sizing: border-box;
}

.angus-page-title {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 28px;
    color: #333;
}

/* Filters Sidebar */
.angus-filters {
    background-color: #f5f5f5;
    padding: 20px;
    border-radius: 5px;
    margin-bottom: 30px;
}

.angus-filters h3 {
    font-size: 22px;
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
}

/* Filter Sections */
.filter-section {
    margin-bottom: 5px;
}

.filter-section h4 {
    font-size: 16px;
    margin-bottom: 0px;
    color: #444;
}

/* Range Sliders */
.range-slider-container {
    padding: 5px 0;
}

.range-slider {
    height: 5px;
    background: #ddd;
    border-radius: 5px;
    position: relative;
    margin: 15px 0;
}

.range-values {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #666;
}

/* Filter Buttons */
.filter-buttons {
    display: flex;
    justify-content: center;
    margin-top: 30px;
}

.angus-button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem; /* 14px based on 16px base */
    background-color: #003c71;
    color: white;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.3s ease;
}

.angus-button:hover {
    background-color: #0d2b4a;
}

.angus-button-secondary {
    background-color: #f0f0f0;
    color: #333;
}

.angus-button-secondary:hover {
    background-color: #e0e0e0;
}

/* Filter Message */
.filter-message {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #4CAF50;
    color: white;
    padding: 8px 15px;
    border-radius: 4px;
    font-size: 0.875rem; /* 14px based on 16px base */
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 100;
    animation: fadeIn 0.3s ease;
}

.filter-note {
    text-align: center;
    margin-top: 10px;
    color: #666;
    font-style: italic;
}

.filter-note p {
    margin: 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Filtering Indicator */
.filtering-indicator {
    position: absolute;
    top: 0;
    right: 15px;
    background-color: #003c71;
    color: white;
    padding: 8px 15px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 100;
    animation: fadeIn 0.2s ease;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
}

.filtering-indicator::before {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.5);
    border-top: 2px solid white;
    border-radius: 50%;
    margin-right: 8px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* View and Sort Options */
.view-sort-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.view-toggle a {
    display: inline-block;
    padding: 8px 15px;
    background-color: white;
    color: #003c71;
    border: 1px solid #003c71;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    font-weight: bold;
    transition: background-color 0.2s, color 0.2s;
    margin-right: 10px;
    cursor: pointer; /* Explicit cursor for Safari */
    -webkit-tap-highlight-color: rgba(22, 65, 112, 0.2); /* Safari touch feedback */
    -webkit-touch-callout: none; /* Disable Safari callout */
    touch-action: manipulation; /* Prevent zoom on double-tap */
    position: relative;
    z-index: 10; /* Ensure clickable on Safari */
}

.view-toggle a:last-child {
    margin-right: 0;
}

.view-toggle a.active {
    background-color: #003c71;
    color: white;
}

.view-toggle a:hover {
    background-color: #f0f0f0;
}

.sorting-options {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* Search box in sorting options */
.angus-search-box {
    display: flex;
    align-items: center;
    margin-left: 15px;
    position: relative;
    flex: 1;
    max-width: 300px;
}

.angus-search-box input[type="text"] {
    padding: 8px 15px;
    padding-right: 60px; /* Space for the buttons */
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 100%;
    font-size: 14px;
    transition: all 0.3s ease;
    background-color: #f9f9f9;
}

.angus-search-box input[type="text"]:focus {
    border-color: #003c71;
    outline: none;
    box-shadow: 0 0 0 2px rgba(22, 65, 112, 0.2);
    background-color: #fff;
}

.angus-search-box button {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0;
    font-size: 14px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.angus-search-box button:hover {
    color: #003c71;
}

.angus-search-box .clear-search {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 0;
    font-size: 14px;
    width: 20px;
    height: 20px;
    display: none;
    align-items: center;
    justify-content: center;
}

.angus-search-box .clear-search:hover {
    color: #333;
}

/* Filtering indicator */
.filtering-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: rgba(22, 65, 112, 0.9);
    color: white;
    padding: 10px 15px;
    border-radius: 4px;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    font-size: 14px;
    max-width: 300px;
}

.sort-option {
    padding: 8px 15px;
    background-color: #f0f0f0;
    color: #333;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s ease;
}

.sort-option.active {
    background-color: #003c71;
    color: white;
}

/* Products Grid */
.angus-products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    justify-items: center;
}

/* Ensure 4 columns only on large screens */
@media (min-width: 1800px) {
    .angus-products-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .angus-product-card {
        max-width: 340px;
    }
}

/* No results state */
.angus-products-grid.no-results {
    display: none;
}

/* No products message */
.no-products-message {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin: 30px 0;
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    z-index: 10;
    clear: both;
    font-size: 18px;
    color: #333;
    font-weight: 500;
}

/* Product Card */
.angus-product-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background-color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

.angus-product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.product-header-link {
    text-decoration: none;
    display: block;
    transition: opacity 0.3s ease;
}

.product-header-link:hover {
    opacity: 0.9;
}

.product-header {
    background-color: #003c71;
    padding: 15px 3px;
    text-align: center;
    border-bottom: 1px solid #e0e0e0;
}

.product-header h3 {
    color: white;
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    text-transform: uppercase;
}

.product-image {
    height: auto;
    overflow: hidden;
    border-bottom: 1px solid #e0e0e0;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Price and Select Button Container */
.product-price-container {
    display: flex;
    align-items: center;
    background-color: #d9eaf9;
    border-bottom: 1px solid #e0e0e0;
    padding: 10px;
}

.product-price {
    flex: 1;
    text-align: left;
    font-size: 18px;
    font-weight: 700;
    color: #003c71;
}

.product-price .inc-gst {
    font-size: 14px;
    font-weight: 400;
}

.product-select-button {
    margin-left: 10px;
}

.select-options-btn {
    background-color: #9fdacc;
    color: #003c71;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    display: inline-block;
}

.select-options-btn:hover {
    background-color: #8bc9ba;
    color: #0d2b4a;
}

.product-sire {
    padding: 12px;
    text-align: center;
    border-bottom: 1px solid #e0e0e0;
    background-color: #f5f5f5;
    width: 100%;
}

.product-sire .sire-label {
    font-weight: 600;
    font-style: italic;
    margin-right: 5px;
}

.product-sire .sire-value {
    font-weight: 700;
}

.product-stats {
    padding: 0;
    background-color: #fff;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    border: 1px solid #e0e0e0;
    border-top: none;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px 5px;
    border-right: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    height: 55px;
    text-align: center;
    position: relative;
}

/* Remove borders for last column and last row */
.stat-item:nth-child(3n) {
    border-right: none;
}

.stat-item:nth-child(n+10) {
    border-bottom: none;
}

.stat-label {
    font-size: 10px;
    color: #333;
    margin-bottom: 2px;
    font-weight: 600;
    text-transform: uppercase;
    line-height: 1;
}

.stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #003c71;
    line-height: 1;
}

/* Alternating background colors for 12 fields (4 rows x 3 columns) */
/* Row 1: CE Dir (blue), CE Dtr (green), GL (blue) */
.stat-item:nth-child(1) {
    background-color: #b9d7f8;
}

.stat-item:nth-child(2) {
    background-color: #9fdacc;
}

.stat-item:nth-child(3) {
    background-color: #b9d7f8;
}

/* Row 2: BW (green), 200D (blue), 400D (green) */
.stat-item:nth-child(4) {
    background-color: #9fdacc;
}

.stat-item:nth-child(5) {
    background-color: #b9d7f8;
}

.stat-item:nth-child(6) {
    background-color: #9fdacc;
}

/* Row 3: 600D (blue), SC (green), DTC (blue) */
.stat-item:nth-child(7) {
    background-color: #b9d7f8;
}

.stat-item:nth-child(8) {
    background-color: #9fdacc;
}

.stat-item:nth-child(9) {
    background-color: #b9d7f8;
}

/* Row 4: CW (green), EMA (blue), %IMF (green) */
.stat-item:nth-child(10) {
    background-color: #9fdacc;
}

.stat-item:nth-child(11) {
    background-color: #b9d7f8;
}

.stat-item:nth-child(12) {
    background-color: #9fdacc;
}

/* Ensure text colors work well with both backgrounds */
.stat-item .stat-value {
    color: #003c71;
}

/* Product actions removed - Select Options button moved to price container */

/* Table View */
.angus-table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin-top: 20px;
    display: none; /* Hidden by default */
}

/* Real data table style - Updated to match Australian Sires design */
.angus-data-table {
    width: 100%;
    margin-top: 20px;
    background-color: white;
    border-radius: 8px;
    overflow-x: auto; /* Changed from hidden to auto for horizontal scrolling */
    overflow-y: visible;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    display: none;
    border-collapse: collapse;
    font-size: 0.875rem; /* 14px based on 16px base */
}

.angus-data-table.visible {
    display: block !important;
}

.angus-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem; /* 14px based on 16px base */
}

.angus-table thead {
    background-color: #003c71;
    color: white;
}

.angus-table th {
    padding: 15px 10px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #0d2b4a;
}

/* First header cell (Title) */
.angus-data-table thead th.column-title {
    text-align: left;
    padding-left: 10px;
}

/* Sortable column headers */
.angus-data-table thead th.sortable {
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: background-color 0.2s ease;
}

.angus-data-table thead th.sortable:hover {
    background-color: #444;
}

.angus-data-table thead th.sortable .sort-indicator {
    margin-left: 8px;
    font-size: 14px;
    opacity: 0.5;
    display: inline-block;
    transition: all 0.2s ease;
    font-weight: normal;
}

.angus-data-table thead th.sortable:hover .sort-indicator {
    opacity: 0.8;
}

/* Hide the default indicator text when sorted */
.angus-data-table thead th.sorted-asc .sort-indicator,
.angus-data-table thead th.sorted-desc .sort-indicator {
    font-size: 0;
    opacity: 1;
}

/* Show only ascending arrow when sorted ascending */
.angus-data-table thead th.sorted-asc .sort-indicator::after {
    content: '▲';
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 3px rgba(255,255,255,0.5);
}

/* Show only descending arrow when sorted descending */
.angus-data-table thead th.sorted-desc .sort-indicator::after {
    content: '▼';
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 3px rgba(255,255,255,0.5);
}

/* Table Body */
.angus-table td {
    padding: 12px 10px;
    border-bottom: 1px solid #e0e0e0;
    vertical-align: middle;
}

.angus-table tbody tr:hover {
    background-color: #f8f9fa;
}

.angus-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.angus-table tbody tr:nth-child(even):hover {
    
}

/* Column styling - Updated to match Australian Sires design */
.column-title {
    font-weight: 600;
    color: #003c71;
}

.column-image img {
    width: 60px;
    height: auto;
    border-radius: 4px;
}

.column-price {
    font-weight: 600;
    color: #00a77e;
}

.column-actions .select-options {
    background-color: #003c71;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    display: inline-block;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
}

.column-actions .select-options:hover {
    background-color: #0d2b4a;
}

.no-results-row td {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

/* Search and filter area */
.angus-table-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 15px;
    gap: 10px;
}

.angus-table-search {
    display: flex;
    align-items: center;
}

.angus-table-search input[type="text"] {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px 0 0 4px;
    width: 200px;
}

.angus-table-search button {
    background-color: #003c71;
    color: white;
    border: none;
    padding: 7px 12px;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
}

.angus-table-search button:hover {
    background-color: #0d2b4a;
}

/* Table Rows */
.angus-products-grid.table-view .angus-product-card {
    display: table-row;
    border: none;
    box-shadow: none;
    width: 100%;
}

.angus-products-grid.table-view .angus-product-card:hover {
    transform: none;
    box-shadow: none;
}

.angus-products-grid.table-view .angus-product-card:nth-child(odd) {
    background-color: #f9f9f9;
}

.angus-products-grid.table-view .angus-product-card:nth-child(even) {
    background-color: #ffffff;
}

/* Table Cells */
.angus-products-grid.table-view .product-header,
.angus-products-grid.table-view .product-image,
.angus-products-grid.table-view .product-price,
.angus-products-grid.table-view .product-sire,
.angus-products-grid.table-view .product-stats,
.angus-products-grid.table-view .product-actions {
    display: table-cell;
    vertical-align: middle;
    padding: 10px;
    border: 1px solid #e0e0e0;
    height: 80px;
}

/* Bull Name Cell */
.angus-products-grid.table-view .product-header {
    background-color: #003c71;
    width: 15%;
    text-align: center;
}

.angus-products-grid.table-view .product-header h3 {
    color: white;
    font-size: 14px;
    margin: 0;
}

/* Image Cell */
.angus-products-grid.table-view .product-image {
    width: 10%;
    height: 80px;
    text-align: center;
}

.angus-products-grid.table-view .product-image img {
    max-height: 70px;
    width: auto;
    object-fit: contain;
}

/* PERFORMANCE: Lazy loading styles */
.lazy-load {
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.lazy-loaded {
    opacity: 1;
}

/* PERFORMANCE: Staged loading indicators */
.stage-loading-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #003c71;
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    z-index: 10000;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.stage-loading-indicator.visible {
    opacity: 1;
    transform: translateY(0);
}

.stage-loading-indicator .spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Auto-loading indicator */
.auto-loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #666;
    font-size: 14px;
    background: #f9f9f9;
    border-radius: 8px;
    margin-top: 10px;
}

.auto-loading-indicator .spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(22, 65, 112, 0.3);
    border-top: 2px solid #003c71;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

/* PERFORMANCE: Pagination styles */
.products-pagination {
    margin: 0px 0;
    text-align: center;
    padding: 0px;
    background: #f9f9f9;
    border-radius: 8px;
}

/* Legacy support for angus-pagination */
.angus-pagination {
    margin: 5px 0;
    text-align: center;
    padding: 5px;
    background: #f9f9f9;
    border-radius: 8px;
}

.pagination-info {
    margin-bottom: 20px;
}

.pagination-info p {
    color: #666;
    font-size: 14px;
    margin: 0;
}

.load-more-btn {
    background: #003c71;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.load-more-btn:hover:not(:disabled) {
    background: #0f2d4f;
}

.load-more-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.traditional-pagination {
    margin-top: 20px;
}

.traditional-pagination a,
.traditional-pagination span {
    display: inline-block;
    padding: 8px 12px;
    margin: 0 4px;
    text-decoration: none;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.traditional-pagination a:hover {
    background: #003c71;
    color: white;
    border-color: #003c71;
}

.traditional-pagination .current {
    background: #003c71;
    color: white;
    border-color: #003c71;
}

/* Video styles for product cards - Performance optimized */
.angus-card-video-container {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 0px;
    overflow: hidden;
    will-change: transform; /* GPU acceleration hint */
    transform: translateZ(0); /* Force hardware acceleration */
}

.angus-card-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 0px;
    will-change: transform; /* GPU acceleration hint */
    transform: translateZ(0); /* Force hardware acceleration */
    backface-visibility: hidden; /* Prevent flickering */
    -webkit-backface-visibility: hidden;
}

/* Default state - show images, hide videos */
.angus-products-grid .angus-card-video-container,
.angus-products-grid .angus-card-video-container-inactive {
    display: none !important;
}

.angus-products-grid .grid-view-image {
    display: block !important;
}

/* Video view state - show videos (but keep them behind images initially) */
.angus-products-grid.video-view .angus-card-video-container {
    display: block !important;
    width: 100%;
    height: 330px; /* Fixed height for consistency */
    background: #000; /* Black background to prevent any white flash */
    position: relative;
    overflow: hidden;
    border-radius: 0px; /* Match the border-radius setting */
    z-index: 1;
}

/* Ensure video container is on top when ready */
.angus-products-grid.video-view .angus-product-card.video-ready .angus-card-video-container {
    z-index: 10;
    background: #f8f9fa; /* Show background only when ready */
}

.angus-products-grid.video-view .angus-card-video {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

/* OVERRIDE: Ensure all images are visible by default in video view */
.angus-products-grid.video-view .grid-view-image {
    display: block !important;
    transition: opacity 0.3s ease-in-out;
}

/* Keep image visible while video is preparing */
.angus-products-grid.video-view .angus-product-card.video-preparing .grid-view-image {
    display: block !important;
    opacity: 1;
}

/* Fade out animation for image when video is ready */
.angus-products-grid.video-view .angus-product-card .grid-view-image.fade-out {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

/* THEN: Only hide images in products that have active video containers AND are ready */
.angus-products-grid.video-view .angus-product-card.has-active-video.video-ready .grid-view-image {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
    z-index: -1 !important;
}

/* CRITICAL: Also hide ALL image elements in video-ready products to prevent double display */
.angus-products-grid.video-view .angus-product-card.has-active-video.video-ready .product-image img,
.angus-products-grid.video-view .angus-product-card.has-active-video.video-ready picture,
.angus-products-grid.video-view .angus-product-card.has-active-video.video-ready img:not(.angus-card-video) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
    z-index: -1 !important;
}

/* Ensure video container is ABOVE everything when ready */
.angus-products-grid.video-view .angus-product-card.has-active-video.video-ready .angus-card-video-container {
    z-index: 100 !important;
    position: relative;
}

/* EXPLICIT: Keep images visible for products without videos in video view */
.angus-products-grid.video-view .angus-product-card:not(.has-active-video) .grid-view-image {
    display: block !important;
    opacity: 1;
}

/* Loading spinner for video loading - now positioned over the image */
.video-loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #003c71;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 20;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Hide loading spinner when video is ready */
.angus-card-video-container.video-loaded .video-loading-spinner {
    display: none;
}

/* Table view - always show images, hide videos */
.angus-products-grid.table-view .angus-card-video-container {
    display: none !important;
}

.angus-products-grid.table-view .grid-view-image {
    display: block !important;
    max-height: 70px;
    width: auto;
    object-fit: contain;
}

/* Ensure all table view images are visible and properly sized */
.angus-products-grid.table-view .product-image img {
    display: block !important;
    max-height: 70px;
    width: auto;
    object-fit: contain;
}

/* Price Cell */
.angus-products-grid.table-view .product-price {
    width: 10%;
    background-color: #d9eaf9;
    color: #003c71;
    text-align: center;
    font-weight: bold;
}

/* Sire Cell */
.angus-products-grid.table-view .product-sire {
    width: 15%;
    background-color: #f5f5f5;
    text-align: center;
}

/* Stats Cell */
.angus-products-grid.table-view .product-stats {
    width: 40%;
    background-color: transparent;
    padding: 5px;
}

.angus-products-grid.table-view .stat-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    margin: 0;
    border-bottom: none;
}

.angus-products-grid.table-view .stat-item {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    margin: 2px;
    width: auto;
    height: auto;
    padding: 3px 6px;
    border-right: none;
    border-radius: 3px;
}

.angus-products-grid.table-view .stat-label {
    margin-bottom: 0;
    margin-right: 5px;
    font-size: 12px;
    font-weight: bold;
}

.angus-products-grid.table-view .stat-value {
    font-size: 14px;
    font-weight: bold;
}

/* Actions Cell */
.angus-products-grid.table-view .product-actions {
    width: 10%;
    text-align: center;
}

.angus-products-grid.table-view .product-actions .angus-button {
    width: auto;
    padding: 8px 12px;
    font-size: 14px;
}

/* Ion Range Slider Custom Styles */
.irs--flat .irs-bar {
    background-color: #003c71;
}

.irs--flat .irs-handle > i:first-child {
    background-color: #003c71;
}

.irs--flat .irs-from, .irs--flat .irs-to, .irs--flat .irs-single {
    background-color: #003c71;
}

.irs--flat .irs-from:before, .irs--flat .irs-to:before, .irs--flat .irs-single:before {
    border-top-color: #003c71;
}

/* Responsive Styles */
@media (max-width: 1799px) {
    .angus-products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }

    .angus-product-card {
        max-width: 320px;
    }

    /* Video view responsive adjustments */
    .angus-products-grid.video-view .angus-card-video {
        height: auto !important;
    }

    .angus-products-grid.video-view .has-active-video .angus-card-video-container {
        height: auto !important;
        min-height: 230px !important;
    }

    .angus-products-grid.video-view .angus-card-video-container {
        height: auto !important;
        min-height: 230px;
    }
}

@media (max-width: 1440px) {
    .angus-page-container {
        padding: 30px 5px;
    }
}

@media (max-width: 1359px) {
    .angus-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .angus-product-card {
        max-width: 400px;
    }

    /* Video view responsive adjustments */
    .angus-products-grid.video-view .angus-card-video {
        height: auto !important;
    }

    .angus-products-grid.video-view .has-active-video .angus-card-video-container {
        height: auto !important;
        min-height: 230px !important;
    }

    .angus-products-grid.video-view .angus-card-video-container {
        height: auto !important;
        min-height: 230px;
    }
}

@media (max-width: 992px) {
    .angus-sidebar,
    .angus-main-content {
        width: 100%;
    }

    .angus-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .angus-product-card {
        max-width: 100%;
        width: 100%;
    }

    .product-header h3 {
        font-size: 16px;
    }

    /* Table view responsive styles */
    .angus-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
        width: 100%;
    }

    .angus-table {
        font-size: 12px;
    }

    .angus-table th,
    .angus-table td {
        padding: 8px 5px;
    }

    .column-image {
        display: none;
    }

    .angus-table-controls {
        flex-direction: column;
        align-items: flex-end;
    }

    .angus-table-search {
        width: 100%;
    }

    .angus-table-search input[type="text"] {
        width: 100%;
    }

    /* Convert to cards on mobile */
    .angus-products-grid.table-view .angus-product-card {
        display: block;
        margin-bottom: 20px;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        overflow: hidden;
        background-color: white;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    }

    /* Add data labels for mobile */
    .angus-products-grid.table-view .product-header,
    .angus-products-grid.table-view .product-image,
    .angus-products-grid.table-view .product-price,
    .angus-products-grid.table-view .product-sire,
    .angus-products-grid.table-view .product-stats,
    .angus-products-grid.table-view .product-actions {
        display: block;
        width: 100%;
        height: auto;
        text-align: center;
    }

    /* Improve mobile stats display */
    .angus-products-grid.table-view .product-stats {
        padding: 10px;
    }

    .angus-products-grid.table-view .stat-row {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .angus-products-grid.table-view .stat-item {
        flex: 0 0 calc(33.333% - 4px);
        margin: 2px;
        padding: 8px 5px;
    }
}

@media (max-width: 768px) {
    .product-price-container {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .product-price {
        text-align: center;
    }

    .select-options-btn {
        width: 100%;
        padding: 10px 16px;
    }

    .stat-label {
        font-size: 11px;
    }

    .stat-value {
        font-size: 16px;
    }

    .stat-item {
        height: 55px;
        padding: 8px 4px;
    }

    .product-header h3 {
        font-size: 16px;
    }

    /* Video view responsive adjustments for mobile */
    .angus-products-grid.video-view .angus-card-video {
        height: auto !important;
    }

    .angus-products-grid.video-view .has-active-video .angus-card-video-container {
        height: auto !important;
        min-height: 400px !important;
    }

    .angus-products-grid.video-view .angus-card-video-container {
        height: auto !important;
        min-height: 400px !important;
    }
}

@media (max-width: 768px) {
    .angus-search-box {
        margin-left: 0 !important;
        margin-top: 10px !important;
        width: 100% !important;
        max-width: none !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }

    .angus-search-box input[type="text"] {
        width: 100% !important;
        max-width: 100% !important;
    }

    .sorting-options {
        flex-wrap: wrap;
        flex-direction: column;
        width: 100%;
    }
    
    .sorting-options .sort-option {
        width: 100%;
        text-align: center;
        margin-bottom: 10px;
    }
}

@media (max-width: 576px) {
    .angus-products-grid {
        grid-template-columns: 1fr;
        gap: 25px;
    }

    .angus-product-card {
        max-width: 100%;
    }

    .view-sort-container {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
        width: 100%;
    }
    
    /* Make view toggle buttons full width on mobile */
    .view-toggle {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .view-toggle a {
        width: 100%;
        margin-right: 0;
        margin-bottom: 5px;
        text-align: center;
        box-sizing: border-box;
    }
    
    .view-toggle a:last-child {
        margin-bottom: 0;
    }

    .sorting-options {
        flex-wrap: wrap;
        width: 100%;
        flex-direction: column;
    }
    
    /* Force search box to be full width on mobile */
    .angus-search-box {
        margin: 10px 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        max-width: none !important;
        flex: 0 0 100% !important;
        display: block !important;
    }
    
    .angus-search-box input[type="text"] {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .sort-option {
        flex: 1 0 100%;
        text-align: center;
        width: 100%;
        margin-bottom: 10px;
    }

    .stat-item {
        height: 50px;
    }
}
