/**
 * Shop layout — header, navigacija, footer, mobilni meni
 * Učitava se posle style.css, header.css i footer.css
 */

/* ----- Footer: čitljivost (naslovi na beloj pozadini) ----- */
.footer-col h4 {
    color: var(--gray-900);
}

.footer-social a {
    color: var(--gray-600);
    background: var(--gray-100);
}

.footer-social a:hover {
    color: var(--white);
}

/* ----- Flash poruke (tablet/mobilni) ----- */
@media (max-width: 768px) {
    .container > .flash-message {
        font-size: 0.95rem;
        line-height: 1.45;
        padding: 14px 16px;
        margin-top: 12px;
        margin-bottom: 8px;
    }
}

/* ----- Fiksni shop header (svi ekrani): pretraga se sakriva pri skrolu nadole ----- */
body {
    padding-top: var(--shop-header-offset, 0px);
    transition: padding-top 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.shop-fixed-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    will-change: transform;
    transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.shop-fixed-header .header-main {
    background: var(--white);
}

.shop-fixed-header .header-nav {
    position: relative;
    top: auto;
    z-index: auto;
}

/* ----- Desktop (>1024px): beli deo klizi nagore iza plavog nav-a ----- */
@media (min-width: 1025px) {
    .shop-fixed-header--compact {
        transform: translateY(calc(-1 * var(--shop-header-main-h, 0px)));
    }
}

/* ----- Tablet/mobilni (do ~1024px): sakrij samo search, ne ceo header ----- */
@media (max-width: 1024px) {
    .shop-fixed-header .header-main {
        transition: padding 0.28s ease, box-shadow 0.28s ease;
    }

    .shop-fixed-header--compact .header-main {
        padding-top: 8px;
        padding-bottom: 8px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    }

    .header-main .header-search {
        max-height: 220px;
        opacity: 1;
        overflow: hidden;
        transition:
            max-height 0.38s cubic-bezier(0.4, 0, 0.2, 1),
            opacity 0.28s ease,
            margin 0.28s ease;
    }

    .shop-fixed-header--compact .header-main .header-search {
        max-height: 0;
        opacity: 0;
        margin-top: 0;
        margin-bottom: 0;
        pointer-events: none;
    }

    .header-main {
        padding: 12px 0;
    }

    .header-main .container {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        gap: 12px 16px;
        align-items: center;
    }

    .header-logo {
        grid-column: 1;
        grid-row: 1;
    }

    .header-icons {
        grid-column: 2;
        grid-row: 1;
        justify-self: end;
    }

    .header-search {
        grid-column: 1 / -1;
        grid-row: 2;
        max-width: none;
        width: 100%;
    }

    .header-search input {
        width: 100%;
        max-width: none;
        font-size: 1rem;
        min-height: 44px;
        padding: 10px 48px 10px 16px;
    }

    .header-search button {
        width: 38px;
        height: 38px;
    }

    .header-logo img {
        height: 42px;
    }

    .header-icon-btn {
        width: 44px;
        height: 44px;
        font-size: 1.05rem;
    }

    /* Nav: horizontalni skrol umesto prelamanja */
    .header-nav {
        padding: 8px 0;
    }

    .header-nav-inner {
        grid-template-columns: auto 1fr;
        min-height: 44px;
    }

    .nav-links {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        gap: 2px;
        mask-image: linear-gradient(to right, #000 92%, transparent 100%);
    }

    .nav-links a {
        padding: 10px 12px;
        font-size: 0.82rem;
    }

    .all-categories-btn a {
        min-height: 44px;
        padding: 0 14px;
    }

    .categories-mega {
        max-height: min(70vh, 480px);
    }

    .mega-layout {
        min-height: 320px;
    }

    .mega-sidebar {
        width: 200px;
    }

    .mega-content {
        padding: 18px 20px;
    }

    .footer {
        padding-top: 36px;
    }

    .footer-main {
        gap: 28px 24px;
    }
}

/* ----- Mobilni drawer (vidljiv samo na malim ekranima) ----- */
.mobile-menu-backdrop,
.mobile-menu-drawer {
    display: none;
}

@media (max-width: 768px) {
    .mobile-menu-backdrop {
        display: block;
    }

    .mobile-menu-drawer {
        display: flex;
    }

    .mobile-menu-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1001;
        background: rgba(26, 26, 46, 0.45);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.25s ease, visibility 0.25s ease;
    }

    .mobile-menu-backdrop.open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .mobile-menu-drawer {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1002;
        width: min(100vw - 48px, 360px);
        max-width: 100%;
        background: var(--white);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
        transform: translateX(-105%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        flex-direction: column;
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .mobile-menu-drawer.open {
        transform: translateX(0);
    }

    .mobile-menu-header {
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 18px;
        border-bottom: 1px solid var(--gray-200);
        background: var(--gray-100);
    }

    .mobile-menu-title {
        font-size: 1.05rem;
        font-weight: 700;
        color: var(--gray-900);
    }

    .mobile-menu-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        margin: -8px -8px -8px 0;
        border: none;
        border-radius: 50%;
        background: transparent;
        color: var(--gray-700);
        font-size: 1.25rem;
        cursor: pointer;
        transition: var(--transition);
    }

    .mobile-menu-close:hover {
        background: var(--gray-200);
        color: var(--dark);
    }

    .mobile-menu-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 8px 0 24px;
    }

    .mobile-menu-section {
        padding: 12px 18px 8px;
    }

    .mobile-menu-heading {
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--gray-600);
        margin-bottom: 10px;
    }

    .mobile-menu-links {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .mobile-menu-links li {
        border-bottom: 1px solid var(--gray-100);
    }

    .mobile-menu-links li:last-child {
        border-bottom: none;
    }

    .mobile-menu-links a {
        display: flex;
        align-items: center;
        gap: 8px;
        min-height: 48px;
        padding: 10px 4px;
        font-size: 0.95rem;
        line-height: 1.35;
        font-weight: 500;
        color: var(--gray-800);
        text-decoration: none;
    }

    .mobile-menu-links a:hover,
    .mobile-menu-links a:focus-visible {
        color: var(--primary);
        outline: none;
    }

    .mobile-menu-links--compact a {
        font-size: 0.9rem;
        min-height: 44px;
    }

    .mobile-menu-account {
        padding-top: 20px;
        margin-top: 8px;
        border-top: 1px solid var(--gray-200);
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .mobile-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        min-height: 48px;
        padding: 12px 18px;
        border-radius: var(--border-radius);
        font-size: 0.95rem;
        font-weight: 600;
        text-align: center;
        text-decoration: none;
        transition: var(--transition);
    }

    .mobile-menu-btn.primary {
        background: var(--primary);
        color: var(--white);
    }

    .mobile-menu-btn.primary:hover {
        background: var(--primary-dark);
        color: var(--white);
    }

    .mobile-menu-btn.secondary {
        background: var(--gray-100);
        color: var(--gray-800);
        border: 1px solid var(--gray-200);
    }

    .mobile-menu-btn.secondary:hover {
        border-color: var(--primary);
        color: var(--primary);
    }

    .mobile-menu-btn.ghost {
        background: transparent;
        color: var(--gray-600);
        border: 1px dashed var(--gray-300);
    }

    .mobile-menu-btn.ghost:hover {
        color: var(--primary);
        border-color: var(--primary);
    }

    /* Kategorije — akordeon */
    .mobile-menu-section--categories {
        padding-bottom: 4px;
    }

    .mobile-cat-accordion {
        
        border-radius: var(--border-radius);
        overflow: hidden;
        background: var(--white);
    }

    .mobile-cat-group {
        border-bottom: 1px solid var(--gray-100);
    }

    .mobile-cat-group:last-child {
        border-bottom: none;
    }

    .mobile-cat-toggle {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        min-height: 48px;
        /* padding: 12px 14px; */
        border: none;
        background: var(--white);
        font-family: inherit;
        font-size: 0.95rem;
        font-weight: 600;
        color: var(--gray-900);
        text-align: left;
        cursor: pointer;
        transition: background 0.15s ease;
    }

    .mobile-cat-toggle:hover {
        background: var(--gray-100);
    }

    .mobile-cat-toggle--nested {
        font-weight: 500;
        font-size: 0.9rem;
        background: var(--gray-100);
        padding-left: 18px;
    }

    .mobile-cat-chevron {
        flex-shrink: 0;
        font-size: 0.72rem;
        color: var(--gray-500);
        transition: transform 0.28s ease;
    }

    .mobile-cat-group.open > .mobile-cat-toggle .mobile-cat-chevron {
        transform: rotate(180deg);
        color: var(--primary);
    }

    .mobile-cat-children {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.42s cubic-bezier(0.4, 0, 0.2, 1);
        background: var(--gray-100);
    }

    .mobile-cat-group.open > .mobile-cat-children {
        max-height: 2800px;
    }

    .mobile-cat-view-all {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 12px 14px;
        font-size: 0.82rem;
        font-weight: 600;
        color: var(--primary);
        text-decoration: none;
        border-bottom: 1px solid var(--gray-200);
        background: var(--white);
    }

    .mobile-cat-view-all--small {
        font-size: 0.78rem;
        padding: 10px 14px 10px 22px;
    }

    .mobile-cat-link {
        display: block;
        padding: 11px 14px 11px 22px;
        font-size: 0.88rem;
        color: var(--gray-700);
        text-decoration: none;
        border-top: 1px solid var(--gray-200);
        background: var(--white);
    }

    .mobile-cat-link:hover {
        color: var(--primary);
        background: rgba(var(--primary-rgb), 0.08);
    }

    .mobile-cat-group--nested {
        border-top: 1px solid var(--gray-200);
        margin-top: 0;
    }

    .mobile-cat-children--nested {
        background: var(--white);
        padding-bottom: 6px;
    }

    .mobile-cat-children--nested .mobile-cat-link {
        padding-left: 28px;
    }

    .mobile-cat-row.mobile-cat-direct {
        display: flex;
        align-items: center;
        min-height: 48px;
        /* padding: 12px 14px; */
        font-size: 0.95rem;
        font-weight: 600;
        color: var(--gray-900);
        text-decoration: none;
        border-bottom: 1px solid var(--gray-100);
    }

    .mobile-cat-row.mobile-cat-direct:hover {
        color: var(--primary);
        background: var(--gray-100);
    }

    /* Sakrij glavnu plavu navigacionu traku — sve je u drawer-u */
    .header-nav {
        display: none;
    }

    /* Mega ostaje u DOM-u ali nije vidljiv */
    .categories-mega {
        display: none !important;
    }
}

/* ----- Mobilni header sitnije podešavanje ----- */
@media (max-width: 768px) {
    .header-main .container {
        grid-template-columns: 1fr auto;
        gap: 10px 12px;
    }

    .header-logo img {
        height: 38px;
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
    }
}

@media (max-width: 380px) {
    .header-logo img {
        height: 34px;
    }

    .mobile-menu-drawer {
        width: min(100vw - 32px, 100%);
    }
}
