/* ================================
   WRAPPER
   ================================ */
.cps-wrapper {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    z-index: 99999;
}

/* ================================
   INPUT BOX
   ================================ */
.cps-input-box {
    position: relative;
    display: flex;
    align-items: center;
}

.cps-icon {
    position: absolute !important;
    left: 14px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 20px !important;
    height: 20px !important;
    color: #94a3b8;
    pointer-events: none;
    z-index: 2;
    margin: 0 !important;
    padding: 0 !important;
}

.cps-input {
    width: 100% !important;
    padding: 14px 80px 14px 46px !important;
    font-size: 16px !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 14px !important;
    outline: none !important;
    background: #fff !important;
    transition: all 0.2s ease;
    color: #1e293b !important;
    box-sizing: border-box !important;
    -webkit-appearance: none;
    appearance: none;
    margin: 0 !important;
    min-height: 0 !important;
    height: auto !important;
    line-height: normal !important;
    text-indent: 0 !important;
}

.cps-input:focus {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1) !important;
    background: #fff !important;
    color: #1e293b !important;
}

.cps-input::placeholder {
    color: #94a3b8;
}

/* ================================
   LOADER
   ================================ */
.cps-loader {
    position: absolute;
    right: 46px;
    width: 18px;
    height: 18px;
    border: 2.5px solid #e2e8f0;
    border-top-color: #6366f1;
    border-radius: 50%;
    display: none;
    animation: cps-spin 0.5s linear infinite;
}

.cps-loader.active {
    display: block;
}

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

/* ================================
   CLEAR BUTTON
   ================================ */
.cps-clear {
    position: absolute;
    right: 12px;
    width: 28px;
    height: 28px;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    font-size: 18px;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    line-height: 1;
    padding: 0;
}

.cps-clear:hover {
    background: #e2e8f0;
    color: #334155;
}

/* ================================
   DROPDOWN
   ================================ */
.cps-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.12), 0 4px 20px rgba(0,0,0,0.06);
    border: 1px solid #e8ecf1;
    display: none;
    max-height: 480px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

.cps-dropdown.active {
    display: block;
    animation: cps-fadeIn 0.15s ease;
}

@keyframes cps-fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.cps-dropdown::-webkit-scrollbar { width: 5px; }
.cps-dropdown::-webkit-scrollbar-track { background: transparent; }
.cps-dropdown::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ================================
   SUGGESTION BAR
   ================================ */
.cps-suggestion {
    padding: 10px 16px;
    font-size: 13px;
    color: #64748b;
    background: #fefce8;
    border-bottom: 1px solid #fef08a;
    border-radius: 14px 14px 0 0;
}

.cps-suggestion-link {
    background: none;
    border: none;
    color: #6366f1;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    font-size: 13px;
    padding: 0;
}

.cps-suggestion-link:hover {
    color: #4338ca;
}

/* ================================
   RESULT ITEM
   ================================ */
.cps-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none !important;
    color: inherit !important;
    border-bottom: 1px solid #f1f5f9;
    transition: background-color 0.12s ease;
}

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

.cps-item:hover,
.cps-item.cps-active {
    background-color: #f8fafc;
}

/* ================================
   ITEM IMAGE
   ================================ */
.cps-item-img {
    position: relative;
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    margin-right: 14px;
    border-radius: 10px;
    overflow: hidden;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
}

.cps-item-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cps-item-img .cps-badge-sale {
    position: absolute;
    top: 4px;
    left: 4px;
    font-size: 9px;
    padding: 2px 5px;
}

/* ================================
   ITEM INFO
   ================================ */
.cps-item-info {
    flex: 1;
    min-width: 0;
}

.cps-item-title {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cps-item-title mark {
    background-color: #fef08a;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

/* ================================
   PRICE
   ================================ */
.cps-item-price {
    font-size: 14px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.cps-price-current {
    font-weight: 700;
    color: #059669;
}

.cps-price-current.cps-price-sale {
    color: #dc2626;
}

.cps-price-old {
    font-size: 12px;
    color: #94a3b8;
    text-decoration: line-through;
}

/* ================================
   BADGES
   ================================ */
.cps-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    letter-spacing: 0.02em;
}

.cps-badge-instock { background: #dcfce7; color: #16a34a; }
.cps-badge-outofstock { background: #fee2e2; color: #dc2626; }

.cps-badge-sale {
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ================================
   VIEW ALL
   ================================ */
.cps-view-all {
    display: block;
    text-align: center;
    padding: 14px 16px;
    font-size: 13px;
    color: #6366f1 !important;
    text-decoration: none !important;
    border-top: 1px solid #f1f5f9;
    transition: background-color 0.12s ease;
    font-weight: 500;
}

.cps-view-all:hover { background-color: #f8fafc; }

/* ================================
   NO RESULTS
   ================================ */
.cps-empty {
    padding: 32px 20px;
    text-align: center;
}

.cps-empty p {
    margin: 0 0 8px;
    font-size: 14px;
    color: #475569;
}

.cps-empty-hint {
    color: #94a3b8 !important;
    font-size: 13px !important;
}

/* ================================
   DESKTOP
   ================================ */
@media (min-width: 769px) {
    .cps-wrapper {
        min-width: 350px;
        max-width: 600px;
    }
}

/* ================================
   RESPONSIVE
   ================================ */
@media (max-width: 768px) {
    .cps-wrapper { max-width: 100%; }

    .cps-input {
        font-size: 15px;
        padding: 12px 70px 12px 42px;
        border-radius: 12px;
    }

    .cps-dropdown {
        max-height: 380px;
        border-radius: 12px;
    }

    .cps-item-img { width: 50px; height: 50px; }
    .cps-item { padding: 10px 14px; }
}

@media (max-width: 400px) {
    .cps-item-img { width: 44px; height: 44px; margin-right: 10px; }
    .cps-item-title { font-size: 13px; }
    .cps-item-price { font-size: 13px; }
}

/* ================================
   OFFCANVAS / MOBILE PANEL — DARK BACKGROUND
   ================================ */
.ct-panel .cps-wrapper,
.ct-offcanvas .cps-wrapper,
[data-panel] .cps-wrapper {
    max-width: 100%;
    padding: 0;
    margin: 10px 0 15px 0;
}

.ct-panel .cps-input,
.ct-offcanvas .cps-input,
[data-panel] .cps-input,
.ct-panel .cps-wrapper .cps-input,
.ct-offcanvas .cps-wrapper .cps-input,
[data-panel] .cps-wrapper .cps-input {
    font-size: 16px !important;
    border-radius: 10px !important;
    padding: 12px 70px 12px 42px !important;
    background: rgba(255, 255, 255, 0.12) !important;
    border: 2px solid rgba(255, 255, 255, 0.25) !important;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
}

.ct-panel .cps-input::placeholder,
.ct-offcanvas .cps-input::placeholder,
[data-panel] .cps-input::placeholder,
.ct-panel .cps-wrapper .cps-input::placeholder,
.ct-offcanvas .cps-wrapper .cps-input::placeholder,
[data-panel] .cps-wrapper .cps-input::placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
    -webkit-text-fill-color: rgba(255, 255, 255, 0.5) !important;
    opacity: 1 !important;
}

.ct-panel .cps-input:focus,
.ct-offcanvas .cps-input:focus,
[data-panel] .cps-input:focus,
.ct-panel .cps-wrapper .cps-input:focus,
.ct-offcanvas .cps-wrapper .cps-input:focus,
[data-panel] .cps-wrapper .cps-input:focus {
    background: rgba(255, 255, 255, 0.18) !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
    box-shadow: none !important;
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
}

.ct-panel .cps-icon,
.ct-offcanvas .cps-icon,
[data-panel] .cps-icon,
.ct-panel .cps-wrapper .cps-icon,
.ct-offcanvas .cps-wrapper .cps-icon,
[data-panel] .cps-wrapper .cps-icon {
    color: rgba(255, 255, 255, 0.5) !important;
}

.ct-panel .cps-clear,
.ct-offcanvas .cps-clear,
[data-panel] .cps-clear {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.7);
}

.ct-panel .cps-clear:hover,
.ct-offcanvas .cps-clear:hover,
[data-panel] .cps-clear:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.ct-panel .cps-loader,
.ct-offcanvas .cps-loader,
[data-panel] .cps-loader {
    border-color: rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
}

/* Dropdown inside offcanvas — white background for readability */
.ct-panel .cps-dropdown.active,
.ct-offcanvas .cps-dropdown.active,
[data-panel] .cps-dropdown.active {
    position: relative !important;
    top: 8px !important;
    left: 0 !important;
    right: 0 !important;
    max-height: 50vh;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    background: #fff;
}

/* Results stay dark text on white background */
.ct-panel .cps-item-title,
.ct-offcanvas .cps-item-title,
[data-panel] .cps-item-title {
    color: #1e293b !important;
}

.ct-panel .cps-item,
.ct-offcanvas .cps-item,
[data-panel] .cps-item {
    color: #1e293b !important;
}

.ct-panel .cps-empty p,
.ct-offcanvas .cps-empty p,
[data-panel] .cps-empty p {
    color: #475569 !important;
}

.ct-panel .cps-view-all,
.ct-offcanvas .cps-view-all,
[data-panel] .cps-view-all {
    color: #6366f1 !important;
}

/* Fix offcanvas overflow so dropdown scrolls properly */
.ct-panel,
.ct-panel .ct-panel-content,
.ct-offcanvas,
[data-panel],
[data-panel] > div {
    overflow-y: auto !important;
    overflow-x: hidden !important;
}