/**
 * Enhanced Search - Autocomplete Styles
 * Mobile-first
 */

/* ===== Stacking context overrides ===== */
#search {
    position: relative;
    z-index: 99999 !important;
}

.top-search {
    z-index: 99999 !important;
}

.header-inner {
    z-index: 99999 !important;
}

/* ===== Dropdown container ===== */
.es-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 99999;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    max-height: 420px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.es-dropdown.es-visible {
    display: block;
}

/* ===== Result item ===== */
.es-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    text-decoration: none !important;
    color: #333;
    transition: background-color 0.15s;
    cursor: pointer;
}

.es-item:hover,
.es-item.es-active {
    background-color: #f8f8f8;
    text-decoration: none !important;
}

.es-item:last-of-type {
    border-bottom: none;
}

/* ===== Thumbnail ===== */
.es-thumb {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    margin-right: 12px;
    object-fit: contain;
    border-radius: 3px;
    background: #f5f5f5;
}

/* ===== Product info ===== */
.es-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.es-category {
    display: block;
    font-size: 11px;
    color: #999;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.es-name {
    display: block;
    font-size: 13px;
    color: #333;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Price ===== */
.es-price {
    flex-shrink: 0;
    text-align: right;
    margin-left: 10px;
    white-space: nowrap;
}

.es-price-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.es-current {
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.es-original {
    font-size: 11px;
    color: #999;
    text-decoration: line-through;
}

.es-special {
    font-size: 13px;
    font-weight: 600;
    color: #e74c3c;
}

/* ===== Loading ===== */
.es-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.es-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top-color: #F8BD07;
    border-radius: 50%;
    animation: es-spin 0.6s linear infinite;
}

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

/* ===== Empty state ===== */
.es-empty {
    padding: 16px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

/* ===== See all results link ===== */
.es-see-all {
    display: block;
    padding: 10px 12px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #F8BD07 !important;
    background: #fafafa;
    border-top: 1px solid #eee;
    text-decoration: none !important;
    transition: background 0.15s;
}

.es-see-all:hover {
    background: #f0f0f0;
    text-decoration: none !important;
}

/* ===== Mobile ===== */
@media (max-width: 767px) {
    .es-dropdown {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        bottom: auto;
        max-height: 50vh;
        border-radius: 0 0 4px 4px;
        border: 1px solid #ddd;
        border-top: none;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    }

    .es-item {
        padding: 12px 16px;
    }

    .es-thumb {
        width: 45px;
        height: 45px;
    }

    .es-name {
        font-size: 14px;
        white-space: normal;
    }
}

/* ===== Desktop ===== */
@media (min-width: 768px) {
    #search input[name="search"] {
        width: 349px !important;
    }

    .es-dropdown {
        min-width: 450px;
    }
}
