/*
 * EmotoSearch – Frontend CSS
 * Styl wyszukiwarki AJAX z podpowiedziami. Kolory dopasowane do emoto (czerwień, biel).
 */

/* ── Wrapper formularza ──────────────────────────────────────────────────── */
.es-search-form {
    position: relative;
    width: 100%;
    margin: 0;
    padding: 0;
}

/* Pill container — border + radius tutaj, NIE na input/button */
.es-search-wrap {
    position: relative !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    min-height: 48px !important;
    height: 48px !important;
    background: #ffffff !important;
    border: 2px solid #dde0e4 !important;
    border-radius: 50px !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    transition: border-color .18s, box-shadow .18s;
}

.es-search-wrap:focus-within {
    border-color: #e63946 !important;
    box-shadow: 0 0 0 3px rgba(230, 57, 70, .13) !important;
}

/* ── Przycisk szukaj (ikona po LEWEJ, flex child) ───────────────────────── */
.es-search-btn {
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-radius: 50px 0 0 50px !important;
    color: #adb5bd !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    position: static !important;
    top: auto !important;
    right: auto !important;
    left: auto !important;
    transform: none !important;
    transition: color .15s;
    outline: none !important;
    -webkit-appearance: none;
    appearance: none;
    float: none !important;
    vertical-align: middle !important;
}

.es-search-btn:hover {
    color: #e63946 !important;
}

.es-search-btn svg {
    pointer-events: none;
    display: block !important;
    transition: opacity .15s;
    flex-shrink: 0;
}

/* ── Input ───────────────────────────────────────────────────────────────── */
.es-search-input {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 16px 0 0 !important;
    margin: 0 !important;
    font-size: 15px !important;
    font-family: inherit !important;
    color: #1a1a1a !important;
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box !important;
    display: block !important;
    position: static !important;
    float: none !important;
    line-height: normal !important;
}

.es-search-input:focus {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

.es-search-input::placeholder {
    color: #adb5bd !important;
}

/* Remove default browser "x" clear button inside search input */
.es-search-input::-webkit-search-decoration,
.es-search-input::-webkit-search-cancel-button,
.es-search-input::-webkit-search-results-button,
.es-search-input::-webkit-search-results-decoration {
    display: none;
}

/* ── Spinner (loading state) ─────────────────────────────────────────────── */
.es-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(174, 174, 174, .35);
    border-top-color: #adb5bd;
    border-radius: 50%;
    animation: es-spin .65s linear infinite;
    position: absolute;
}

.es-search-btn.es-loading svg         { opacity: 0; }
.es-search-btn.es-loading .es-spinner { display: block; }

@keyframes es-spin {
    to { transform: rotate(360deg); }
}

/* ── Dropdown ────────────────────────────────────────────────────────────── */
.es-results-wrap {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e4e8ed;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .13);
    z-index: 999999;
    overflow: hidden;
    max-height: 480px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.es-results-wrap.es-open {
    display: block;
    animation: es-fadein .12s ease;
}

@keyframes es-fadein {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Scrollbar (WebKit) */
.es-results-wrap::-webkit-scrollbar { width: 5px; }
.es-results-wrap::-webkit-scrollbar-track { background: transparent; }
.es-results-wrap::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 3px; }
.es-results-wrap::-webkit-scrollbar-thumb:hover { background: #ccc; }

/* ── Lista wyników ───────────────────────────────────────────────────────── */
.es-results-list {
    list-style: none;
    margin: 0;
    padding: 6px 0;
}

/* ── Pojedynczy wynik ────────────────────────────────────────────────────── */
.es-item {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f4f4f4;
    transition: background .1s;
    text-decoration: none;
    color: inherit;
}

.es-item:last-child {
    border-bottom: none;
}

.es-item:hover,
.es-item--active {
    background: #fff5f5;
}

/* ── Zdjęcie produktu ────────────────────────────────────────────────────── */
.es-item-img {
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid #efefef;
    background: #fafafa;
    flex-shrink: 0;
    display: block;
}

.es-item-img--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Treść (tytuł, SKU, marka) ───────────────────────────────────────────── */
.es-item-body {
    flex: 1;
    min-width: 0;
}

.es-item-title {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.es-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 3px;
    flex-wrap: wrap;
}

.es-item-sku {
    font-size: 12px;
    color: #666;
}

.es-item-ean {
    font-size: 12px;
    color: #888;
    font-family: monospace;
}

.es-item-brand {
    font-size: 12px;
    color: #999;
    font-style: italic;
}

/* ── Fragment opisu ────────────────────────────────────────────────────────── */
.es-item-desc {
    font-size: 11px;
    color: #999;
    margin-top: 3px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Prawa strona (cena, badge) ──────────────────────────────────────────── */
.es-item-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    flex-shrink: 0;
}

.es-item-price {
    font-size: 15px;
    font-weight: 700;
    color: #e63946;
    white-space: nowrap;
}

/* ── Badge dostępności ───────────────────────────────────────────────────── */
.es-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    letter-spacing: .3px;
    text-transform: uppercase;
    white-space: nowrap;
}

.es-badge--stock {
    background: #d4edda;
    color: #155724;
}

.es-badge--nostock {
    background: #f0f0f0;
    color: #888;
}

/* ── Brak wyników ────────────────────────────────────────────────────────── */
.es-no-results {
    padding: 22px 16px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* ── Stopka "Pokaż wszystkie" ────────────────────────────────────────────── */
.es-footer-link {
    padding: 10px 14px;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
    text-align: right;
}

.es-footer-link a {
    font-size: 13px;
    color: #e63946;
    text-decoration: none;
    font-weight: 600;
}

.es-footer-link a:hover {
    text-decoration: underline;
}

/* ── Podświetlenie frazy ─────────────────────────────────────────────────── */
mark.es-hi {
    background: #fff0b3;
    color: inherit;
    padding: 0;
    border-radius: 2px;
}

/* ── Responsive: mobilny (bottom sheet) ─────────────────────────────────── */
@media (max-width: 600px) {
    .es-results-wrap {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 16px 16px 0 0;
        max-height: 72vh;
        box-shadow: 0 -4px 30px rgba(0, 0, 0, .15);
    }

    .es-item-title {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .es-item-right {
        flex-direction: row;
        align-items: center;
    }
}
