/**
 * Holy Dog - AJAX Live Product Search Styles
 *
 * Matches the Holy Dog brand palette (blues, cream, Manrope/Fraunces).
 * Fully responsive; safe to embed in any Astra header widget area.
 *
 * @package HolydogArtboardsChild
 * @since   1.2.0
 */

/* ── Local design tokens (inherit from :root if available) ──── */
.holydog-search-widget {
    --hds-blue: #1C54A1;
    --hds-blue-dk: #174a8e;
    --hds-ink: #1B2A3F;
    --hds-muted: #5B6B80;
    --hds-line: #E3E8EF;
    --hds-bg: #F6F8FB;
    --hds-white: #FFFFFF;
    --hds-accent: #C8892A;
    /* warm gold - used for <mark> */
    --hds-r: 10px;
    --hds-shadow: 0 10px 36px rgba(27, 42, 63, 0.14);
    --hds-shadow-sm: 0 2px 12px rgba(27, 42, 63, 0.08);

    position: relative;
    width: 100%;
    /* Let the widget expand to fill its container, or set a larger max-width for very wide screens */
    max-width: 600px;
    font-family: 'Manrope', system-ui, -apple-system, sans-serif;
}

/* ── Search form row ─────────────────────────────────────────── */
.holydog-search-form {
    position: relative;
    display: flex;
    align-items: center;
}

/* Input field */
.holydog-search-input {
    width: 100%;
    height: 44px;
    padding: 0 38px 0 42px !important;
    /* left: icon space, right: clear btn */
    border: 1.5px solid var(--hds-line);
    border-radius: var(--hds-r);
    background: var(--hds-white);
    color: var(--hds-ink);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
    -webkit-appearance: none;
    box-sizing: border-box;
}

.holydog-search-input:focus {
    border-color: var(--hds-blue);
    box-shadow: 0 0 0 3px rgba(28, 84, 161, 0.13);
}

.holydog-search-input::placeholder {
    color: var(--hds-muted);
    font-weight: 400;
}

/* Hide browser's native clear/search decorations */
.holydog-search-input::-webkit-search-cancel-button,
.holydog-search-input::-webkit-search-decoration {
    display: none;
}

/* ── Search icon (left side, decorative) ────────────────────── */
.holydog-search-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--hds-muted);
    display: flex;
    align-items: center;
    pointer-events: none;
    transition: color 0.18s;
}

.holydog-search-input:focus~.holydog-search-icon,
.holydog-search-form:focus-within .holydog-search-icon {
    color: var(--hds-blue);
}

/* ── Clear button ────────────────────────────────────────────── */
.holydog-search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: none;
    background: var(--hds-bg);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hds-muted);
    padding: 0;
    transition: background 0.15s, color 0.15s;
}

.holydog-search-clear:hover {
    background: var(--hds-line);
    color: var(--hds-ink);
}

.holydog-search-clear[hidden] {
    display: none;
}

/* ── Results dropdown ────────────────────────────────────────── */
.holydog-search-results {
    position: absolute;
    top: calc(100% + 7px);
    left: 0;
    right: 0;
    z-index: 99999;
    background: var(--hds-white);
    border: 1.5px solid var(--hds-line);
    border-radius: var(--hds-r);
    box-shadow: var(--hds-shadow);
    max-height: 480px;
    overflow-y: auto;
    overflow-x: hidden;
    /* Hidden state */
    opacity: 0;
    transform: translateY(-8px) scale(0.99);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    /* Smooth scroll */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Visible state - toggled by JS */
.holydog-search-results.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Custom scrollbar (Webkit) */
.holydog-search-results::-webkit-scrollbar {
    width: 4px;
}

.holydog-search-results::-webkit-scrollbar-thumb {
    background: var(--hds-line);
    border-radius: 2px;
}

/* ── Loading state ───────────────────────────────────────────── */
.holydog-search-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 16px;
    color: var(--hds-muted);
    font-size: 13px;
}

/* Spinner */
.holydog-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--hds-line);
    border-top-color: var(--hds-blue);
    border-radius: 50%;
    animation: holydog-spin 0.7s linear infinite;
    flex-shrink: 0;
}

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

/* ── Empty state ─────────────────────────────────────────────── */
.holydog-search-empty {
    padding: 18px 16px;
    color: var(--hds-muted);
    font-size: 13px;
    text-align: center;
}

/* ── Results list ────────────────────────────────────────────── */
.holydog-results-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
}

/* Single result row */
.holydog-result-item {
    margin: 0;
    transition: background 0.12s;
}

.holydog-result-item+.holydog-result-item {
    border-top: 1px solid var(--hds-bg);
}

/* Active / hovered row */
.holydog-result-item.is-active,
.holydog-result-item:hover {
    background: var(--hds-bg);
}

/* Anchor - flex row */
.holydog-result-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    text-decoration: none;
    color: inherit;
}

/* Thumbnail cell */
.holydog-result-img {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--hds-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.holydog-result-img img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    display: block;
}

/* Placeholder when no image */
.holydog-result-no-img {
    color: var(--hds-muted);
    opacity: 0.5;
}

/* Text body */
.holydog-result-body {
    flex: 1 1 0;
    min-width: 0;
    /* prevents overflow */
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.holydog-result-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--hds-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* Highlighted matched text */
.holydog-result-title mark {
    background: transparent;
    color: var(--hds-blue);
    font-weight: 800;
}

.holydog-result-cat {
    font-size: 11px;
    color: var(--hds-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Price */
.holydog-result-price {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--hds-blue);
    white-space: nowrap;
    margin-left: auto;
}

/* ── "View all results" footer link ─────────────────────────── */
.holydog-view-all {
    display: block;
    padding: 10px 14px;
    border-top: 1.5px solid var(--hds-line);
    font-size: 12.5px;
    font-weight: 700;
    color: var(--hds-blue);
    text-decoration: none;
    text-align: center;
    letter-spacing: 0.03em;
    transition: background 0.15s, color 0.15s;
}

.holydog-view-all:hover {
    background: var(--hds-bg);
    color: var(--hds-blue-dk);
}

/* ── Responsive - collapse max-width on mobile ───────────────── */
@media (max-width: 600px) {
    .holydog-search-widget {
        max-width: 100%;
    }
}

/* ── Astra header integration helpers ───────────────────────── */
/* When the widget is inside an Astra header row, let it stretch */
.ast-builder-grid-row .holydog-search-widget,
.ast-header-html-widget .holydog-search-widget,
.ast-custom-html-widget .holydog-search-widget {
    max-width: 100% !important;
    width: 100%;
    min-width: 300px;
    /* Ensure a wider minimum width in the header */
}

/* Centre-align the input inside narrower header slots */
.widget.holydog-ajax-search-widget {
    display: flex;
    align-items: center;
    width: 100%;
}