/* ============================================================
   Qr-search.css
   QR Scanner + Business/Product Search styles
   Part 1: Home search bar UI only
   ============================================================ */

#searchBarContainer{
    display:flex;
    align-items:center;
    ga:10px;
    background:var(--card-bg,#fff);
    border-radius:16px;
    paddin:12px;
    margin: 0;
    box-shadow:0 2px 8px rgba(0,0,0,0.08);
    box-sizing:border-box;
    width:100%;
}

#qrScannerButton{
    flex:0 0 auto;
    height:46px;
    width:46px;
    min-width:46px;
    border:none;
    border-radius:12px;
    background:var(--primary-color,#16a34a);
    color:#fff;
    font-size:20px;
    line-height:1;
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    box-shadow:0 2px 6px rgba(22,163,74,0.35);
    transition:transform .12s ease, background .2s ease;
}

#qrScannerButton:hover{
    background:var(--primary-color-dark,#0f7a37);
}

#qrScannerButton:active{
    transform:scale(0.92);
}

#qrScannerButton:focus-visible{
    outline:2px solid var(--primary-color-dark,#0f7a37);
    outline-offset:2px;
}

#searchInputWrap{
    position:relative;
    flex:1 1 auto;
    min-width:0;
    display:flex;
    align-items:center;
}

#searchInputIcon{
    position:absolute;
    left:14px;
    font-size:15px;
    color:var(--text-muted,#777);
    pointer-events:none;
}

#businessSearch{
    width:100%;
    height:46px;
    padding:0 38px 0 38px;
    border:1px solid #e2e2e2;
    border-radius:999px;
    background:#fff;
    font-size:15px;
    color:var(--text-dark,#222);
    outline:none;
    box-sizing:border-box;
    transition:border-color .2s ease, box-shadow .2s ease;
}

#businessSearch::placeholder{
    color:var(--text-muted,#777);
}

#businessSearch:focus{
    border-color:var(--primary-color,#16a34a);
    box-shadow:0 0 0 3px rgba(22,163,74,0.15);
}

#clearBusinessSearch{
    position:absolute;
    right:8px;
    height:28px;
    width:28px;
    min-width:28px;
    border:none;
    border-radius:50%;
    background:transparent;
    color:var(--text-muted,#777);
    font-size:14px;
    display:none;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    padding:0;
    transition:background .15s ease, color .15s ease;
}

#clearBusinessSearch.is-visible{
    display:flex;
}

#clearBusinessSearch:hover{
    background:rgba(0,0,0,0.06);
    color:var(--text-dark,#222);
}

#clearBusinessSearch:active{
    transform:scale(0.92);
}

#clearBusinessSearch:focus-visible{
    outline:2px solid var(--primary-color,#16a34a);
    outline-offset:2px;
}

/* Desktop: centred, same max width as listings */
@media (min-width:1024px){
    #searchBarContainer{
        max-width:100%;
        margin-left:auto;
        margin-right:auto;
    }
}

/* Mobile safety: never allow horizontal scroll */
@media (max-width:400px){
    #searchBarContainer{
        padding:10px;
        gap:8px;
    }
    #qrScannerButton{
        height:42px;
        width:42px;
        min-width:42px;
        font-size:18px;
    }
    #businessSearch{
        height:42px;
        font-size:14px;
    }
    #clearBusinessSearch{
        height:26px;
        width:26px;
        min-width:26px;
        right:6px;
    }
}

/* ============================================================
   Part 2: QR Scanner Overlay
   ============================================================ */

.qr-scanner-overlay{
    position:fixed;
    inset:0;
    z-index:99999;
    display:none;
    flex-direction:column;
    align-items:center;
    background:rgba(0,0,0,0.95);
    padding:0 16px 32px;
    box-sizing:border-box;
    overscroll-behavior:contain;
}

.qr-scanner-overlay.is-open{
    display:flex;
}

#qrScannerHeader{
    width:100%;
    max-width:520px;
    display:flex;
    align-items:center;
    gap:12px;
    padding:16px 4px;
    flex:0 0 auto;
}

#closeQrScanner{
    height:42px;
    width:42px;
    border:none;
    border-radius:50%;
    background:rgba(255,255,255,0.12);
    color:#fff;
    font-size:18px;
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    transition:background .2s ease, transform .12s ease;
}

#closeQrScanner:hover{ background:rgba(255,255,255,0.22); }
#closeQrScanner:active{ transform:scale(0.92); }

#qrScannerTitle{
    color:#fff;
    font-size:17px;
    font-weight:600;
}

#qrScannerBox{
    width:70vw;
    height:70vw;
    max-width:400px;
    max-height:400px;
    margin:auto 0;
    border-radius:20px;
    overflow:hidden;
    background:#111;
    position:relative;
    border:3px solid rgba(255,255,255,0.75);
    transition:border-color .3s ease, box-shadow .3s ease;
    flex:0 0 auto;
}

#qrReader{
    width:100%;
    height:100%;
}

#qrReader video,
#qrReader canvas{
    width:100% !important;
    height:100% !important;
    object-fit:cover;
    display:block;
}

#qrReader__dashboard,
#qrReader__header_message,
#qrReader img[alt="Info icon"]{
    display:none !important;
}

/* Border states */
#qrScannerBox.qr-state-default{
    border-color:rgba(255,255,255,0.75);
    box-shadow:none;
}

#qrScannerBox.qr-state-scanning{
    border-color:#ef4444;
    animation:qrPulse 1.2s ease-in-out infinite;
}

#qrScannerBox.qr-state-success{
    border-color:#22c55e;
    box-shadow:0 0 0 6px rgba(34,197,94,0.25);
    animation:none;
}

@keyframes qrPulse{
    0%   { box-shadow:0 0 0 0 rgba(239,68,68,0.55); border-color:#ef4444; }
    70%  { box-shadow:0 0 0 14px rgba(239,68,68,0); border-color:#f87171; }
    100% { box-shadow:0 0 0 0 rgba(239,68,68,0); border-color:#ef4444; }
}

#qrScannerInstructions{
    margin:24px 0 auto;
    text-align:center;
    flex:0 0 auto;
}

#qrInstructionMain{
    margin:0;
    color:#fff;
    font-size:16px;
    font-weight:600;
}

#qrInstructionSub{
    margin:6px 0 0;
    color:rgba(255,255,255,0.65);
    font-size:13px;
}

body.qr-scanner-open{
    overflow:hidden;
}

@media (max-width:400px){
    #qrScannerTitle{ font-size:16px; }
    #qrInstructionMain{ font-size:15px; }
}

/* ============================================================
   Part 4: Live search suggestions dropdown
   ============================================================ */

#searchSuggestions{
    position:absolute;
    top:calc(100% + 8px);
    left:0;
    right:0;
    display:none;
    max-height:60vh;
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
    background:#fff;
    border:1px solid #eee;
    border-radius:14px;
    box-shadow:0 8px 24px rgba(0,0,0,0.14);
    z-index:9000;
    box-sizing:border-box;
}

#searchSuggestions.is-open{ display:block; }

.searchSuggestionGroup{
    padding:8px 14px 4px;
    font-size:12px;
    font-weight:700;
    letter-spacing:.4px;
    text-transform:uppercase;
    color:var(--text-muted,#888);
    background:#fafafa;
    border-bottom:1px solid #f0f0f0;
}

.searchSuggestionItem{
    display:flex;
    align-items:center;
    gap:10px;
    min-height:48px;
    padding:8px 14px;
    cursor:pointer;
    border-bottom:1px solid #f4f4f4;
    box-sizing:border-box;
}

.searchSuggestionItem:last-child{ border-bottom:none; }

.searchSuggestionItem:hover,
.searchSuggestionItem.is-active{
    background:rgba(22,163,74,0.10);
}

.searchSuggestionThumb{
    flex:0 0 auto;
    height:36px;
    width:36px;
    border-radius:9px;
    object-fit:cover;
    background:#f1f1f1;
    display:flex;
    align-items:center;
    justify-content:center;
    color:var(--primary-color,#16a34a);
    font-size:15px;
    overflow:hidden;
}

.searchSuggestionThumb img{
    height:100%;
    width:100%;
    object-fit:cover;
    display:block;
}

.searchSuggestionText{
    min-width:0;
    flex:1 1 auto;
}

.searchSuggestionTitle{
    font-size:14px;
    font-weight:600;
    color:var(--text-dark,#222);
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}

.searchSuggestionSub{
    font-size:12px;
    color:var(--text-muted,#777);
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}

.searchSuggestionMessage{
    padding:14px;
    font-size:14px;
    text-align:center;
    color:var(--text-muted,#777);
}

/* ============================================================
   Part 5: Search Results section
   ============================================================ */

#searchResultsHeader{
    display:flex;
    align-items:center;
    gap:12px;
    margin:2px 0 10px;
}

#searchResultsBackBtn{
    height:40px;
    width:40px;
    min-width:40px;
    border:none;
    border-radius:12px;
    background:var(--card-bg,#fff);
    color:var(--text-dark,#222);
    font-size:16px;
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    box-shadow:0 2px 8px rgba(0,0,0,0.08);
    transition:transform .12s ease, background .2s ease;
}

#searchResultsBackBtn:hover{ background:#f3f3f3; }
#searchResultsBackBtn:active{ transform:scale(0.92); }

#searchResultsTitle{
    font-size:18px;
    font-weight:700;
    color:var(--text-dark,#222);
    margin:0;
}

#searchResultsQuery{
    font-size:14px;
    color:var(--text-muted,#777);
    margin:0 0 14px;
    word-break:break-word;
}

#searchResultsQueryText{
    color:var(--primary-color,#16a34a);
    font-weight:700;
}

#searchResultsLoading{
    padding:24px 0;
    text-align:center;
    font-size:14px;
    color:var(--text-muted,#777);
}

.searchResultsHeading{
    display:flex;
    align-items:center;
    gap:10px;
    font-size:15px;
    font-weight:700;
    color:var(--text-dark,#222);
    margin:14px 0 10px;
}

.searchResultsHeading::after{
    content:"";
    flex:1;
    height:1px;
    background:#e2e2e2;
}

.searchResultsCardWrap{
    background:var(--card-bg,#fff);
    border-radius:14px;
    padding:18px 14px;
    box-shadow:0 2px 10px rgba(0,0,0,.06);
    box-sizing:border-box;
    width:100%;
}

#searchBusinessesGrid{
    display:grid;
    grid-template-columns:repeat(6,1fr);
    gap:22px 16px;
}

#searchProductsGrid{
    display:grid;
    grid-template-columns:repeat(4,1fr);
    gap:16px;
}

@media (max-width:768px){
    #searchBusinessesGrid{
        grid-template-columns:repeat(4,1fr);
        gap:20px 14px;
    }
    #searchProductsGrid{
        grid-template-columns:repeat(3,1fr);
        gap:14px;
    }
}

@media (max-width:600px){
    #searchBusinessesGrid{
        grid-template-columns:repeat(3,1fr);
        gap:18px 12px;
    }
    #searchProductsGrid{
        grid-template-columns:repeat(2,1fr);
        gap:12px;
    }
}

/* Product result card */
.searchProductCard{
    background:var(--card-bg,#fff);
    border:1px solid #f0f0f0;
    border-radius:14px;
    overflow:hidden;
    cursor:pointer;
    box-shadow:0 2px 8px rgba(0,0,0,0.06);
    transition:transform .12s ease, box-shadow .2s ease;
    display:flex;
    flex-direction:column;
    min-width:0;
}

.searchProductCard:active{ transform:scale(0.98); }
.searchProductCard:hover{ box-shadow:0 6px 16px rgba(0,0,0,0.10); }

.searchProductImage{
    width:100%;
    aspect-ratio:1/1;
    object-fit:cover;
    display:block;
    background:#f4f4f4;
}

.searchProductImagePlaceholder{
    width:100%;
    aspect-ratio:1/1;
    background:#f4f4f4;
    display:flex;
    align-items:center;
    justify-content:center;
    color:var(--primary-color,#16a34a);
    font-size:26px;
}

.searchProductInfo{
    padding:10px;
    min-width:0;
}

.searchProductTitle{
    font-size:14px;
    font-weight:600;
    color:var(--text-dark,#222);
    margin:0 0 2px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}

.searchProductBusiness,
.searchProductDistance{
    font-size:12px;
    color:var(--text-muted,#777);
    margin:0;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}

.searchProductPrice{
    display:block;
    margin:4px 0 2px;
    font-size:14px;
    font-weight:700;
    color:var(--primary-color,#16a34a);
}

/* Empty state */
#searchResultsEmpty{
    text-align:center;
    padding:46px 18px;
    background:var(--card-bg,#fff);
    border-radius:14px;
    box-shadow:0 2px 10px rgba(0,0,0,.06);
}

#searchResultsEmpty i{
    font-size:34px;
    color:var(--primary-color,#16a34a);
    margin-bottom:12px;
    display:block;
}

#searchResultsEmpty h3{
    font-size:17px;
    color:var(--text-dark,#222);
    margin:0 0 6px;
}

#searchResultsEmptyText{
    font-size:14px;
    color:var(--text-muted,#777);
    margin:0;
    word-break:break-word;
}

/* Highlight for the product found after opening a business page */
.searchProductHighlight{
    outline:3px solid var(--primary-color,#16a34a);
    outline-offset:2px;
    border-radius:14px;
    animation:searchProductPulse 1s ease-in-out 2;
}

@keyframes searchProductPulse{
    0%   { box-shadow:0 0 0 0 rgba(22,163,74,0.45); }
    70%  { box-shadow:0 0 0 12px rgba(22,163,74,0); }
    100% { box-shadow:0 0 0 0 rgba(22,163,74,0); }
}
