/* ==========================================================================
   COFIS CZ Elastic Search — Autocomplete Popup
   Namespace: .czel-*
   CSS custom properties (--czel-*) jsou generovány inline <style> z PHP modulu.
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. Base / Reset
   -------------------------------------------------------------------------- */

.czel-popup *,
.czel-popup *::before,
.czel-popup *::after {
    box-sizing: border-box;
}

.czel-popup {
    font-family: var(--czel-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}


/* --------------------------------------------------------------------------
   2. Overlay (zatmavení stránky za popupem)
   -------------------------------------------------------------------------- */

.czel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 9998;
    opacity: 0;
    transition: opacity 250ms ease;
    pointer-events: none;
}

.czel-overlay--visible {
    opacity: 1;
    pointer-events: auto;
}


/* --------------------------------------------------------------------------
   3. Popup kontejner
   -------------------------------------------------------------------------- */

.czel-popup {
    position: absolute;
    background: var(--czel-bg, #fff);
    border-radius: var(--czel-radius, 16px);
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.05),
        0 20px 50px -8px rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(0, 0, 0, 0.06);
    max-width: var(--czel-popup-width, 940px);
    width: 100%;
    z-index: 9999;
    overflow: hidden;
}

.czel-popup--entering {
    animation: czelSlideIn 250ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.czel-popup--leaving {
    animation: czelSlideOut 150ms ease-in forwards;
}


/* --------------------------------------------------------------------------
   3. Sloupcový layout
   -------------------------------------------------------------------------- */

.czel-popup__columns {
    display: flex;
    min-height: 300px;
}

.czel-popup__col {
    padding: 20px;
}

.czel-popup__col--categories {
    width: 180px;
    flex-shrink: 0;
    border-right: 1px solid var(--czel-border, #f0f0f0);
    background: var(--czel-bg-subtle, #fafbfc);
}

.czel-popup__col--top {
    width: 220px;
    flex-shrink: 0;
    border-right: 1px solid var(--czel-border, #f0f0f0);
}

.czel-popup__col--products {
    flex: 1;
    min-width: 0;
}


/* --------------------------------------------------------------------------
   4. Hlavičky sekcí
   -------------------------------------------------------------------------- */

.czel-popup__section-title {
    text-transform: uppercase;
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    color: var(--czel-text-muted, #9ca3af);
    font-weight: 700;
    margin: 0 0 12px 0;
}


/* --------------------------------------------------------------------------
   5. Zvýraznění hledané fráze
   -------------------------------------------------------------------------- */

.czel-highlight {
    background: rgba(1, 140, 149, 0.12);
    color: var(--czel-primary, #018c95);
    border-radius: 2px;
    padding: 0 1px;
    font-style: normal;
}


/* --------------------------------------------------------------------------
   6. Návrhy vyhledávacích frází (suggestions)
   -------------------------------------------------------------------------- */

.czel-popup__suggestions,
.czel-popup__recent-searches,
.czel-popup__popular-queries {
    padding: 14px 20px 10px;
    border-bottom: 1px solid var(--czel-border, #f0f0f0);
}

.czel-popup__suggestions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.czel-popup__suggestion {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    background: var(--czel-bg-subtle, #f5f5f7);
    color: var(--czel-text, #1f2937);
    font-size: 0.78rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.czel-popup__suggestion:hover {
    background: var(--czel-primary-light, rgba(1, 140, 149, 0.1));
    color: var(--czel-primary, #018c95);
}

.czel-popup__suggestion svg {
    width: 13px;
    height: 13px;
    color: var(--czel-text-muted, #9ca3af);
    flex-shrink: 0;
}

.czel-popup__suggestion:hover svg {
    color: var(--czel-primary, #018c95);
}

/* Specifické styly pro recent searches */
.czel-popup__recent-searches .czel-popup__section-title {
    margin-bottom: 8px;
}

.czel-popup__recent-searches .czel-popup__suggestion svg {
    color: var(--czel-text-muted, #9ca3af);
}


/* --------------------------------------------------------------------------
   7. Kategorie
   -------------------------------------------------------------------------- */

.czel-popup__categories {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.czel-popup__category {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 10px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--czel-text, #1f2937);
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.czel-popup__category:hover {
    background: #fff;
    color: var(--czel-primary, #018c95);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.czel-popup__category svg {
    width: 14px;
    height: 14px;
    color: var(--czel-text-muted, #9ca3af);
    flex-shrink: 0;
    opacity: 0;
    transform: translateX(-3px);
    transition: all 0.15s ease;
}

.czel-popup__category:hover svg {
    opacity: 1;
    transform: translateX(0);
    color: var(--czel-primary, #018c95);
}


/* --------------------------------------------------------------------------
   7b. Značky / Výrobci
   -------------------------------------------------------------------------- */

.czel-popup__brands {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--czel-border, #f0f0f0);
}

.czel-popup__brands .czel-popup__section-title {
    margin-bottom: 8px;
}

.czel-popup__brands-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.czel-popup__brand {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 10px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--czel-text, #1f2937);
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.czel-popup__brand:hover {
    background: #fff;
    color: var(--czel-primary, #018c95);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.czel-popup__brand svg {
    width: 14px;
    height: 14px;
    color: var(--czel-text-muted, #9ca3af);
    flex-shrink: 0;
    opacity: 0;
    transform: translateX(-3px);
    transition: all 0.15s ease;
}

.czel-popup__brand:hover svg {
    opacity: 1;
    transform: translateX(0);
    color: var(--czel-primary, #018c95);
}


/* --------------------------------------------------------------------------
   8. Top produkt
   -------------------------------------------------------------------------- */

.czel-popup__top-product {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--czel-text, #1f2937);
    border-radius: 12px;
    padding: 10px;
    transition: all 0.2s ease;
    position: relative;
}

.czel-popup__top-product:hover {
    background: var(--czel-hover-bg, #f9fafb);
}

.czel-popup__top-product-image-wrap {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 10px;
    background: #f5f5f7;
    margin-bottom: 12px;
}

.czel-popup__top-product-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.czel-popup__top-product:hover .czel-popup__top-product-image {
    transform: scale(1.04);
}

.czel-popup__top-product-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}

.czel-popup__top-product-name {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--czel-text, #1f2937);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.czel-popup__top-product-price {
    font-size: 1rem;
    font-weight: 800;
    color: var(--czel-primary, #018c95);
}

/* V default popupu: prostřední sloupec = šířka 1 produktového sloupce */
.czel-popup--default .czel-popup__col--top {
    width: auto;
    flex: 1;
}

.czel-popup--default .czel-popup__col--products {
    flex: 2;
}


/* --------------------------------------------------------------------------
   9. Seznam produktů — 2-sloupcový grid
   -------------------------------------------------------------------------- */

.czel-popup__products {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.czel-popup__products--single-col {
    grid-template-columns: 1fr;
}

.czel-popup__product {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--czel-text, #1f2937);
    transition: all 0.15s ease;
}

.czel-popup__product:hover,
.czel-popup__product--active {
    background: var(--czel-hover-bg, #f5f5f7);
}

.czel-popup__product-image {
    width: 72px;
    height: 72px;
    object-fit: contain;
    border-radius: 8px;
    flex-shrink: 0;
    background: #f5f5f7;
    padding: 3px;
}

.czel-popup__product-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.czel-popup__product-name {
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.3;
    color: var(--czel-text, #1f2937);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.czel-popup__product-price {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--czel-primary, #018c95);
}

.czel-popup__price-old {
    text-decoration: line-through;
    color: var(--czel-text-muted, #9ca3af);
    font-weight: 500;
    font-size: 0.75rem;
    margin-right: 4px;
}


/* --------------------------------------------------------------------------
   10. Tlačítko košíku
   -------------------------------------------------------------------------- */

.czel-popup__product-cart {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: none;
    background: var(--czel-primary-light, rgba(1, 140, 149, 0.08));
    cursor: pointer;
    color: var(--czel-primary, #018c95);
    transition: all 0.15s ease;
}

.czel-popup__product-cart:hover {
    background: var(--czel-primary, #018c95);
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(1, 140, 149, 0.35);
}

.czel-popup__product-cart--added {
    background: #059669;
    color: #fff;
}

.czel-popup__product-cart--variant {
    background: var(--czel-bg-subtle, rgba(107, 114, 128, 0.08));
    color: var(--czel-text-muted, #6b7280);
}

.czel-popup__product-cart--variant:hover {
    background: var(--czel-text-muted, #6b7280);
    color: #fff;
    box-shadow: 0 3px 10px rgba(107, 114, 128, 0.3);
}

.czel-popup__product-cart--variant.czel-popup__product-cart--inline {
    background: var(--czel-text-muted, #6b7280);
    color: #fff;
}

.czel-popup__product-cart--variant.czel-popup__product-cart--inline:hover {
    background: var(--czel-text, #4b5563);
    box-shadow: 0 4px 14px rgba(107, 114, 128, 0.3);
}

.czel-popup__product-cart--small {
    width: 30px;
    height: 30px;
    border-radius: 8px;
}

.czel-popup__product-cart--small svg {
    width: 14px;
    height: 14px;
}

.czel-popup__product-cart svg {
    width: 17px;
    height: 17px;
}

/* Inline cart button pod cenou (top produkt) — styl jako "Show all results" */
.czel-popup__product-cart--inline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: auto;
    height: auto;
    padding: 9px 20px;
    margin-top: 10px;
    border-radius: 10px;
    background: var(--czel-primary, #018c95);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    align-self: center;
}

.czel-popup__product-cart--inline:hover {
    background: var(--czel-primary-hover, #017580);
    box-shadow: 0 4px 14px rgba(1, 140, 149, 0.3);
    color: #fff;
    transform: translateY(-1px) scale(1);
}

.czel-popup__product-cart--inline span {
    white-space: nowrap;
}

.czel-popup__product-cart--inline svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Detail icon — neobjednatelné produkty (available_for_order = 0) */
.czel-popup__product-detail {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f1f5f9;
    color: #64748b;
    transition: background 0.15s, color 0.15s;
}
.czel-popup__product:hover .czel-popup__product-detail {
    background: #e2e8f0;
    color: #475569;
}
.czel-popup__product-detail--inline {
    width: auto;
    height: auto;
    border-radius: 6px;
    padding: 6px 12px;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
}


/* --------------------------------------------------------------------------
   11. Footer
   -------------------------------------------------------------------------- */

.czel-popup__footer {
    border-top: 1px solid var(--czel-border, #f0f0f0);
    padding: 14px 20px;
}

.czel-popup__show-all-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px 24px;
    border-radius: 10px;
    background: var(--czel-primary, #018c95);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.czel-popup__show-all-btn:hover {
    background: var(--czel-primary-hover, #017580);
    box-shadow: 0 4px 14px rgba(1, 140, 149, 0.3);
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
}

.czel-popup__show-all-btn:active {
    transform: translateY(0);
}

.czel-popup__show-all-btn svg {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.czel-popup__show-all-btn:hover svg {
    transform: translateX(3px);
}


/* --------------------------------------------------------------------------
   12. Prázdný stav
   -------------------------------------------------------------------------- */

.czel-popup__empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--czel-text-muted, #9ca3af);
    font-size: 0.85rem;
    grid-column: 1 / -1;
}


/* --------------------------------------------------------------------------
   13. Zavírací tlačítko
   -------------------------------------------------------------------------- */

.czel-popup__close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--czel-text-muted, #9ca3af);
    cursor: pointer;
    transition: all 0.15s ease;
    z-index: 1;
}

.czel-popup__close:hover {
    background: var(--czel-hover-bg, #f3f4f6);
    color: var(--czel-text, #1f2937);
}


/* --------------------------------------------------------------------------
   14. Animace
   -------------------------------------------------------------------------- */

@keyframes czelSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes czelSlideOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-6px) scale(0.98);
    }
}


/* --------------------------------------------------------------------------
   15. Responzivní — mobil
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
    .czel-popup {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        max-width: none;
        border-radius: 0;
        overflow-y: auto;
        z-index: 10000;
    }

    .czel-popup--entering {
        animation: czelMobileSlideIn 250ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }

    .czel-popup__suggestions,
    .czel-popup__recent-searches,
    .czel-popup__popular-queries {
        padding: 10px 14px 8px;
    }

    .czel-popup__columns {
        flex-direction: column;
        min-height: auto;
    }

    .czel-popup__col {
        border-right: none;
        width: 100%;
        padding: 12px 14px;
    }

    .czel-popup__col--categories {
        border-bottom: 1px solid var(--czel-border, #f0f0f0);
        padding: 10px 14px;
    }

    .czel-popup__col--top {
        order: -1;
        border-bottom: 1px solid var(--czel-border, #f0f0f0);
        border-right: none;
        width: 100%;
        padding: 10px 14px;
    }

    .czel-popup__products--single-col {
        grid-template-columns: 1fr;
    }

    /* Značky na mobilu — horizontální chipy */
    .czel-popup__brands-list {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }

    .czel-popup__brand {
        padding: 5px 12px;
        background: #fff;
        border-radius: 20px;
        border: 1px solid var(--czel-border, #e5e7eb);
        font-size: 0.75rem;
        white-space: nowrap;
    }

    .czel-popup__brand:hover {
        border-color: var(--czel-primary, #018c95);
        box-shadow: none;
    }

    .czel-popup__brand svg {
        display: none;
    }

    .czel-popup__brands {
        margin-top: 10px;
        padding-top: 10px;
    }

    .czel-popup__col--products {
        padding-bottom: 8px;
    }

    /* Kategorie na mobilu — horizontální chipy */
    .czel-popup__categories {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }

    .czel-popup__category {
        padding: 5px 12px;
        background: #fff;
        border-radius: 20px;
        border: 1px solid var(--czel-border, #e5e7eb);
        font-size: 0.75rem;
        white-space: nowrap;
    }

    .czel-popup__category:hover {
        border-color: var(--czel-primary, #018c95);
    }

    .czel-popup__category svg {
        display: none;
    }

    /* Top produkt na mobilu — stejný jako běžný produkt */
    .czel-popup__top-product {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        padding: 6px;
        border-radius: 10px;
    }

    .czel-popup__top-product-image-wrap {
        width: 60px;
        height: 60px;
        aspect-ratio: auto;
        flex-shrink: 0;
        margin-bottom: 0;
        border-radius: 8px;
    }

    .czel-popup__top-product-name {
        font-size: 0.8rem;
        margin-bottom: 0;
    }

    .czel-popup__top-product-price {
        font-size: 0.8rem;
    }

    /* Produkty na mobilu — 1 sloupec */
    .czel-popup__products {
        grid-template-columns: 1fr;
    }

    .czel-popup__section-title {
        margin-bottom: 8px;
    }

    .czel-popup__footer {
        position: sticky;
        bottom: 0;
        background: var(--czel-bg, #fff);
        padding: 10px 14px;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
    }

    .czel-popup__close {
        top: 8px;
        right: 8px;
        width: 32px;
        height: 32px;
        background: var(--czel-hover-bg, #f3f4f6);
    }

    /* Default popup na mobilu: jen oblíbená hledání + oblíbené produkty */
    .czel-popup--default .czel-popup__recent-searches,
    .czel-popup--default .czel-popup__col--categories {
        display: none;
    }

    /* Oba režimy: skrýt prostřední sloupec (novinky / top produkt) */
    .czel-popup__col--top {
        display: none;
    }

    /* Search režim: skrýt značky */
    .czel-popup__brands {
        display: none;
    }
}

@keyframes czelMobileSlideIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* --------------------------------------------------------------------------
   16. Přístupnost
   -------------------------------------------------------------------------- */

.czel-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}


/* --------------------------------------------------------------------------
   17. Error popup (ES nedostupny)
   -------------------------------------------------------------------------- */

.czel-popup__error {
    text-align: center;
    padding: 48px 24px 32px;
    color: #6b7280;
}

.czel-popup__error-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: #f3f4f6;
    color: #9ca3af;
}

.czel-popup__error-icon svg {
    width: 22px;
    height: 22px;
}

.czel-popup__error-message {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 6px;
}

.czel-popup__error-hint {
    font-size: 0.8rem;
    color: #9ca3af;
}

.czel-popup__error-link {
    color: #018c95;
    text-decoration: underline;
    transition: color 0.15s;
}

.czel-popup__error-link:hover {
    color: #016b72;
}
