/**
 * Storefront v3.0.0 - Production Ready
 * Clean, centered search bar with icon inside
 */

.odoo-storefront-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem 3rem; /* Added bottom padding to prevent footer overlap */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ---- CLEAN CENTERED SEARCH BAR ---- */
.storefront-search-bar {
    margin-bottom: 2.5rem;
    position: relative;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

/* Search wrapper - Clean and simple */
.storefront-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    height: 56px;
    background: #ffffff;
    border: 2px solid #FE8B27;
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(254, 139, 39, 0.1);
    transition: all 0.3s ease;
}

.storefront-search-wrapper:focus-within {
    border-color: #e67817;
    box-shadow: 0 4px 12px rgba(254, 139, 39, 0.2);
}

/* Search input - Full width, clean */
.storefront-search-input {
    width: 100%;
    height: 100%;
    border: none;
    padding: 0 4rem 0 1.5rem;
    font-size: 1rem;
    outline: none;
    background: transparent;
    color: #333;
}

.storefront-search-input::placeholder {
    color: #bbb;
}

/* Search icon - Inside input on right */
.storefront-search-icon {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: #FE8B27;
    pointer-events: none;
}

/* Autocomplete dropdown - styled like image 2 */
.search-autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 0.6rem);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    max-height: 450px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-autocomplete-dropdown.active {
    display: block;
}

/* Individual autocomplete item */
.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background .2s;
    text-decoration: none;
    color: inherit;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: #f9f9f9;
}

/* Product thumbnail in autocomplete */
.autocomplete-item-image {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    background: #f8f8f8;
    border: 1px solid #efefef;
}

.autocomplete-no-image {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    background: #f8f8f8;
    border: 1px solid #efefef;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.autocomplete-no-image svg {
    width: 24px;
    height: 24px;
    color: #ccc;
}

/* Product info in autocomplete */
.autocomplete-item-info {
    flex: 1;
    min-width: 0;
}

.autocomplete-item-name {
    font-size: 0.92rem;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-item-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: #888;
}

.autocomplete-item-meta span {
    white-space: nowrap;
}

/* "Product" label on right */
.autocomplete-item-label {
    padding: 0.35rem 0.8rem;
    background: #f0f0f0;
    color: #666;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    flex-shrink: 0;
}

/* No results message */
.no-results-autocomplete {
    padding: 1.6rem;
    text-align: center;
    color: #999;
    font-size: 0.9rem;
}

/* Loading state */
.autocomplete-loading {
    padding: 1.6rem;
    text-align: center;
    color: #999;
    font-size: 0.9rem;
}

.autocomplete-loading::after {
    content: "...";
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: "."; }
    40% { content: ".."; }
    60%, 100% { content: "..."; }
}

/* ---- LAYOUT ---- */
.storefront-content {
    display: grid;
    grid-template-columns: 230px 1fr;
    gap: 1.8rem;
    align-items: start;
}

@media (max-width: 900px) {
    .storefront-content { grid-template-columns: 1fr; }
    .storefront-sidebar { 
        order: 2; 
        width: 100%;
        position: static; /* Remove sticky on mobile to avoid header clash */
        margin-bottom: 1.5rem;
    }
    .storefront-main { order: 1; }
}

/* ---- PRODUCTS CONTAINER - Defined space to prevent footer overflow ---- */
.storefront-products-container {
    min-height: 600px; /* Minimum height to contain products */
    padding-bottom: 3rem; /* Space before footer */
    display: flex;
    flex-direction: column;
}

/* Main products area */
.storefront-main {
    width: 100%;
    min-height: 500px; /* Ensure minimum height */
}

.products-grid-storefront {
    margin-bottom: 2rem; /* Space before pagination */
    flex: 1; /* Take available space */
}

.storefront-pagination {
    margin-top: auto; /* Push to bottom of container */
    padding: 2rem 0; /* Space around pagination */
}

/* ---- SIDEBAR ---- */
.storefront-sidebar {
    background: #f9f9f9;
    border: 1px solid #e5e5e5;
    border-radius: 11px;
    padding: 1.15rem;
    position: sticky;
    top: 110px; /* Increased offset for sticky header (was 100px, now 110px) */
}

.sidebar-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 .95rem 0;
}

.category-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-list li { margin-bottom: .38rem; }

.category-list li a {
    display: flex;
    justify-content: space-between;
    padding: .55rem .7rem;
    border-radius: 7px;
    text-decoration: none;
    color: #555;
    font-size: .86rem;
    font-weight: 500;
    transition: all .2s;
}

.category-list li a:hover {
    background: #fff;
    color: #ff8c42;
}

.category-list li.active a {
    background: linear-gradient(135deg, #ff8c42 0%, #ff7a29 100%);
    color: #fff;
    box-shadow: 0 2px 7px rgba(255,140,66,.22);
}

.cat-count {
    font-size: .78rem;
    opacity: .7;
}

/* ---- MAIN ---- */
.storefront-main { min-width: 0; }

.storefront-title {
    font-size: 1.7rem;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 1.4rem 0;
}

/* ---- GRID ---- */
.products-grid-storefront {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.1rem;
}

@media (max-width: 1100px) {
    .products-grid-storefront { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .products-grid-storefront { grid-template-columns: 1fr; }
}

/* ---- COMPACT CARD ---- */
.storefront-product-card {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 9px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all .25s;
}

.storefront-product-card:hover {
    box-shadow: 0 3px 12px rgba(0,0,0,.08);
    transform: translateY(-2px);
    border-color: #ff8c42;
}

.product-card-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.storefront-product-card .product-image {
    position: relative;
    width: 100%;
    height: 50px;
    background: #f8f8f8;
    overflow: hidden;
}

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

.storefront-product-card .no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #ccc;
}

.storefront-product-card .stock-badge {
    position: absolute;
    top: 4px; right: 4px;
    padding: .13rem .38rem;
    border-radius: 11px;
    font-size: .62rem;
    font-weight: 700;
    background: rgba(255,255,255,.95);
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
}

.storefront-product-card .stock-badge.in-stock { color: #22a95a; }
.storefront-product-card .stock-badge.low-stock { color: #e08e00; }
.storefront-product-card .stock-badge.out-of-stock { color: #e53e3e; }

.storefront-product-card .product-info {
    padding: .5rem .8rem .38rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: .2rem;
}

.storefront-product-card .product-name {
    font-size: .8rem;
    font-weight: 600;
    color: #1a1a2e;
    line-height: 1.22;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

.storefront-product-card .product-sku {
    font-size: .66rem;
    color: #aaa;
}

.storefront-product-card .product-branch-tags {
    display: none !important; /* Hidden on desktop per user request */
}

.storefront-product-card .branch-tag-small {
    display: none !important; /* Hidden */
}

.storefront-product-card .branch-tag-more {
    display: none !important; /* Hidden */
}

.storefront-product-card .product-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: .28rem;
}

.storefront-product-card .product-price {
    font-size: .9rem;
    font-weight: 700;
    color: #22a95a;
}

.storefront-product-card .product-stock {
    font-size: .7rem;
    color: #888;
}

.storefront-product-card .product-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .32rem;
    padding: .48rem .8rem .58rem;
    border-top: 1px solid #f2f2f2;
}

.storefront-product-card .btn-view-product,
.storefront-product-card .btn-add-to-cart {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .22rem;
    padding: .38rem .5rem; /* Reduced for compact look */
    border-radius: 5px;
    font-size: .72rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s;
    line-height: 1.2;
}

.storefront-product-card .btn-view-product {
    background: #fff;
    color: #555;
    border: 1.5px solid #ddd; /* Outlined style */
}

.storefront-product-card .btn-view-product:hover { 
    background: #f7f7f7;
    border-color: #ccc;
}

.storefront-product-card .btn-add-to-cart {
    background: #ff8c42; /* Solid orange */
    color: #fff;
    border: none;
}

.storefront-product-card .btn-add-to-cart:hover {
    background: #e57a30; /* Darker orange */
}

.storefront-product-card .btn-view-product svg,
.storefront-product-card .btn-add-to-cart svg {
    width: 11px; height: 11px;
}

/* Pagination */
.storefront-pagination {
    margin-top: 2.3rem;
    display: flex;
    justify-content: center;
}

.storefront-pagination .page-numbers {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: .45rem;
}

.storefront-pagination a,
.storefront-pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 .65rem;
    border: 1px solid #ddd;
    border-radius: 7px;
    text-decoration: none;
    color: #555;
    font-size: .86rem;
    font-weight: 500;
    transition: all .2s;
}

.storefront-pagination a:hover {
    background: #f5f5f5;
}

.storefront-pagination .current {
    background: linear-gradient(135deg, #ff8c42 0%, #ff7a29 100%);
    color: #fff;
    border-color: transparent;
}

.no-products {
    text-align: center;
    padding: 3.5rem 2rem;
    color: #999;
}

/* ---- MOBILE RESPONSIVE SEARCH BAR ---- */
@media (max-width: 768px) {
    .storefront-search-bar {
        max-width: 100%;
        margin-bottom: 2rem;
    }
    
    .storefront-search-wrapper {
        height: 52px;
    }
    
    .storefront-search-input {
        font-size: 0.95rem;
        padding: 0 3.5rem 0 1.2rem;
    }
    
    .storefront-search-icon {
        right: 1.2rem;
        width: 18px;
        height: 18px;
    }
}

@media (max-width: 480px) {
    .storefront-search-wrapper {
        height: 48px;
    }
    
    .storefront-search-input {
        font-size: 0.9rem;
        padding: 0 3rem 0 1rem;
    }
    
    .storefront-search-icon {
        right: 1rem;
        width: 16px;
        height: 16px;
    }
}


/* ============================================================
   MOBILE FIXES - Sticky Sidebar Offset & Responsive Layout
   Added for production mobile optimization
   ============================================================ */

/* Mobile - Optimize for smaller screens */
@media (max-width: 768px) {
    /* Remove sticky on mobile to avoid header clash */
    .storefront-sidebar {
        position: static;
        margin-bottom: 2rem; /* Increased for footer clearance */
    }
    
    /* Products container on mobile */
    .storefront-products-container {
        min-height: auto; /* Let content determine height on mobile */
        padding-bottom: 4rem; /* Extra padding on mobile */
    }
    
    .storefront-main {
        min-height: auto;
        margin-bottom: 2rem;
    }
    
    /* MOBILE HORIZONTAL CARD LAYOUT - Fixed height, tags visible */
    .storefront-product-card {
        flex-direction: row !important;
        height: 140px !important;
        max-height: 140px !important;
        display: flex !important;
    }
    
    .storefront-product-card .product-card-link {
        flex-direction: row !important;
        flex: 1 !important;
        display: flex !important;
        min-width: 0 !important;
    }
    
    /* Image on left */
    .storefront-product-card .product-image {
        width: 110px !important;
        min-width: 110px !important;
        height: 100% !important;
        flex-shrink: 0 !important;
    }
    
    /* Info on right */
    .storefront-product-card .product-info {
        flex: 1 !important;
        padding: 0.65rem 0.75rem 0 0.75rem !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        overflow: hidden !important;
        min-width: 0 !important;
    }
    
    .storefront-product-card .product-name {
        font-size: 0.9rem !important;
        line-height: 1.3 !important;
        margin-bottom: 0.25rem !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
    }
    
    .storefront-product-card .product-branch-tags {
        display: none !important; /* Hidden per user request */
    }
    
    .storefront-product-card .branch-tag-small {
        font-size: 0.65rem !important;
        padding: 0.2rem 0.4rem !important;
        display: inline-block !important;
    }
    
    .storefront-product-card .product-meta {
        margin-top: 0.3rem !important;
        margin-bottom: 0 !important;
    }
    
    .storefront-product-card .product-price {
        font-size: 1rem !important;
        line-height: 1.3 !important;
    }
    
    .storefront-product-card .product-stock {
        display: none !important;
    }
    
    /* BUTTONS AT BOTTOM RIGHT - with proper spacing */
    .storefront-product-card .product-actions {
        display: flex !important;
        flex-direction: row !important;
        gap: 0.4rem !important;
        padding: 0 0.5rem 0.65rem 0 !important;
        justify-content: flex-end !important;
        align-items: center !important;
        border-top: none !important;
        margin-top: auto !important;
    }
    
    /* Compact buttons */
    .storefront-product-card .product-actions .btn-view-product,
    .storefront-product-card .product-actions .btn-add-to-cart {
        font-size: 0.7rem !important;
        padding: 0.45rem 0.65rem !important;
        border-radius: 5px !important;
        font-weight: 600 !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.25rem !important;
        height: 30px !important;
        min-width: auto !important;
    }
    
    .storefront-product-card .product-actions .btn-view-product svg,
    .storefront-product-card .product-actions .btn-add-to-cart svg {
        width: 11px !important;
        height: 11px !important;
    }
    
    /* View button */
    .storefront-product-card .product-actions .btn-view-product {
        background: #fff !important;
        color: #555 !important;
        border: 1.5px solid #ddd !important;
    }
    
    /* Add to Cart button */
    .storefront-product-card .product-actions .btn-add-to-cart {
        background: #ff8c42 !important;
        color: #fff !important;
        border: none !important;
    }
}

/* Small mobile phones (320px - 480px) */
@media (max-width: 480px) {
    .storefront-product-card {
        height: 130px !important;
        max-height: 130px !important;
    }
    
    .storefront-product-card .product-image {
        width: 100px !important;
        min-width: 100px !important;
    }
    
    .storefront-product-card .product-info {
        padding: 0.6rem 0.65rem 0 0.65rem !important;
    }
    
    .storefront-product-card .product-name {
        font-size: 0.85rem !important;
    }
    
    .storefront-product-card .product-actions .btn-view-product,
    .storefront-product-card .product-actions .btn-add-to-cart {
        font-size: 0.65rem !important;
        padding: 0.4rem 0.55rem !important;
        height: 28px !important;
    }
    
    /* Stock badge on mobile */
    .stock-badge {
        font-size: 0.65rem !important;
        padding: 0.2rem 0.4rem !important;
        top: 0.3rem;
        right: 0.3rem;
    }
    
    /* Search bar adjustments */
    .storefront-search-wrapper {
        height: 52px;
    }
    
    .storefront-search-input {
        font-size: 0.95rem;
        padding: 0 3.5rem 0 1.2rem;
    }
    
    /* Product grid spacing */
    .products-grid-storefront {
        gap: 0.75rem; /* Tighter gap for horizontal cards */
        margin-bottom: 2rem; /* Prevent footer overlap */
    }
    
    /* Pagination spacing */
    .storefront-pagination {
        padding: 1.5rem 0 2rem; /* Extra bottom padding */
    }
    
    /* Reduce side padding but add bottom padding to prevent footer overlap */
    .odoo-storefront-container {
        padding: 0 0.75rem 2rem; /* Reduced from 4rem since container handles it */
    }
}

/* Small mobile - Further optimizations */
@media (max-width: 480px) {
    .storefront-sidebar {
        padding: 1rem;
        border-radius: 8px;
        margin-bottom: 2rem; /* Ensure footer clearance */
    }
    
    /* Products container on small mobile */
    .storefront-products-container {
        min-height: auto; /* Let content determine height */
        padding-bottom: 5rem; /* Extra padding on tiny screens */
    }
    
    .storefront-main {
        min-height: auto;
        margin-bottom: 2rem;
    }
    
    /* Horizontal cards on small mobile */
    .storefront-product-card {
        height: 130px; /* Slightly shorter on tiny screens */
    }
    
    .storefront-product-card .product-image {
        width: 100px; /* Smaller image on tiny screens */
        min-width: 100px;
    }
    
    .product-info {
        padding: 0.6rem;
    }
    
    .product-name {
        font-size: 0.85rem !important;
    }
    
    .sidebar-title {
        font-size: 1rem;
    }
    
    .category-list li a {
        padding: 0.5rem 0.6rem;
        font-size: 0.85rem;
    }
    
    .storefront-search-wrapper {
        height: 48px;
    }
    
    .storefront-search-input {
        font-size: 0.9rem;
        padding: 0 3rem 0 1rem;
    }
    
    .storefront-search-icon {
        width: 18px;
        height: 18px;
    }
    
    .products-grid-storefront {
        gap: 0.65rem; /* Even tighter on small screens */
        margin-bottom: 2rem; /* Prevent footer overlap */
    }
    
    /* Extra pagination spacing on small mobile */
    .storefront-pagination {
        padding: 1rem 0 3rem;
    }
    
    /* Extra bottom padding on very small screens */
    .odoo-storefront-container {
        padding-bottom: 2rem; /* Container handles spacing */
    }
}

/* Ensure categories don't overflow on mobile */
@media (max-width: 640px) {
    .category-list {
        max-height: none;
        overflow: visible;
    }
    
    .category-list li a {
        font-size: 0.88rem;
    }
}
