/* ==========================================================
   CocoStore Live Search — Header search-as-you-type
   ========================================================== */

/* ---- Search Form (desktop: inline in header-right) ---- */
.cs-search {
    position: relative;
    display: flex;
    align-items: center;
}

.cs-search-input {
    width: 200px;
    height: 38px;
    padding: 0 36px 0 14px;          /* room for icon on right */
    background: var(--ccs-input-bg);
    border: 1px solid var(--ccs-input-border);
    border-radius: 8px;
    color: var(--ccs-text);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s, width 0.25s ease;
}

.cs-search-input::placeholder {
    color: var(--ccs-text-muted);
}

.cs-search-input:focus {
    border-color: var(--ccs-accent);
    width: 260px;
}

/* Magnifying glass icon (positioned inside input) */
.cs-search-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ccs-text-muted);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cs-search-icon svg {
    width: 16px;
    height: 16px;
}

/* ---- Results Dropdown ---- */
.cs-search-results {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 360px;
    max-height: 480px;
    overflow-y: auto;
    background: var(--ccs-surface);
    border: 1px solid var(--ccs-border);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    z-index: 10000;
}

/* Scrollbar styling */
.cs-search-results::-webkit-scrollbar {
    width: 6px;
}

.cs-search-results::-webkit-scrollbar-track {
    background: transparent;
}

.cs-search-results::-webkit-scrollbar-thumb {
    background: var(--ccs-border-hover);
    border-radius: 3px;
}

/* ---- Individual Result Item ---- */
.cs-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    text-decoration: none;
    color: var(--ccs-text);
    transition: background 0.15s;
    border-bottom: 1px solid var(--ccs-border);
}

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

.cs-search-item:hover {
    background: var(--ccs-surface-hover);
}

.cs-search-item:hover .cs-search-item-title {
    color: var(--ccs-accent);
}

/* Thumbnail */
.cs-search-item-thumb {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 6px;
    object-fit: cover;
    background: var(--ccs-input-bg);
    border: 1px solid var(--ccs-border);
}

/* Text block (title + price stacked) */
.cs-search-item-info {
    flex: 1;
    min-width: 0;                     /* allow text truncation */
}

.cs-search-item-title {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--ccs-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.15s;
}

.cs-search-item-price {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ccs-gold);
    margin-top: 2px;
}

/* Out of stock tag */
.cs-search-oos {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ccs-accent);
    opacity: 0.7;
    margin-left: 6px;
}

/* ---- Footer link ("View all results...") ---- */
.cs-search-footer {
    display: block;
    padding: 12px 14px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ccs-accent);
    text-decoration: none;
    border-top: 1px solid var(--ccs-border);
    transition: background 0.15s;
}

.cs-search-footer:hover {
    background: var(--ccs-surface-hover);
    color: var(--ccs-accent-hover);
}

/* ---- Loading / Empty States ---- */
.cs-search-status {
    padding: 24px 14px;
    text-align: center;
    color: var(--ccs-text-muted);
    font-size: 0.85rem;
}

.cs-search-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--ccs-border);
    border-top-color: var(--ccs-accent);
    border-radius: 50%;
    animation: cs-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

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

/* ---- Mobile Search (inside mobile nav panel) ---- */
.cs-search-mobile {
    padding: 16px;
    border-bottom: 1px solid var(--ccs-border);
}

.cs-search-mobile .cs-search-input {
    width: 100%;
}

.cs-search-mobile .cs-search-input:focus {
    width: 100%;
}

.cs-search-mobile .cs-search-results {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 0;
    max-height: 60vh;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .cs-search-input {
        width: 160px;
    }

    .cs-search-input:focus {
        width: 200px;
    }

    .cs-search-results {
        width: 320px;
    }
}

@media (max-width: 768px) {
    /* Hide desktop search on mobile — use mobile-nav version instead */
    .header-right .cs-search {
        display: none;
    }

    .cs-search-mobile .cs-search-results {
        border-radius: 0 0 10px 10px;
    }
}
