/**
 * Category Navigator Widget Styles
 *
 * @package Elementor_Category_Navigator
 */

/* ── Site-specific (Aoprema "Išči po kategorijah" dropdown container) ─────
   The dropdown panel sits inside Elementor container .elementor-element-8bba76d.
   Strip its border and round the bottom corners so the dropdown reads as a card.
   If that Elementor container is ever rebuilt, the hash in the selector below
   will need updating — better long-term home: that container's Style/Advanced
   tab in Elementor. */
.elementor-element.elementor-element-8bba76d,
.elementor-element.elementor-element-8bba76d > .elementor-widget-container,
.elementor-element.elementor-element-8bba76d .elementor-widget-container {
    border: none !important;
}

.elementor-element.elementor-element-8bba76d {
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;
    overflow: hidden;
}

/* Defensive width override — when this widget lives inside an Elementor
   Menu widget submenu, the submenu's <ul.sub-menu> wrapper has a narrow
   default width that prevents the dropdown from spanning the page.
   Force any submenu/menu-item ancestor that contains our widget to be wide.
   Desktop only — on mobile the submenu uses its natural positioning, otherwise
   the translateX(-50%) shifts the dropdown off-screen and creates a gap. */
@media (min-width: 769px) {
    .elementor-nav-menu .sub-menu:has(.ecn-widget),
    ul.sub-menu:has(.ecn-widget),
    li.menu-item:has(.ecn-widget) > .sub-menu,
    li.menu-item:has(.ecn-widget) > .elementor-nav-menu--dropdown {
        width: 1200px !important;
        max-width: 95vw !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }
}

/* ── Two-column layout on desktop: tabs left, panel right ────────────── */
/* Force widget + Elementor wrapper to fill — Elementor's "Width = Full width"
   widget setting can fail to apply on flex root elements on frontend. */
.elementor-widget-category_navigator,
.elementor-widget-category_navigator > .elementor-widget-container {
    width: 100% !important;
}

.ecn-widget {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    width: 100% !important;
}

/* ── Main category tabs (vertical list on left) ──────────────────────── */
.ecn-main-tabs {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding: 0;
    border: none;
    background: #fff;
    flex: 0 0 200px;
}

.ecn-widget .ecn-main-tabs .ecn-tab {
    appearance: none;
    -webkit-appearance: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    margin: 0;
    background: #fff !important;
    border: none !important;
    border-bottom: 1px solid #eef0f3 !important;
    border-radius: 0 !important;
    cursor: pointer;
    font-weight: 500;
    font-size: 15px;
    line-height: 1.4;
    color: #2c3e50 !important;
    text-align: left;
    text-transform: none;
    text-decoration: none;
    letter-spacing: normal;
    box-shadow: none !important;
    outline: none;
    white-space: normal;
    transition: background-color 0.15s, color 0.15s;
}

.ecn-widget .ecn-main-tabs .ecn-tab:last-child {
    border-bottom: none !important;
}

.ecn-widget .ecn-main-tabs .ecn-tab::after {
    content: '\203A';
    font-size: 20px;
    line-height: 1;
    color: #242424;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.ecn-widget .ecn-main-tabs .ecn-tab:hover {
    background: #f7f9fc !important;
    color: #1a4cdb !important;
}

.ecn-widget .ecn-main-tabs .ecn-tab:hover::after {
    transform: translateX(2px);
}

.ecn-widget .ecn-main-tabs .ecn-tab.ecn-tab--active {
    background: #eef3ff !important;
    color: #1a4cdb !important;
    font-weight: 600;
}

/* ── Panels (flyout to the right of tabs on desktop) ───────────────── */
.ecn-panels {
    flex: 1;
    min-width: 0;
    padding: 16px 20px;
    border-left: 1px solid #eef0f3;
    background: #fff;
}

.ecn-panel {
    display: none;
}

.ecn-panel--active {
    display: block;
}

/* ── Column grid: explicit .ecn-column divs (rendered by PHP), each a
   vertical flex stack of brands. Each column is independent — expanding
   a brand in column 1 doesn't re-flow brands in column 2. */
.ecn-wrapper {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
}

.ecn-column {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-left: 10px;
}

.ecn-block {
    display: flex;
    flex-direction: row;
    gap: 12px;
}

/* ── Thumbnail ───────────────────────────────────── */
.ecn-thumb {
    flex-shrink: 0;
}

.ecn-thumb img {
    width: 40px;
    height: auto;
    display: block;
}

/* ── Brand title toggle ──────────────────────────── */
.ecn-widget .ecn-title-toggle {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 0 4px 0;
    font-weight: bold;
    font-size: inherit;
    font-family: inherit;
    line-height: 1.4;
    color: inherit !important;
    text-align: left;
    text-transform: none;
    text-decoration: none;
    letter-spacing: normal;
    box-shadow: none !important;
    outline: none;
    min-height: 0;
    min-width: 0;
}

.ecn-widget .ecn-title-toggle:hover {
    color: #0073aa !important;
    background: none !important;
}

.ecn-widget .ecn-title-toggle::after {
    content: '\203A';
    font-size: 20px;
    line-height: 1;
    transition: transform 0.2s;
    display: inline-block;
    color: #242424;
}

.ecn-block--expanded > .ecn-content > .ecn-title-toggle::after {
    transform: rotate(90deg);
}

/* ── Plain title (brands with no children) ───────── */
.ecn-title {
    font-weight: bold;
    margin-bottom: 4px;
}

.ecn-title a {
    color: inherit;
    text-decoration: none;
}

.ecn-title a:hover {
    color: #0073aa;
}

/* ── Collapsible children ────────────────────────── */
.ecn-children {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.ecn-block--expanded > .ecn-content > .ecn-children {
    max-height: 2000px;
}

.ecn-children a {
    text-decoration: none;
    color: #555;
    font-size: 13px;
    line-height: 1.6;
}

.ecn-children a:hover {
    color: #0073aa;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 1024px) {
    .ecn-wrapper {
        column-count: 3;
    }
}

@media (max-width: 768px) {
    /* Revert to single column on mobile — tabs above, panel below. */
    .ecn-widget {
        flex-direction: column;
    }
    .ecn-main-tabs {
        flex: none;
    }
    .ecn-panels {
        padding: 0;
        border-left: none;
        background: transparent;
    }

    /* Two columns, centered, no thumbnails. Flatten the explicit .ecn-column
       divs via display:contents so CSS multi-column can lay out the brands. */
    .ecn-wrapper {
        display: block;
        column-count: 2 !important;
        column-gap: 20px;
        padding: 10px 16px;
    }
    .ecn-column {
        display: contents;
    }
    .ecn-block {
        break-inside: avoid;
        margin-bottom: 8px;
    }

    /* Stack tabs vertically on mobile — preserve pre-2.2.1 mobile look. */
    .ecn-main-tabs {
        flex-direction: column;
        gap: 0;
        border-bottom: none;
        margin-bottom: 0;
        background: transparent;
        border-radius: 0;
        box-shadow: none;
        overflow: visible;
    }

    /* Mobile keeps the original chevron-less rows. */
    .ecn-widget .ecn-main-tabs .ecn-tab::after {
        display: none;
    }

    .ecn-widget .ecn-main-tabs .ecn-tab {
        font-size: 16px;
        padding: 12px 16px;
        border-radius: 0 !important;
        border: none !important;
        border-bottom: 1px solid #eee !important;
        background: #fff !important;
        text-align: left;
        width: 100%;
        white-space: normal;
    }

    .ecn-widget .ecn-main-tabs .ecn-tab:first-child {
        border-radius: 4px 4px 0 0 !important;
    }

    .ecn-widget .ecn-main-tabs .ecn-tab:last-child {
        border-radius: 0 0 4px 4px !important;
        border-bottom: none !important;
    }

    .ecn-widget .ecn-main-tabs .ecn-tab.ecn-tab--active {
        background: #f5f5f5 !important;
        color: #0073aa !important;
        font-weight: 700;
        position: static;
        padding-bottom: 12px;
    }

    /* Panel sits right below tabs. */
    .ecn-panels {
        margin-top: 0;
    }

    .ecn-panel--active {
        border-top: 1px solid #eee;
        padding-top: 10px;
    }

    /* Hide thumbnails on mobile — text only. */
    .ecn-thumb {
        display: none;
    }

    /* Compact brand list. */
    .ecn-block {
        margin-bottom: 8px;
        gap: 0;
    }

    .ecn-widget .ecn-title-toggle {
        font-size: 15px;
        padding: 4px 0 !important;
    }

    .ecn-title {
        font-size: 15px;
    }

    .ecn-children a {
        font-size: 14px;
        padding: 3px 0 3px 12px;
    }
}
