/**
 * Mechano Catalog Public Styles
 */

/* Vehicle Search Form */
body .mechano-vehicle-search {
    margin: 20px 0;
    padding: 20px;
    background: #f9f9f9;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
}

body .mechano-search-form {
    display: flex;
    flex-direction: column;
}

body .mechano-search-form.horizontal {
    flex-direction: row;
}

body .mechano-search-form.vertical {
    flex-direction: column;
    align-items: stretch;
}

.search-field {
    flex: 1;
    min-width: 200px;
}

.search-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.search-field select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    font-size: 14px;
}

.search-field select:disabled {
    background: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

.search-button-field {
    flex: 0 0 auto;
}

body .mechano-search-btn {
    background: #007cba;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.3s ease;
}

body .mechano-search-btn:hover:not(:disabled) {
    background: #005a87;
}

body .mechano-search-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Search Results */
body .mechano-search-results {
    margin-top: 30px;
    padding: 20px;
    background: #fff;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
}

body .mechano-search-results h3 {
    margin: 0 0 20px 0;
    color: #333;
    border-bottom: 2px solid #007cba;
    padding-bottom: 10px;
}

.results-container {
    min-height: 100px;
}

.search-results-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

/* Catalog Layout */
body .mechano-catalog {
    margin: 20px 0;
}

.catalog-search {
    margin-bottom: 30px;
}

.catalog-filters {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-group label {
    font-weight: 600;
    color: #333;
}

.filter-group select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.product-card {
    background: #fff;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: box-shadow 0.3s ease;
}

.product-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.product-card img {
    max-width: 100%;
    height: auto;
    margin-bottom: 15px;
}

.product-card h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #333;
}

.product-card .price {
    font-size: 18px;
    font-weight: bold;
    color: #007cba;
    margin-bottom: 15px;
}

.product-card .compatibility-check {
    margin-top: 10px;
}

/* Vehicle Compatibility */
body .mechano-compatibility {
    margin: 20px 0;
    padding: 20px;
    background: #f0f8ff;
    border: 1px solid #b3d9ff;
    border-radius: 8px;
}

body .mechano-compatibility h3 {
    margin: 0 0 15px 0;
    color: #0066cc;
}

.compatibility-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.compatibility-item {
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #d1ecf1;
    border-radius: 4px;
    color: #0c5460;
}

.compatibility-item strong {
    margin-right: 8px;
}

.compatibility-item .years {
    color: #666;
    font-size: 0.9em;
}

/* Compatibility Check Button */
.check-compatibility {
    background: #28a745;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s ease;
}

.check-compatibility:hover {
    background: #218838;
}

.check-compatibility:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.check-compatibility.compatible {
    background: #28a745;
}

.check-compatibility.incompatible {
    background: #dc3545;
}

/* Loading States */
.loading {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #ddd;
    border-top-color: #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Pagination */
.catalog-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
}

.pagination-btn {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: #fff;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.pagination-btn:hover {
    background: #007cba;
    color: #fff;
    border-color: #007cba;
}

.pagination-btn.current {
    background: #007cba;
    color: #fff;
    border-color: #007cba;
}

.pagination-btn:disabled {
    background: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

/* Responsive Design */
@media (max-width: 768px) {
    .mechano-search-form {
        flex-direction: column;
    }
    
    .search-field {
        min-width: auto;
    }
    
    .catalog-filters {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .compatibility-list {
        gap: 5px;
    }
    
    .compatibility-item {
        padding: 6px 10px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .mechano-vehicle-search {
        padding: 15px;
    }
    
    .mechano-search-results {
        padding: 15px;
    }
    
    .catalog-filters {
        padding: 10px;
    }
    
    .product-card {
        padding: 15px;
    }
}

/* Select2 Integration */
.select2-container {
    width: 100% !important;
}

.select2-container .select2-selection--single {
    height: 42px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.select2-container .select2-selection--single .select2-selection__rendered {
    line-height: 40px;
    padding-left: 10px;
    color: #333;
}

.select2-container .select2-selection--single .select2-selection__arrow {
    height: 40px;
}

.select2-dropdown {
    border: 1px solid #ddd;
    border-radius: 4px;
}

.select2-container--default .select2-selection--single:focus {
    border-color: #007cba;
    outline: none;
    box-shadow: 0 0 3px rgba(0, 124, 186, 0.3);
}

/* WordPress Theme Compatibility */
.entry-content .mechano-vehicle-search,
.post-content .mechano-vehicle-search {
    margin: 20px 0;
}

.entry-content .mechano-catalog,
.post-content .mechano-catalog {
    margin: 20px 0;
}

/* WooCommerce Integration */
.woocommerce .mechano-compatibility {
    margin: 20px 0;
}

.woocommerce-tabs .mechano-compatibility {
    margin: 0;
    padding: 20px 0;
    background: transparent;
    border: none;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .mechano-vehicle-search {
        background: #2a2a2a;
        border-color: #555;
        color: #fff;
    }
    
    .search-field label {
        color: #fff;
    }
    
    .search-field select {
        background: #3a3a3a;
        border-color: #555;
        color: #fff;
    }
    
    .mechano-search-results {
        background: #2a2a2a;
        border-color: #555;
        color: #fff;
    }
    
    .catalog-filters {
        background: #2a2a2a;
        border-color: #555;
    }
    
    .product-card {
        background: #2a2a2a;
        border-color: #555;
        color: #fff;
    }
    
    .compatibility-item {
        background: #3a3a3a;
        border-color: #555;
        color: #fff;
    }
    
    .mechano-product-card {
        background: #2a2a2a;
        border-color: #555;
        color: #fff;
    }
}

/* Smart Loading Strategy - Product Cards */
body .mechano-product-card {
    display: flex;
    flex-wrap: wrap;
    background: #fff;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
}

body .mechano-product-card:hover {
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

body .mechano-product-card .product-image {
    flex: 0 0 180px;
    margin-right: 20px;
    text-align: center;
}

body .mechano-product-card .product-image img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    border: 1px solid #eee;
}

body .mechano-product-card .no-image {
    width: 150px;
    height: 120px;
    background: #f5f5f5;
    border: 2px dashed #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
    border-radius: 4px;
}

body .mechano-product-card .product-info {
    flex: 1;
    min-width: 250px;
}

body .mechano-product-card .product-title {
    margin: 0 0 10px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

body .mechano-product-card .product-meta {
    color: #666;
    font-size: 14px;
    line-height: 1.6;
}

body .mechano-product-card .product-pricing {
    flex: 0 0 150px;
    text-align: right;
    margin-left: 20px;
}

body .mechano-product-card .price {
    font-size: 20px;
    font-weight: bold;
    color: #2e7d23;
    margin-bottom: 10px;
}

body .mechano-product-card .price-request {
    font-size: 16px;
    color: #ff9800;
    font-weight: 600;
    margin-bottom: 10px;
}

body .mechano-product-card .stock {
    font-size: 14px;
    margin-bottom: 15px;
}

body .mechano-product-card .stock.in-stock {
    color: #2e7d23;
}

body .mechano-product-card .stock.out-of-stock {
    color: #d32f2f;
}

body .mechano-product-card .product-actions {
    flex: 0 0 150px;
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

body .mechano-product-card .button {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s ease;
    display: inline-block;
}

body .mechano-product-card .wc-add-to-cart {
    background: #2e7d23;
    color: white;
}

body .mechano-product-card .wc-add-to-cart:hover {
    background: #1b5e20;
}

body .mechano-product-card .button-secondary {
    background: #0073aa;
    color: white;
}

body .mechano-product-card .button-secondary:hover {
    background: #005a87;
}

body .mechano-product-card .request-price {
    background: #ff9800;
    color: white;
}

body .mechano-product-card .request-price:hover {
    background: #f57c00;
}

body .mechano-product-card .button-disabled {
    background: #ccc;
    color: #999;
    cursor: not-allowed;
}

body .mechano-product-card .button-success {
    background: #4caf50;
    color: white;
}

/* Responsive Design for Product Cards */
@media (max-width: 768px) {
    .mechano-product-card {
        flex-direction: column;
    }
    
    .mechano-product-card .product-image {
        flex: none;
        margin-right: 0;
        margin-bottom: 15px;
    }
    
    .mechano-product-card .product-pricing {
        flex: none;
        margin-left: 0;
        text-align: left;
        margin-bottom: 15px;
    }
    
    .mechano-product-card .product-actions {
        flex: none;
        text-align: left;
        flex-direction: row;
        flex-wrap: wrap;
    }
}

/* WooCommerce Categories Grid with Images */
.woocommerce-categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.woocommerce-category-card {
    background: #fff;
    border: 2px solid #e1e1e1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
}

.woocommerce-category-card:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transform: translateY(-3px);
    border-color: #007cba;
}

.woocommerce-category-card.active {
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
    /* Keep compact - don't span all columns */
}

.woocommerce-category-card .category-image {
    width: 100%;
    height: 150px;
    overflow: hidden;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.woocommerce-category-card .category-image img {
    height: 100%;
    object-fit: cover;
}

.woocommerce-category-card .category-no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
}

.woocommerce-category-card .category-no-image .dashicons {
    font-size: 60px;
    width: 60px;
    height: 60px;
    color: #ccc;
}

.woocommerce-category-card .category-info {
    padding: 15px;
    text-align: center;
}

.woocommerce-category-card .category-info h5 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

.woocommerce-category-card .product-count {
    font-size: 13px;
    color: #666;
    display: block;
}

/* Subcategories Container */
.woocommerce-category-card .subcategories-container {
    padding: 15px;
    background: #f9f9f9;
    border-top: 1px solid #e1e1e1;
    width: 100%;
    box-sizing: border-box;
    order: 10; /* Place at bottom of flex container */
}

.subcategories-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
}

.subcategory-item-wrapper {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 6px;
}

.subcategory-item {
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    color: #333;
}

.subcategory-item:hover {
    background: #f0f8ff;
    border-color: #007cba;
}

.subcategory-item.active {
    background: #007cba;
    border-color: #007cba;
    color: #fff;
}

.subcategory-item .subcat-icon {
    font-size: 12px;
    color: #333;
    flex: 0 0 16px;
}

.subcategory-item.active .subcat-icon {
    color: #fff;
}

.subcategory-item .subcat-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.subcategory-item .subcat-count {
    font-size: 12px;
    color: #666;
    flex: 0 0 auto;
}

.subcategory-item.active .subcat-count {
    color: rgba(255,255,255,0.8);
}

/* Nested subcategories (3rd level and deeper) */
.nested-subcategories {
    margin-left: 20px;
    margin-top: 8px;
    border-left: 2px solid #e1e1e1;
    padding-left: 10px;
    width: calc(100% - 30px); /* Account for margin and padding */
    box-sizing: border-box;
}

.nested-subcategories .subcategory-item {
    font-size: 13px;
    padding: 8px 10px;
}

.nested-subcategories .subcat-icon {
    font-size: 10px;
}

.loading-subcats,
.no-subcats,
.error-subcats {
    padding: 15px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

.error-subcats {
    color: #d32f2f;
}

/* Responsive Grid for Categories */
@media (max-width: 1200px) {
    .woocommerce-categories-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

@media (max-width: 768px) {
    .woocommerce-categories-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }
    
    .woocommerce-category-card .category-image {
        height: 120px;
    }
    
    .woocommerce-category-card .category-info h5 {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .woocommerce-categories-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .woocommerce-category-card .category-image {
        height: 100px;
    }
    
    .woocommerce-category-card .category-info {
        padding: 10px;
    }
    
    .subcategory-item {
        padding: 8px 10px;
        font-size: 13px;
    }
}
