/* ============================================================
   Eastlink Espresso – Live Product Search
   Colours: #023934 | #024B44 | #E86A3F | #E4EEF0
   Fonts:   Oswald (labels/headings) | Roboto (body/results)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@400;500;600&family=Roboto:wght@400;500&display=swap');

/* ── Root variables ──────────────────────────────────────── */
:root {
    --el-dark:    #023934;
    --el-mid:     #024B44;
    --el-accent:  #E86A3F;
    --el-light:   #E4EEF0;
    --el-white:   #ffffff;
    --el-text:    #1a1a1a;
    --el-muted:   #666666;
    --el-radius:  4px;
    --el-shadow:  0 8px 32px rgba(2, 57, 52, 0.18);
}

/* ── Wrapper ─────────────────────────────────────────────── */
.el-search-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* ── Search bar container ────────────────────────────────── */
.el-search-bar {
    display: flex;
    align-items: center;
    background: var(--el-white);
    border-radius: var(--el-radius);
    overflow: visible;
    position: relative;
    height: 44px;
    min-width: 480px;
}

/* ── Category dropdown ───────────────────────────────────── */
.el-cat-dropdown {
    position: relative;
    flex-shrink: 0;
}

.el-cat-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    height: 44px;
    background: transparent;
    border: none;
    border-right: 1px solid #d0dde0;
    cursor: pointer;
    font-family: 'Oswald', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--el-dark);
    white-space: nowrap;
    transition: background 0.15s;
}

.el-cat-btn:hover {
    background: var(--el-light);
}

.el-cat-arrow {
    width: 10px;
    height: 6px;
    color: var(--el-muted);
    transition: transform 0.2s;
}

.el-cat-btn[aria-expanded="true"] .el-cat-arrow {
    transform: rotate(180deg);
}

.el-cat-list {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 160px;
    background: var(--el-white);
    border-radius: var(--el-radius);
    box-shadow: var(--el-shadow);
    list-style: none;
    margin: 0;
    padding: 4px 0;
    z-index: 9999;
}

.el-cat-list.open {
    display: block;
}

.el-cat-item {
    padding: 10px 16px;
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    color: var(--el-text);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}

.el-cat-item:hover,
.el-cat-item.active {
    background: var(--el-light);
    color: var(--el-dark);
    font-weight: 500;
}

.el-cat-item.active {
    color: var(--el-accent);
}

/* ── Text input ──────────────────────────────────────────── */
.el-search-input {
    flex: 1;
    height: 44px;
    border: none;
    outline: none;
    padding: 0 14px;
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    color: var(--el-text);
    background: transparent;
}

.el-search-input::placeholder {
    color: #aab8bc;
}

/* ── Submit button ───────────────────────────────────────── */
.el-search-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 44px;
    background: var(--el-accent);
    border: none;
    border-radius: 0 var(--el-radius) var(--el-radius) 0;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}

.el-search-submit:hover {
    background: #d45e32;
}

.el-search-submit svg {
    width: 18px;
    height: 18px;
}

/* ── Results dropdown ────────────────────────────────────── */
.el-results-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--el-white);
    border-radius: var(--el-radius);
    box-shadow: var(--el-shadow);
    z-index: 9998;
    overflow: hidden;
}

.el-results-dropdown.open {
    display: flex;
}

/* Two-column layout matching screenshot */
.el-results-best,
.el-results-other {
    padding: 14px 0;
}

.el-results-best {
    flex: 1.4;
    border-right: 1px solid #e8eff1;
}

.el-results-other {
    flex: 1;
}

.el-results-heading {
    font-family: 'Oswald', sans-serif;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--el-muted);
    padding: 0 16px 8px;
}

/* Best match item (with thumbnail) */
.el-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    text-decoration: none;
    color: var(--el-text);
    transition: background 0.12s;
}

.el-result-item:hover {
    background: var(--el-light);
    text-decoration: none;
    color: var(--el-dark);
}

.el-result-thumb {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 3px;
    background: #f5f8f9;
    flex-shrink: 0;
}

.el-result-name {
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    line-height: 1.3;
}

.el-result-name strong {
    font-weight: 500;
}

/* Other results item (text only) */
.el-result-other-item {
    display: block;
    padding: 7px 16px;
    font-family: 'Roboto', sans-serif;
    font-size: 13px;
    color: var(--el-text);
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
}

.el-result-other-item:hover {
    background: var(--el-light);
    color: var(--el-dark);
    text-decoration: none;
}

/* No results */
.el-no-results {
    padding: 16px;
    font-family: 'Roboto', sans-serif;
    font-size: 14px;
    color: var(--el-muted);
    width: 100%;
    text-align: center;
}

/* Loading */
.el-loading {
    padding: 16px;
    font-family: 'Roboto', sans-serif;
    font-size: 13px;
    color: var(--el-muted);
    width: 100%;
    text-align: center;
}

/* ── Mobile trigger (icon only) ──────────────────────────── */
.el-mobile-trigger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--el-white);
    padding: 0;
}

.el-mobile-trigger svg {
    width: 22px;
    height: 22px;
}

/* ── Mobile overlay ──────────────────────────────────────── */
.el-mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 57, 52, 0.7);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.el-mobile-overlay.open {
    display: flex;
}

.el-mobile-popup {
    background: var(--el-white);
    border-radius: 8px;
    padding: 24px 20px 20px;
    width: 100%;
    max-width: 480px;
    position: relative;
    box-shadow: var(--el-shadow);
}

.el-mobile-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: var(--el-muted);
    cursor: pointer;
    padding: 0;
}

.el-mobile-close:hover {
    color: var(--el-dark);
}

.el-search-bar--popup {
    min-width: unset;
    width: 100%;
    border-radius: var(--el-radius);
    height: auto;
}

.el-search-bar--popup .el-results-dropdown {
    left: 0;
    right: 0;
    top: calc(100% + 6px);
}

/* ── Responsive breakpoint ───────────────────────────────── */
@media (max-width: 768px) {
    .el-search-bar:not(.el-search-bar--popup) {
        display: none;
    }

    .el-mobile-trigger {
        display: flex;
    }

    /* Stack category dropdown above input+button row */
    .el-search-bar--popup {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .el-search-bar--popup .el-cat-dropdown {
        width: 100%;
    }

    .el-search-bar--popup .el-cat-btn {
        width: 100%;
        height: 44px;
        border: 1px solid #d0dde0;
        border-radius: var(--el-radius);
        justify-content: space-between;
    }

    /* Input + submit sit side by side on the second row */
    .el-search-bar--popup .el-input-row {
        display: flex;
        align-items: center;
        border: 1px solid #d0dde0;
        border-radius: var(--el-radius);
        overflow: hidden;
    }

    .el-search-bar--popup .el-search-input {
        flex: 1;
        height: 44px;
        border: none;
    }

    .el-search-bar--popup .el-search-submit {
        border-radius: 0 var(--el-radius) var(--el-radius) 0;
        height: 44px;
    }

    /* Single-column results on mobile — hide Other Results */
    .el-results-other {
        display: none !important;
    }

    .el-results-best {
        border-right: none;
        width: 100%;
        flex: unset;
    }

    .el-results-dropdown.open {
        flex-direction: column;
    }
}

@media (min-width: 769px) {
    .el-mobile-trigger {
        display: none;
    }
}
