/* DBT WEB SHOP — Catalog stranice */

.catalog { padding: 24px 16px; }
.catalog__header { margin-bottom: 24px; }
.catalog__header h1 { font-size: 1.75rem; margin-bottom: 4px; }
.catalog__count { color: var(--gray-500); font-size: 0.9rem; }

.catalog__layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 24px;
}

/* MOBILE FILTER TOGGLE */
.catalog__filter-toggle {
    display: none;
    width: 100%;
    padding: 12px 16px;
    background: var(--white);
    border: 2px solid var(--gray-200);
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 16px;
    font-size: 1rem;
    text-align: left;
    position: relative;
}
.catalog__filter-toggle:hover { border-color: var(--primary); color: var(--primary); }
.catalog__filter-count {
    background: var(--primary);
    color: var(--white);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-left: 8px;
}
.catalog__close-mobile {
    display: none;
    width: 100%;
    padding: 12px;
    background: var(--gray-100);
    border: none;
    border-radius: 4px;
    margin-top: 12px;
    cursor: pointer;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .catalog__layout { grid-template-columns: 1fr; }
    .catalog__filter-toggle { display: flex; align-items: center; gap: 8px; }
    .catalog__close-mobile { display: block; }

    .catalog__sidebar {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100vw;
        z-index: 99;
        border-radius: 0;
        overflow-y: auto;
        box-shadow: 0 4px 16px rgba(0,0,0,0.15);
        padding-top: 60px;
    }
    .catalog__sidebar.is-open { display: block; }

    /* Catalog mobile polish */
    .catalog { padding: 16px 12px; }
    .catalog__header h1 { font-size: 1.4rem; }
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .product-card__body { padding: 10px; }
    .product-card__brand { font-size: 0.7rem; }
    .product-card__title { font-size: 0.9rem; }
    .product-card__sub { font-size: 0.75rem; }
    .product-card__price strong { font-size: 0.95rem; }
    .price-note { font-size: 0.65rem; }
    .price-login, .price-na { font-size: 0.8rem; }
    .stock { font-size: 0.7rem; }

    /* Sort toolbar */
    .catalog__toolbar { justify-content: flex-start; }
    .sort-form { width: 100%; flex-wrap: wrap; }
    .sort-form select { flex: 1; min-width: 0; }

    /* Product detail */
    .product-detail { padding: 16px 12px; }
    .product-detail__layout { gap: 16px; }
    .product-detail__info h1 { font-size: 1.2rem; line-height: 1.3; }
    .price-amount { font-size: 1.5rem; }
    .product-gallery__main { padding: 16px; }
    .product-gallery__thumbs { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); }
    .specs-table td { padding: 8px 6px; font-size: 0.85rem; }
    .specs-table td:first-child { width: 130px; }
    .stock-table td { font-size: 0.85rem; padding: 6px; }
    .breadcrumbs { font-size: 0.8rem; }

    /* Add to cart forma */
    .add-to-cart { gap: 14px; }
    .qty-input { justify-content: space-between; }
    .qty-input input { width: 70px; }
}

/* Vrlo mali (≤480px) — 1 kolona kataloga */
@media (max-width: 480px) {
    .product-grid { grid-template-columns: 1fr; }
    .product-card__image { aspect-ratio: 16/10; }
}

/* FILTERI — desktop sticky sidebar */
.catalog__sidebar {
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 16px;
    align-self: start;
}
/* Akcije (Primeni + Reset) sticky na vrhu sidebar-a — UVIJEK vidljivo */
.filter-actions--top {
    position: sticky;
    top: -16px; /* kompenzuje padding-top sidebar-a (16px) */
    z-index: 5;
    background: var(--white);
    padding: 12px 0 14px;
    margin: -16px -16px 8px; /* širi se preko padding-a sidebar-a */
    padding-left: 16px;
    padding-right: 16px;
    border-bottom: 2px solid var(--gray-200);
}
.filter-actions--top .btn--primary {
    display: block;
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    min-height: 48px;
    margin: 0;
}
.filter-actions--top .catalog__reset {
    display: block;
    text-align: center;
    margin-top: 8px;
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.85rem;
}
.filter-actions--top .catalog__reset:hover { color: var(--primary); }
.filter-actions--bottom {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 2px solid var(--gray-200);
}
.filter-actions--bottom .btn--primary {
    display: block;
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    min-height: 48px;
}
.filter-group { margin-bottom: 16px; }
.filter-group label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 6px; }
.filter-group select,
.filter-group input[type="search"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    font-size: 0.9rem;
}
.filter-group label.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.filter-group label.checkbox input { width: auto; }
.catalog__reset {
    display: block;
    text-align: center;
    margin-top: 8px;
    color: var(--gray-500);
    font-size: 0.85rem;
    text-decoration: none;
}
.catalog__reset:hover { color: var(--primary); text-decoration: underline; }

/* TOOLBAR */
.catalog__toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}
.sort-form { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.sort-form select { padding: 6px 10px; border: 1px solid var(--gray-200); border-radius: 4px; }

/* PRODUCT GRID */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.product-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    color: var(--dark);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
}
.product-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.product-card__image {
    position: relative;
    background: var(--white);
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 16px;
}
.product-card__image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}
.product-card:hover .product-card__image img {
    transform: scale(1.05);
}
.product-card__no-image {
    color: var(--gray-500);
    font-size: 0.85rem;
}
.product-card__body { padding: 12px; flex: 1; display: flex; flex-direction: column; }
.product-card__brand { font-size: 0.75rem; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px; }
.product-card__title {
    font-size: 1rem;
    margin: 4px 0;
    font-weight: 600;
}
.product-card__pr {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: normal;
}
.product-card__sub { color: var(--gray-500); font-size: 0.85rem; margin-bottom: 8px; }
.product-card__meta { margin-top: auto; margin-bottom: 8px; }
.product-card__price { padding-top: 8px; border-top: 1px solid var(--gray-200); }
.product-card__price strong { font-size: 1.1rem; color: var(--primary); display: block; }
.price-note { font-size: 0.7rem; color: var(--gray-500); }
.price-na, .price-login { font-size: 0.875rem; color: var(--gray-500); }

/* BADGES */
.badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--white);
}
.badge--winter { background: #1976d2; }
.badge--promo  { background: var(--primary); }
.badge--new    { background: #2e7d32; }

/* STOCK */
.stock {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
}
.stock--ok { background: #e8f5e9; color: #2e7d32; }
.stock--out { background: #ffebee; color: #c62828; }

/* STOCK TIER (10+ / 4+ / 4- za B2B B2C skrivene kolicine) */
.stock-tier {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.stock-tier--high { background: #c8e6c9; color: #1b5e20; }  /* zeleno: 10+ */
.stock-tier--mid  { background: #fff3e0; color: #e65100; }  /* narandzasto: 4+ */
.stock-tier--low  { background: #ffe0b2; color: #bf360c; }  /* tamno narandzasto: 4- */
.stock-tier--out  { background: #ffebee; color: #c62828; }  /* crveno: nema */
.stock-tier--lg   { padding: 5px 14px; font-size: 0.875rem; }

/* PAGINATION */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 32px;
}
.pagination__btn {
    padding: 8px 16px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 4px;
    text-decoration: none;
    color: var(--dark);
}
.pagination__btn:hover { background: var(--primary); color: var(--white); border-color: var(--primary); }
.pagination__info { color: var(--gray-500); }

/* EMPTY STATE */
.empty-state {
    text-align: center;
    padding: 64px 16px;
    color: var(--gray-500);
}

/* PRODUCT DETAIL */
.product-detail { padding: 24px 16px; }
.breadcrumbs {
    margin-bottom: 16px;
    color: var(--gray-500);
    font-size: 0.875rem;
}
.breadcrumbs a { color: var(--gray-500); text-decoration: none; }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs span { margin: 0 8px; }

.product-detail__layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-bottom: 32px;
}
@media (max-width: 768px) {
    .product-detail__layout { grid-template-columns: 1fr; }
}

.product-detail__media {
    background: var(--white);
}

.product-gallery {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.product-gallery__main {
    background: var(--gray-100);
    border-radius: 8px;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
}
.product-gallery__main img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: opacity 0.2s ease;
}
.product-gallery__thumbs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
}
.product-gallery__thumb {
    background: var(--gray-100);
    border: 2px solid transparent;
    border-radius: 6px;
    padding: 4px;
    cursor: pointer;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease;
}
.product-gallery__thumb:hover { border-color: var(--gray-200); }
.product-gallery__thumb.is-active { border-color: var(--primary); }
.product-gallery__thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.product-detail__info h1 { font-size: 1.5rem; margin: 8px 0; }
.product-detail__brand { color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px; font-size: 0.85rem; }
.product-detail__sku { color: var(--gray-500); margin-bottom: 16px; }

.product-detail__price-box {
    background: var(--gray-100);
    border-left: 4px solid var(--primary);
    padding: 16px;
    border-radius: 4px;
    margin: 16px 0;
}
.price-main { display: flex; flex-direction: column; gap: 4px; }
.price-amount { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.price-vat { margin-top: 8px; color: var(--gray-500); font-size: 0.9rem; }

.product-detail__stock { margin-top: 24px; }
.product-detail__stock h3 { font-size: 1rem; margin-bottom: 8px; }
.stock-list { list-style: none; padding: 0; margin: 0; }
.stock-list__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-200);
}
.stock-list__name {
    flex: 1;
    min-width: 0;
    word-break: break-word;
    font-size: 0.92rem;
    line-height: 1.35;
    color: var(--dark);
}
.stock-list__item--total {
    border-bottom: none;
    border-top: 2px solid var(--dark);
    margin-top: 4px;
    padding-top: 12px;
    font-weight: 700;
}
.stock-list__item--total .stock-list__name { font-weight: 700; letter-spacing: 0.5px; }

/* Compat — legacy stock-table iz ranijih verzija (još uvijek se koristi negdje) */
.stock-table { width: 100%; border-collapse: collapse; }
.stock-table td { padding: 8px; border-bottom: 1px solid var(--gray-200); word-break: break-word; }
.stock-table .muted { color: var(--gray-500); font-size: 0.85rem; }
.stock-table__total td { border-bottom: none; border-top: 2px solid var(--dark); font-weight: 700; }

.product-detail__actions { margin-top: 24px; }
.btn--lg { padding: 14px 28px; font-size: 1.1rem; }

.product-detail__specs { margin-top: 32px; }
.product-detail__specs h2 { font-size: 1.25rem; margin-bottom: 16px; }
.specs-table { width: 100%; max-width: 600px; border-collapse: collapse; }
.specs-table td { padding: 10px; border-bottom: 1px solid var(--gray-200); }
.specs-table td:first-child { color: var(--gray-500); width: 200px; }
.product-detail__external { margin-top: 16px; color: var(--gray-500); font-size: 0.9rem; }
.product-detail__external a { color: var(--primary); }

/* ============================================================ */
/* MOBILE POLISH v3 (22.05.2026) — telefoni + tablet            */
/* ============================================================ */

/* Filter sidebar — anti-zoom za input fontove + bolji spacing */
.catalog__sidebar .filter-form input,
.catalog__sidebar .filter-form select {
    font-size: 16px; /* iOS ne zumira ako je >=16px */
    min-height: 44px; /* Apple HIG touch target */
    box-sizing: border-box;
}
.catalog__sidebar .filter-group { margin-bottom: 14px; }
.catalog__sidebar .filter-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--gray-500);
    margin-bottom: 6px;
}
.catalog__sidebar .filter-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    background: var(--white);
}
.catalog__sidebar .filter-group .checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    font-size: 0.95rem;
    text-transform: none;
    letter-spacing: normal;
    color: var(--dark);
    font-weight: 400;
    cursor: pointer;
}
.catalog__sidebar .filter-group .checkbox input[type=checkbox] {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

/* Product card title — line-clamp 2 reda za duge OTR nazive */
.product-card__title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    min-height: 2.6em; /* rezerviše prostor za 2 reda — kartice ostaju iste visine */
}

/* Tablet (≤900px) — grupisanje filtera vizuelno */
@media (max-width: 900px) {
    .catalog__sidebar .filter-form { display: grid; gap: 8px; }
}

/* ============================================================ */
/* MOBILE — prosta verzija. Drawer = jedan scroll kontejner.    */
/* ============================================================ */
@media (max-width: 768px) {
    /* Override sticky iz desktop sekcije — na mobile nije sticky nego fixed drawer */
    .catalog__sidebar {
        position: fixed !important;
        top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
        height: 100vh;
        height: 100dvh;
        max-height: none !important;
        width: 100% !important;
        max-width: 100% !important;
        z-index: 99;
        overflow-y: scroll !important; /* uvijek pokaži scroll, nikad ne sakrij */
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y; /* dozvoli vertikalni touch scroll */
        padding: 16px 14px calc(80px + env(safe-area-inset-bottom, 0px));
        background: var(--white);
        border: 0;
        border-radius: 0;
        align-self: auto !important;
    }
    /* Na mobile: sakrij gornje akcije, koristimo sticky dno */
    .filter-actions--top {
        display: none !important;
    }
    /* STICKY BOTTOM dugme — UVIJEK vidljivo na dnu ekrana */
    .filter-actions--bottom {
        position: fixed !important;
        left: 0;
        right: 0;
        bottom: 0;
        margin: 0 !important;
        padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
        background: var(--white);
        border-top: 2px solid var(--gray-200);
        box-shadow: 0 -4px 16px rgba(0,0,0,0.12);
        z-index: 100;
    }
    .filter-actions--bottom .btn--primary {
        display: block;
        width: 100%;
        min-height: 52px;
        font-size: 1.05rem;
        font-weight: 700;
        padding: 14px;
        margin: 0;
    }
    /* Sakrij staro Zatvori dugme na dnu — već imamo X gore (ako ga vratimo) i sticky Primeni */
    .catalog__close-mobile {
        display: none !important;
    }

    .catalog__sidebar .filter-group {
        margin-bottom: 14px;
        padding-bottom: 14px;
        border-bottom: 1px solid var(--gray-100);
    }
    .catalog__sidebar .filter-group label:not(.checkbox) {
        display: block;
        font-size: 0.8rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        color: var(--gray-500);
        margin-bottom: 6px;
    }
    .catalog__sidebar .filter-group input[type=search],
    .catalog__sidebar .filter-group select {
        width: 100%;
        min-height: 46px;
        padding: 10px 12px;
        border: 1px solid var(--gray-200);
        border-radius: 6px;
        background: var(--white);
        font-size: 16px;
        box-sizing: border-box;
    }
    .catalog__sidebar .filter-group .checkbox {
        display: flex; align-items: center; gap: 10px;
        min-height: 44px;
        font-size: 0.95rem;
    }
    .catalog__sidebar .filter-group .checkbox input[type=checkbox] {
        width: 22px; height: 22px;
    }

    /* "Primeni filtere" — punog formata, jasno vidljiv */
    .catalog__sidebar .btn--primary,
    .catalog__sidebar .btn--block {
        display: block;
        width: 100%;
        min-height: 52px;
        margin-top: 12px;
        padding: 14px;
        font-size: 1rem;
        font-weight: 700;
        text-align: center;
    }
    .catalog__reset {
        display: block;
        text-align: center;
        margin: 12px 0;
        color: var(--gray-500);
        text-decoration: none;
        font-size: 0.9rem;
    }

    .catalog__filter-toggle { min-height: 48px; font-size: 1rem; margin-bottom: 10px; }
    .catalog__header { margin-bottom: 12px; }
    .catalog__layout { gap: 8px; }
    .catalog__toolbar { margin-bottom: 8px; }

    .stock-list__item { padding: 12px 0; }
    .stock-list__name { font-size: 0.88rem; }

    .specs-table td:first-child { width: 110px; font-size: 0.82rem; }
    .specs-table td:last-child { font-size: 0.9rem; word-break: break-word; }
}

/* Ekstra mali (<400px) — još kompaktnije */
@media (max-width: 400px) {
    .product-card__title { font-size: 0.85rem; }
    .specs-table td:first-child { width: 100px; }
}
