/* ============================================================
   Popup Search Bar v4.1
   All customizable values use CSS custom properties (--ps-*)
   set by the Elementor widget via {{WRAPPER}}.
   Fallback values = the defaults shown in the Elementor panel.
   ============================================================ */

/* ---- Trigger Button ---- */
.popsearch-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    cursor: pointer;
    padding: 6px;
    color: #ffffff !important;
    border-radius: 0;
    transition: opacity 0.2s ease;
    line-height: 1;
}
.popsearch-trigger svg {
    stroke: #ffffff !important;
}
.popsearch-trigger:hover {
    opacity: 0.7;
    background: none !important;
}

/* ---- Overlay ---- */
.popsearch-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: var(--ps-overlay-bg, rgba(0,0,0,0.55));
    backdrop-filter: blur(var(--ps-overlay-blur, 4px));
    -webkit-backdrop-filter: blur(var(--ps-overlay-blur, 4px));
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: var(--ps-modal-top, 80px);
    padding-left: 16px;
    padding-right: 16px;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.popsearch-overlay[hidden] { display: none !important; }
.popsearch-overlay.popsearch-visible { opacity: 1; }

/* ---- Modal Box ---- */
.popsearch-modal {
    background: var(--ps-modal-bg, #111111);
    border-radius: var(--ps-modal-radius, 14px);
    width: 100%;
    max-width: var(--ps-modal-width, 580px);
    box-shadow: 0 24px 60px rgba(0,0,0,0.22), 0 4px 16px rgba(0,0,0,0.10);
    overflow: hidden;
    position: relative;
    transform: translateY(-12px) scale(0.98);
    transition: transform 0.22s ease, opacity 0.22s ease;
    opacity: 0;
}
.popsearch-overlay.popsearch-visible .popsearch-modal {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* ---- Input Row ---- */
.popsearch-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: var(--ps-input-padding-v, 14px) 16px;
    border-bottom: 1px solid var(--ps-input-divider, #2a2a2a);
    background: var(--ps-input-bg, transparent);
}
.popsearch-icon {
    flex-shrink: 0;
    stroke: var(--ps-input-icon, #666666);
    color: var(--ps-input-icon, #666666);
}
#popsearch-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: var(--ps-input-font-size, 15px);
    font-family: inherit;
    color: var(--ps-input-text, #ffffff);
    background: transparent;
    line-height: 24px;
    min-width: 0;
    appearance: none;
    -webkit-appearance: none;
}
#popsearch-input::placeholder { color: var(--ps-input-placeholder, #555555); }
#popsearch-input::-webkit-search-cancel-button,
#popsearch-input::-webkit-search-decoration { -webkit-appearance: none; }

/* ---- Close Button ---- */
.popsearch-close {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--ps-close-bg, #222222);
    border: none;
    border-radius: var(--ps-close-radius, 6px);
    padding: 4px;
    cursor: pointer;
    color: var(--ps-close-color, #aaaaaa);
    transition: background 0.15s ease;
}
.popsearch-close:hover { background: #e8e8e8; }

/* ---- Keyboard shortcut badge ---- */
.popsearch-shortcut-keys {
    display: flex; gap: 4px; flex-shrink: 0; margin-right: 4px;
}
.popsearch-shortcut-keys kbd,
.popsearch-shortcut-hint kbd {
    display: inline-block;
    font-size: 10px; font-family: inherit;
    background: var(--ps-kbd-bg, #222222);
    border: 1px solid var(--ps-kbd-border, #333333);
    border-radius: 4px; padding: 2px 5px;
    color: var(--ps-kbd-color, #666666);
    line-height: 1.4;
}
.popsearch-shortcut-hint {
    text-align: center; font-size: 11px;
    color: var(--ps-shortcut-hint, #444444);
    padding: 10px 16px 4px;
}

/* ---- Filter tabs ---- */
.popsearch-filters {
    display: flex; gap: 0; padding: 0 12px;
    border-bottom: 1px solid var(--ps-filter-divider, #2a2a2a);
    overflow-x: auto; scrollbar-width: none;
}
.popsearch-filters::-webkit-scrollbar { display: none; }
.popsearch-filter-tab {
    display: inline-flex; align-items: center; gap: 5px;
    padding: var(--ps-filter-padding, 10px) 12px;
    font-size: var(--ps-filter-font-size, 13px);
    font-family: inherit; font-weight: 500;
    color: var(--ps-filter-color, #666666);
    background: none; border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer; white-space: nowrap;
    transition: color .15s, border-color .15s;
    margin-bottom: -1px;
}
.popsearch-filter-tab:hover { color: var(--ps-filter-hover, #cccccc); }
.popsearch-filter-tab.active {
    color: var(--ps-filter-active, #ffffff);
    border-bottom-color: var(--ps-filter-active-line, #ffffff);
}
.popsearch-filter-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px;
    font-size: 10px; font-weight: 600;
    background: var(--ps-filter-badge-bg, #2a2a2a);
    border-radius: 10px;
    color: var(--ps-filter-badge-color, #666666);
}
.popsearch-filter-tab.active .popsearch-filter-count {
    background: var(--ps-filter-badge-active-bg, #ffffff);
    color: var(--ps-filter-badge-active-color, #111111);
}

/* ---- Results count ---- */
.popsearch-count {
    font-size: 11px;
    color: var(--ps-results-count, #555555);
    padding: 6px 16px 0;
}

/* ---- Results list ---- */
.popsearch-results {
    max-height: var(--ps-results-max-height, 420px);
    overflow-y: auto;
    padding: 8px 0;
}
.popsearch-results:empty { display: none; }

/* ---- Section label ---- */
.popsearch-section-label {
    padding: 8px 16px;
    font-size: var(--ps-section-label-size, 11px);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ps-section-label, #555555);
    font-family: inherit;
}
.popsearch-section-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 16px 0;
}
.popsearch-section-row .popsearch-section-label { padding: 0; }

/* ---- Result item ---- */
.popsearch-result-item {
    display: flex; align-items: center; gap: 12px;
    padding: var(--ps-result-padding-v, 8px) 16px;
    text-decoration: none; color: inherit;
    border-radius: var(--ps-result-radius, 8px);
    margin: 0 8px;
    transition: background 0.12s ease;
    min-width: 0;
}
.popsearch-result-item:hover,
.popsearch-result-item:focus,
.popsearch-result-item.popsearch-focused {
    background: var(--ps-result-hover-bg, #1e1e1e);
    outline: none;
}

/* ---- Thumbnail ---- */
.popsearch-thumb {
    width: var(--ps-thumb-size, 40px);
    height: var(--ps-thumb-size, 40px);
    border-radius: var(--ps-thumb-radius, 6px);
    object-fit: cover; flex-shrink: 0;
}
.popsearch-thumb-placeholder {
    width: var(--ps-thumb-size, 40px);
    height: var(--ps-thumb-size, 40px);
    border-radius: var(--ps-thumb-radius, 6px);
    background: var(--ps-thumb-placeholder-bg, #222222);
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: #ccc;
}
.popsearch-thumb-sm { width: 32px !important; height: 32px !important; }

/* ---- Result text ---- */
.popsearch-result-text {
    display: flex; flex-direction: column; min-width: 0; flex: 1;
}
.popsearch-result-title {
    font-size: var(--ps-title-size, 15px);
    font-weight: 500;
    color: var(--ps-title-color, #ffffff);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    line-height: 20px;
}
.popsearch-result-meta {
    font-size: var(--ps-desc-size, 13px);
    color: var(--ps-desc-color, #888888);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    line-height: 20px;
}

/* ---- Highlight match ---- */
.popsearch-highlight {
    background: var(--ps-highlight-bg, transparent);
    color: var(--ps-highlight-color, inherit);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ---- Empty / loading state ---- */
.popsearch-state {
    padding: 24px 16px; text-align: center;
    font-size: var(--ps-state-font-size, 14px);
    color: var(--ps-state-color, #555555);
}
.popsearch-loading {
    display: flex; align-items: center; justify-content: center;
}

/* ---- Spinner ---- */
@keyframes popsearch-spin { to { transform: rotate(360deg); } }
.popsearch-spinner {
    display: inline-block; width: 14px; height: 14px;
    border: 2px solid #e0e0e0; border-top-color: #888;
    border-radius: 50%;
    animation: popsearch-spin .7s linear infinite;
    margin-right: 8px; vertical-align: middle; flex-shrink: 0;
}

/* ---- Product row ---- */
.popsearch-product-item { align-items: center; }
.popsearch-product-actions {
    display: flex; flex-direction: column;
    align-items: flex-end; gap: 6px;
    flex-shrink: 0; margin-left: 8px;
}
.popsearch-price {
    font-size: var(--ps-price-size, 13px);
    font-weight: 600;
    color: var(--ps-price-color, #ffffff);
    white-space: nowrap;
}
.popsearch-prod-link {
    text-decoration: none; color: inherit; display: block;
}
.popsearch-prod-link:hover {
    text-decoration: underline; text-underline-offset: 2px;
}

/* ---- Quick view trigger button ---- */
.popsearch-qv-trigger {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 5px 8px; font-size: 11px; font-weight: 600;
    font-family: inherit; white-space: nowrap;
    background: var(--ps-qv-bg, #222222);
    color: var(--ps-qv-color, #aaaaaa);
    border: 1px solid var(--ps-qv-border, #333333);
    border-radius: var(--ps-qv-radius, 6px);
    cursor: pointer; transition: background .15s;
}
.popsearch-qv-trigger:hover { filter: brightness(0.95); }

/* ---- Add to Cart button ---- */
.popsearch-atc-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 10px;
    font-size: var(--ps-atc-font-size, 12px);
    font-weight: 600; font-family: inherit; white-space: nowrap;
    background: var(--ps-atc-bg, #ffffff);
    color: var(--ps-atc-color, #111111);
    border: none;
    border-radius: var(--ps-atc-radius, 6px);
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    line-height: 1.4;
}
.popsearch-atc-btn:hover:not(:disabled) {
    filter: brightness(1.15);
    transform: translateY(-1px);
}
.popsearch-atc-btn:disabled { cursor: default; opacity: 0.7; }
.popsearch-atc-btn.popsearch-atc-success {
    background: var(--ps-atc-success-bg, #16a34a);
}

/* ---- Load more ---- */
.popsearch-load-more-wrap {
    display: flex; justify-content: center;
    padding: 10px 16px 14px;
}
.popsearch-load-more-btn {
    background: none;
    border: 1px solid var(--ps-load-more-border, #2a2a2a);
    border-radius: var(--ps-load-more-radius, 8px);
    font-size: var(--ps-load-more-font-size, 13px);
    font-family: inherit;
    color: var(--ps-load-more-color, #888888);
    padding: 7px 20px; cursor: pointer;
    transition: background 0.15s, border-color 0.15s; width: 100%;
}
.popsearch-load-more-btn:hover {
    background: var(--ps-load-more-hover-bg, #1e1e1e);
    filter: brightness(0.97);
}

/* ---- Browse all ---- */
.popsearch-browse-all {
    padding: 10px 16px 14px; text-align: center;
    border-top: 1px solid var(--ps-browse-border, #222222);
    margin-top: 4px;
}
.popsearch-browse-link {
    font-size: var(--ps-browse-font-size, 12px);
    color: var(--ps-browse-color, #555555);
    text-decoration: none; transition: color .15s;
}
.popsearch-browse-link:hover { filter: brightness(0.7); text-decoration: underline; }

/* ---- History items ---- */
.popsearch-history-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 16px; background: none; border: none;
    text-align: left; font-size: 14px; font-family: inherit;
    color: var(--ps-history-color, #cccccc);
    cursor: pointer; border-radius: 8px;
    margin: 0 8px; width: calc(100% - 16px);
    transition: background 0.12s;
}
.popsearch-history-item svg {
    flex-shrink: 0;
    color: var(--ps-history-icon, #444444);
    stroke: var(--ps-history-icon, #444444);
}
.popsearch-history-item:hover {
    background: var(--ps-history-hover-bg, #1e1e1e);
}
.popsearch-clear-btn {
    background: none; border: none;
    font-size: 11px; font-family: inherit;
    color: var(--ps-clear-btn, #555555);
    cursor: pointer; padding: 2px 4px;
    transition: color 0.15s;
}
.popsearch-clear-btn:hover { filter: brightness(0.7); }

/* ---- Media grid ---- */
.popsearch-media-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--ps-media-gap, 6px);
    padding: 6px 12px 8px;
}
.popsearch-media-item {
    display: block;
    border-radius: var(--ps-media-radius, 6px);
    overflow: hidden; aspect-ratio: 1;
    background: var(--ps-media-bg, #222222);
    transition: opacity .15s, transform .15s;
}
.popsearch-media-item:hover { opacity: .85; transform: scale(1.03); }
.popsearch-media-item img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---- Quick View panel ---- */
.popsearch-quickview {
    position: absolute; inset: 0;
    background: var(--ps-qv-panel-bg, #111111);
    border-radius: var(--ps-modal-radius, 14px);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform .22s cubic-bezier(.4,0,.2,1);
    z-index: 10;
}
.popsearch-quickview.popsearch-qv-open { transform: translateX(0); }
.popsearch-qv-inner { padding: 16px; }
.popsearch-qv-close {
    position: absolute; top: 12px; right: 12px;
    background: var(--ps-close-bg, #222222);
    border: none; border-radius: var(--ps-close-radius, 6px);
    padding: 5px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: var(--ps-close-color, #aaaaaa);
    transition: background .15s;
}
.popsearch-qv-close:hover { filter: brightness(0.93); }
.popsearch-qv-img-wrap {
    border-radius: var(--ps-qv-img-radius, 10px);
    overflow: hidden; margin-bottom: 8px;
    background: var(--ps-qv-img-bg, #222222);
    aspect-ratio: 4/3;
}
.popsearch-qv-img-wrap img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.popsearch-qv-thumbs {
    display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap;
}
.popsearch-qv-thumb {
    width: 48px; height: 48px; border-radius: 6px;
    object-fit: cover; border: 2px solid transparent;
    cursor: pointer; transition: border-color .15s;
}
.popsearch-qv-thumb.active { border-color: var(--ps-filter-active, #ffffff); }
.popsearch-qv-title {
    font-size: var(--ps-qv-title-size, 15px);
    font-weight: 600;
    color: var(--ps-qv-title-color, #ffffff);
    margin-bottom: 6px; line-height: 1.4;
}
.popsearch-qv-prices { margin-bottom: 8px; }
.popsearch-qv-price {
    font-size: 16px; font-weight: 600;
    color: var(--ps-qv-price-color, #ffffff);
}
.popsearch-qv-regular-price {
    font-size: 13px; text-decoration: line-through; margin-right: 6px;
    color: var(--ps-qv-reg-color, #555555);
}
.popsearch-qv-sale-price {
    font-size: 16px; font-weight: 700;
    color: var(--ps-qv-sale-color, #e53e3e);
}
.popsearch-qv-desc {
    font-size: var(--ps-qv-desc-size, 13px);
    color: var(--ps-qv-desc-color, #666666);
    line-height: 1.6; margin-bottom: 12px;
}
.popsearch-qv-outofstock {
    font-size: 12px; font-weight: 500; margin-bottom: 10px;
    color: var(--ps-qv-oos-color, #e53e3e);
}
.popsearch-qv-actions {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.popsearch-qv-full-link {
    font-size: 12px; text-decoration: none;
    color: var(--ps-qv-full-link, #888888);
}
.popsearch-qv-full-link:hover { text-decoration: underline; }
.popsearch-qv-loading, .popsearch-qv-err {
    display: flex; align-items: center; justify-content: center;
    height: 200px; font-size: 13px; color: #aaa; gap: 8px;
}

/* ---- Scrollbar ---- */
.popsearch-results::-webkit-scrollbar { width: 6px; }
.popsearch-results::-webkit-scrollbar-track { background: transparent; }
.popsearch-results::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }

/* Dark theme is the default — no media query needed */
    .popsearch-input-row    { border-bottom-color: var(--ps-input-divider, #2a2a2a); }
    #popsearch-input        { color: var(--ps-input-text, #eeeeee); }
    #popsearch-input::placeholder { color: var(--ps-input-placeholder, #555555); }
    .popsearch-close        { background: var(--ps-close-bg, #2a2a2a); color: var(--ps-close-color, #aaaaaa); }
    .popsearch-result-item:hover,
    .popsearch-result-item.popsearch-focused { background: var(--ps-result-hover-bg, #252525); }
    .popsearch-result-title { color: var(--ps-title-color, #eeeeee); }
    .popsearch-result-meta,
    .popsearch-section-label { color: var(--ps-desc-color, #666666); }
    .popsearch-thumb-placeholder { background: var(--ps-thumb-placeholder-bg, #2a2a2a); }
    .popsearch-state        { color: var(--ps-state-color, #666666); }
    .popsearch-filter-tab   { color: var(--ps-filter-color, #555555); }
    .popsearch-filter-tab:hover { color: var(--ps-filter-hover, #aaaaaa); }
    .popsearch-filter-tab.active { color: var(--ps-filter-active, #eeeeee); border-bottom-color: var(--ps-filter-active-line, #eeeeee); }
    .popsearch-filter-count { background: var(--ps-filter-badge-bg, #2a2a2a); color: var(--ps-filter-badge-color, #666666); }
    .popsearch-filter-tab.active .popsearch-filter-count { background: var(--ps-filter-badge-active-bg, #eeeeee); color: var(--ps-filter-badge-active-color, #111111); }
    .popsearch-filters      { border-bottom-color: var(--ps-filter-divider, #2a2a2a); }
    .popsearch-load-more-btn { border-color: var(--ps-load-more-border, #333333); color: var(--ps-load-more-color, #aaaaaa); }
    .popsearch-quickview    { background: var(--ps-qv-panel-bg, #1a1a1a); }
    .popsearch-qv-img-wrap  { background: var(--ps-qv-img-bg, #2a2a2a); }
    .popsearch-qv-title     { color: var(--ps-qv-title-color, #eeeeee); }
    .popsearch-qv-price     { color: var(--ps-qv-price-color, #eeeeee); }
    .popsearch-qv-desc      { color: var(--ps-qv-desc-color, #888888); }
    .popsearch-history-item { color: var(--ps-history-color, #cccccc); }
    .popsearch-media-item   { background: var(--ps-media-bg, #2a2a2a); }
    .popsearch-shortcut-keys kbd { background: var(--ps-kbd-bg, #2a2a2a); border-color: var(--ps-kbd-border, #3a3a3a); color: var(--ps-kbd-color, #666666); }
    .popsearch-browse-all   { border-top-color: var(--ps-browse-border, #222222); }
    .popsearch-browse-link  { color: var(--ps-browse-color, #555555); }
    .popsearch-qv-trigger   { background: var(--ps-qv-bg, #2a2a2a); color: var(--ps-qv-color, #aaaaaa); border-color: var(--ps-qv-border, #333333); }
}
