/* ============================================================
   Branch Search - ULTRA CLEAN v2.9.0
   ============================================================ */

.odoo-branch-search-container {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 1.5rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.search-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 1.5rem;
    text-align: center;
}

/* ---- ABSOLUTELY CLEAN SEARCH BAR ---- */
.odoo-branch-search-form { margin-bottom: 2rem; }

.search-bar-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 850px;
    margin: 0 auto;
}

/* ONE border, perfectly clean */
.search-bar-wrapper {
    display: flex;
    align-items: stretch;
    flex: 1;
    height: 50px;
    background: #fff;
    border: 2px solid #d4a55a;
    border-radius: 25px;
    overflow: hidden;
    padding: 0;
}

.search-bar-wrapper:focus-within {
    border-color: #b8882e;
    box-shadow: 0 0 0 3px rgba(212,165,90,.08);
}

.branch-select-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: #faf8f5;
    border-right: 1px solid #e8dfc8;
}

.branch-dropdown {
    height: 100%;
    padding: 0 2.2rem 0 1.2rem;
    border: none;
    background: transparent;
    font-size: 0.88rem;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    appearance: none;
    min-width: 130px;
    outline: none;
}

.branch-select-wrapper::after {
    content: "▾";
    position: absolute;
    right: .8rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #999;
    font-size: .62rem;
}

.search-divider { display: none; }

.product-search-input {
    flex: 1;
    height: 100%;
    border: none;
    background: transparent;
    padding: 0 1.2rem;
    font-size: 0.92rem;
    color: #333;
    outline: none;
}

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

/* Orange button flush right */
.search-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    height: 100%;
    padding: 0 1.8rem;
    background: linear-gradient(135deg, #ff8c42 0%, #ff7a29 100%);
    color: #fff;
    border: none;
    border-radius: 0;
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
    white-space: nowrap;
}

.search-button svg { width: 13px; height: 13px; }

.search-button:hover {
    background: linear-gradient(135deg, #e57a30 0%, #e06616 100%);
}

.clear-button {
    height: 46px;
    padding: 0 1.25rem;
    background: #f8f8f8;
    color: #777;
    border: 1px solid #ddd;
    border-radius: 23px;
    font-size: .86rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
}

.clear-button:hover { background: #ececec; color: #444; }

@media (max-width: 680px) {
    .search-bar-container { flex-direction: column; max-width: 100%; }
    .search-bar-wrapper { width: 100%; }
    .clear-button { width: 100%; }
}

/* ---- AUTOCOMPLETE DROPDOWN ---- */
.search-bar-wrapper {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 2px solid #d4a55a;
    border-top: none;
    border-radius: 0 0 12px 12px;
    max-height: 350px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin-top: -2px;
}

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
}

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

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

.autocomplete-item img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.autocomplete-no-image {
    width: 50px;
    height: 50px;
    background: #f5f5f5;
    border-radius: 6px;
    flex-shrink: 0;
}

.autocomplete-details {
    flex: 1;
    min-width: 0;
}

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

.autocomplete-price {
    font-size: 0.85rem;
    font-weight: 700;
    color: #22a95a;
    margin-top: 0.2rem;
}

.autocomplete-stock {
    font-size: 0.75rem;
    color: #888;
    white-space: nowrap;
}

.search-loading, .welcome-message, .no-results {
    text-align: center;
    padding: 2.5rem 1rem;
    color: #999;
}

.loading-spinner {
    width: 36px; height: 36px;
    border: 3px solid #f0f0f0;
    border-top-color: #ff8c42;
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 0.8s linear infinite;
}

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

.results-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.2rem;
    padding-bottom: .65rem;
    border-bottom: 1px solid #eee;
}

.results-count { font-size: .92rem; color: #555; }
.results-count strong { color: #ff8c42; }

/* ---- GRID ---- */
.products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 columns on desktop */
    gap: 1.2rem;
}

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

@media (max-width: 768px) {
    .products-grid { 
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
    
    /* Mobile horizontal cards - FIXED HEIGHT */
    .product-card {
        height: 140px !important;
        max-height: 140px !important;
        display: flex !important;
        flex-direction: row !important;
    }
    
    .product-card .product-image {
        width: 110px !important;
        min-width: 110px !important;
        height: 100% !important;
        flex-shrink: 0 !important;
    }
    
    .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;
    }
    
    .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;
    }
    
    .product-card .product-sku {
        font-size: 0.7rem !important;
        margin-bottom: 0.2rem !important;
    }
    
    .product-card .product-branch-tags {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.25rem !important;
        margin: 0.25rem 0 !important;
    }
    
    .product-card .branch-tag-small {
        font-size: 0.65rem !important;
        padding: 0.2rem 0.4rem !important;
    }
    
    .product-card .product-meta {
        margin-top: 0.3rem !important;
        margin-bottom: 0 !important;
    }
    
    .product-card .product-price {
        font-size: 1rem !important;
        line-height: 1.3 !important;
    }
    
    /* Buttons at BOTTOM RIGHT - with proper spacing */
    .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;
        margin-top: auto !important;
    }
    
    .product-card .product-actions .btn-view-product,
    .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;
        height: 30px !important;
        min-width: auto !important;
    }
    
    /* View button */
    .product-card .product-actions .btn-view-product {
        background: #fff !important;
        color: #555 !important;
        border: 1.5px solid #ddd !important;
    }
    
    /* Add to Cart button */
    .product-card .product-actions .btn-add-to-cart {
        background: #ff8c42 !important;
        color: #fff !important;
        border: none !important;
    }
    
    .product-card .stock-badge {
        font-size: 0.65rem !important;
        padding: 0.2rem 0.4rem !important;
    }
    
    /* CLEAN SEARCH BAR ON MOBILE */
    .search-bar-container {
        flex-direction: column !important;
        align-items: center !important;
        gap: 0.75rem !important;
    }
    
    .search-bar-wrapper {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    #branch-select {
        width: 100% !important;
        text-align: center !important;
    }
    
    #product-search {
        text-align: left !important;
        width: 100% !important;
    }
    
    .search-button {
        width: 100% !important;
    }
    
    .clear-button {
        width: 100% !important;
    }
}

/* Small mobile phones (320px - 480px) */
@media (max-width: 480px) {
    .product-card {
        height: 130px !important;
        max-height: 130px !important;
    }
    
    .product-card .product-image {
        width: 100px !important;
        min-width: 100px !important;
    }
    
    .product-card .product-info {
        padding: 0.6rem 0.65rem 0 0.65rem !important;
    }
    
    .product-card .product-name {
        font-size: 0.85rem !important;
    }
    
    .product-card .product-actions .btn-view-product,
    .product-card .product-actions .btn-add-to-cart {
        font-size: 0.65rem !important;
        padding: 0.4rem 0.55rem !important;
        height: 28px !important;
    }
}

@media (max-width: 480px) {
    .product-card {
        height: 130px; /* Even shorter on tiny screens */
    }
    
    .product-image {
        width: 100px; /* Smaller image on tiny screens */
        min-width: 100px;
    }
    
    .product-info {
        padding: 0.6rem;
    }
    
    .product-name {
        font-size: 0.85rem !important;
    }
}

/* ---- ULTRA COMPACT CARD - HORIZONTAL LAYOUT ALL DEVICES ---- */
.product-card {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 9px;
    overflow: hidden;
    display: flex;
    flex-direction: row; /* Horizontal on all devices */
    transition: all .25s;
    height: 145px; /* Reduced height for more compact look */
}

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

/* Image: Left side on all devices */
.product-image {
    position: relative;
    width: 140px; /* Desktop image width */
    min-width: 140px;
    height: 100%;
    background: #f8f8f8;
    overflow: hidden;
    flex-shrink: 0;
}

.product-image img {
    width: 100%; 
    height: 100%;
    object-fit: cover; /* Ensure image covers the space properly */
    object-position: center;
    transition: transform .3s;
}

.product-card:hover .product-image img { transform: scale(1.04); }

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

.no-image svg { width: 36px; height: 36px; }

.stock-badge {
    position: absolute;
    top: 5px; right: 5px;
    padding: .15rem .42rem;
    border-radius: 12px;
    font-size: .65rem;
    font-weight: 700;
    background: rgba(255,255,255,.95);
    box-shadow: 0 1px 3px rgba(0,0,0,.1);
}

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

/* Product info: Right side on all devices */
.product-info {
    padding: .75rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: .25rem;
    justify-content: space-between;
}

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

.product-sku {
    font-size: .68rem;
    color: #aaa;
}

.product-branch-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .22rem;
    margin: .08rem 0;
}

.branch-tag-small {
    display: inline-flex;
    padding: .14rem .4rem;
    background: #fff4ec;
    color: #d0641a;
    border: 1px solid #ffd9bb;
    border-radius: 14px;
    font-size: .6rem;
    font-weight: 600;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.branch-tag-more {
    display: inline-flex;
    padding: .14rem .4rem;
    background: #f5f5f5;
    color: #888;
    border-radius: 14px;
    font-size: .6rem;
}

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

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

.product-price .currency { font-size: .8rem; }

/* Hide units display */
.product-stock {
    display: none;
}

.product-actions {
    display: flex;
    gap: .35rem;
    margin-top: .4rem;
}

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

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

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

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

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

.btn-add-to-cart:disabled {
    background: #ddd;
    color: #999;
    cursor: not-allowed;
}

.btn-view-product svg,
.btn-add-to-cart svg {
    width: 13px; height: 13px; /* Smaller icons */
}

.error-message {
    background: #fff5f5;
    border: 1px solid #ffc5c5;
    color: #c53030;
    padding: .75rem 1rem;
    border-radius: 8px;
    margin: .65rem 0;
    font-size: .86rem;
}
