/* ============================================================
   MEDIA GRID — FINAL ENGINE (JS DYNAMIC ROW HEIGHT)
   STATUS: FROZEN
   ============================================================ */


/* ============================================================
   CONTAINER SYSTEM
   ============================================================ */

.mb-container {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 16px;
    padding-right: 16px;
    box-sizing: border-box;
}


/* ============================================================
   SECTION PADDING SYSTEM
   ============================================================ */

.mb-test {
    --mb-section-pt: 60px;
    --mb-section-pb: 60px;

    padding-top: var(--mb-section-pt);
    padding-bottom: var(--mb-section-pb);
}

@media (max-width: 767px) {
    .mb-test {
        --mb-section-pt: 90px;
        --mb-section-pb: 40px;
    }
}


/* ============================================================
   GRID LAYOUT — DYNAMIC SLOT (CONTROLLED BY JS)
   ============================================================ */

:root {
    /* fallback – JS nadpisuje dynamicznie */
    --mb-row: 220px;
}

.mb-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);

    /* KLUCZ SYSTEMU */
    grid-auto-rows: var(--mb-row);
    grid-auto-flow: dense;

    gap: 18px;
    transition: opacity 180ms ease;
}


/* ============================================================
   FADE STATE
   ============================================================ */

.mb-grid.is-fading {
    opacity: 0;
}


/* ============================================================
   CARD — GRID ITEM (HEIGHT = N × --mb-row)
   ============================================================ */

.mb-card {
    box-sizing: border-box;
    width: 100%;

    background: #fff;
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 4px 14px rgba(0,0,0,0.02);

    display: flex;
    flex-direction: column;

    transition: box-shadow 180ms ease;

    /* DOMYŚLNIE 1 SLOT */
    grid-row: span 1;

    /* FLEX SAFETY */
    min-height: 0;
    overflow: hidden;
}

/* PODWÓJNY KAFEL — 2 SLOTY */
.mb-card--large {
    grid-row: span 2;
}

.mb-card:hover {
    box-shadow: 0 6px 18px rgba(0,0,0,0.05);
}


/* ============================================================
   IMAGE CONTAINER — ELASTYCZNY, MASKUJĄCY
   ============================================================ */

.mb-card-image {
    position: relative;
    width: 100%;

    /* bierze całą pozostałą przestrzeń */
    flex: 1 1 auto;

    background: #fff;
    overflow: hidden;

    /* FLEX SAFETY */
    min-height: 0;
}


/* ============================================================
   IMAGE — WYKROJNIK TECHNICZNY (NO CROP, SAFE)
   ============================================================ */

.mb-card-image img {
    width: 100%;
    height: 100%;
    display: block;

    object-fit: contain;
    object-position: center;

    background: #fff;

    /* ANTI-EDGE-CASE */
    max-width: 100%;
    max-height: 100%;
    flex-shrink: 1;
}


/* ============================================================
   OVERLAY
   ============================================================ */

.mb-card-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.18);
    opacity: 0;
    transition: opacity 180ms ease;
}

.mb-card-image:hover .mb-card-overlay {
    opacity: 1;
}


/* ============================================================
   CONTENT — ELASTYCZNY BUFOR (TYPO SAFE)
   ============================================================ */

.mb-card-content {
    flex: 0 1 auto;

    min-height: 56px;
    max-height: 80px;

    padding: 7px 12px 10px;

    background: #fff;

    /* klucz: nie tniemy descendery */
    overflow-x: hidden;
    overflow-y: visible;

    display: flex;
    flex-direction: column;
    justify-content: center;
}


/* ============================================================
   TEXT — TECHNICZNY, JEDNOLINIOWY
   ============================================================ */

.mb-card-title,
.mb-card-text,
.mb-card-dimensions {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mb-card-title {
    font-size: 13px;
    font-weight: 500;
    color: rgb(7, 138, 6);

    margin-bottom: 1px;
    line-height: 1.1;
}

.mb-card-title a {
    color: inherit;
    text-decoration: none;
}

.mb-card-text,
.mb-card-dimensions {
    font-size: 11px;
    color: #777;
    line-height: 1.4;
}


/* ============================================================
   FILTERS
   ============================================================ */


.filters-container {
    margin-bottom: 15px;
}

.media-boxes-filter {
    list-style: none;
    padding: 0;
    margin: 0;
    display: inline-block;
    font-size: 0;
}

.media-boxes-filter > li {
    display: inline-block;
    margin: 0 10px 5px 0;
}

.media-boxes-filter > li a {
    display: block;
    padding: 0 15px;
    height: 38px;
    line-height: 38px;

    font-size: 13px;
    color: #444;
    text-decoration: none;

    border: 1px solid #ebebeb;
    background: #fff;

    transition: border 0.1s ease;
}

.media-boxes-filter > li a:hover {
    border-color: #dadada;
}

.media-boxes-filter > li a.selected {
    background: #4d4c4d;
    color: #fff;
}


/* ============================================================
   RESPONSIVE — ZMIANA TYLKO LICZBY KOLUMN
   ============================================================ */

@media (max-width: 1024px) {
    .mb-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 820px) {
    .mb-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .mb-grid {
        grid-template-columns: 1fr;
    }
}
/* ============================================================
   VIEW TOGGLE — COLUMNS (2×2 GRID BUTTON)
   FINAL / FROZEN
   ============================================================ */


/* ============================================================
   FILTERS LAYOUT — FILTRY + PRZYCISK PO PRAWEJ
   ============================================================ */

.filters-container {
    display: flex;
    align-items: flex-start;     /* KLUCZ: przycisk NIE wędruje */
    gap: 12px;
}

/* lista filtrów — MOŻE się zawijać */
.media-boxes-filter {
    flex: 1 1 auto;
    min-width: 0;               /* KLUCZ: pozwala filtrom się zwijać */
}

/* wrapper przycisku — NIGDY się nie kurczy */
.mb-view-toggle {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
}


/* ============================================================
   PRZYCISK ZMIANY KOLUMN — 38×38
   ============================================================ */

.mb-grid-btn {
    width: 38px;
    height: 38px;               /* taka sama wysokość jak filtry */
    padding: 6px;

    box-sizing: border-box;

    background: #fff;
    border: 1px solid #ebebeb;
    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    transition: border-color 0.1s ease;
}

/* hover IDENTYCZNY jak filtry */
.mb-grid-btn:hover {
    border-color: #dadada;
}


/* ============================================================
   IKONA 2×2 — WYPEŁNIA CAŁY PRZYCISK
   ============================================================ */

/*
  STRUKTURA:
  .mb-grid-btn
    └── .mb-grid-icon
          ├── span
          ├── span
          ├── span
          └── span
*/

.mb-grid-btn .mb-grid-icon {
    width: 100%;
    height: 100%;

    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 4px;
}

/* pojedynczy kwadrat */
.mb-grid-btn .mb-grid-icon span {
    display: block;
    width: 100%;
    height: 100%;

    background: #cfcfd1;        /* nieaktywny */
}


/* ============================================================
   VIEWPORT LIMITS — UKRYWANIE NIEDOZWOLONYCH
   ============================================================ */

/* mobile — tylko 1 kolumna */
.mb-test[data-max-cols="1"] .mb-grid-btn span:nth-child(n+2) {
    display: none;
}

/* tablet — max 2 kolumny */
.mb-test[data-max-cols="2"] .mb-grid-btn span:nth-child(n+3) {
    display: none;
}

/* small desktop — max 3 kolumny */
.mb-test[data-max-cols="3"] .mb-grid-btn span:nth-child(4) {
    display: none;
}


/* ============================================================
   STANY — ILOŚĆ KOLUMN = ILOŚĆ ZAPALONYCH
   ============================================================ */

.mb-test[data-cols="1"] .mb-grid-btn span:nth-child(1),
.mb-test[data-cols="2"] .mb-grid-btn span:nth-child(-n+2),
.mb-test[data-cols="3"] .mb-grid-btn span:nth-child(-n+3),
.mb-test[data-cols="4"] .mb-grid-btn span:nth-child(-n+4) {
    background: #24820b;        /* aktywny */
}


/* ============================================================
   GRID — STEROWANIE LICZBĄ KOLUMN (JS → CSS)
   ============================================================ */

.mb-test[data-cols="4"] .mb-grid {
    grid-template-columns: repeat(4, 1fr);
}

.mb-test[data-cols="3"] .mb-grid {
    grid-template-columns: repeat(3, 1fr);
}

.mb-test[data-cols="2"] .mb-grid {
    grid-template-columns: repeat(2, 1fr);
}

.mb-test[data-cols="1"] .mb-grid {
    grid-template-columns: 1fr;
}



/* ============================================================
   MB VIEWER — KONTENER 1200px + UKŁAD 50 / 50
   ============================================================ */
.mb-viewer {
    padding-top: 4rem;
}

.mb-viewer {
    width: 100%;
}

.mb-viewer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;

    display: grid;
    grid-template-columns: 1fr 1fr; /* ZAWSZE 50 / 50 */
    gap: 2rem;
    align-items: stretch;
}
/* ============================================================
   LEWA STRONA — VIEWER / KANWA
   ============================================================ */

.mb-viewer-media {
    position: relative;
    display: flex;
    flex-direction: column;
}

/* RAMA NA OBRAZ / WYKROJNIK */
.mb-viewer-canvas {
    position: relative;
    flex: 1;
    min-height: 320px;
    background: #f5f5f5; /* neutralne tło */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* OBRAZY / SVG / CANVAS — JEDNA ZASADA */
.mb-viewer-canvas img,
.mb-viewer-canvas svg,
.mb-viewer-canvas canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ============================================================
   KONTROLKI KARUZELI
   ============================================================ */

.mb-viewer-controls {
    display: flex;
    justify-content: space-between;
    margin-top: 0.75rem;
}

.mb-viewer-controls button {
    width: 48px;
    height: 48px;
    background: transparent;
    border: 1px solid #ccc;
    cursor: pointer;
    position: relative;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.mb-viewer-controls button:hover {
    background: #eee;
    border-color: #999;
}

/* STRZAŁKI — CZYSTY CSS */
.mb-viewer-prev::before,
.mb-viewer-next::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    border-top: 2px solid #333;
    border-right: 2px solid #333;
    transform-origin: center;
}

.mb-viewer-prev::before {
    transform: translate(-50%, -50%) rotate(-135deg);
}

.mb-viewer-next::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

/* ============================================================
   PRAWA STRONA — DANE
   ============================================================ */

.mb-viewer-data {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* NAGŁÓWEK */
.mb-viewer-header {
    margin-bottom: 1rem;
}

.mb-viewer-title {
    font-size: 1.4rem;
    font-weight: 500;
    margin: 0;
}

/* ============================================================
   TABELA DANYCH
   ============================================================ */

.mb-viewer-specs {
    width: 100%;
}

.mb-specs-table {
    width: 100%;
    border-collapse: collapse;
}

.mb-specs-table th,
.mb-specs-table td {
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    vertical-align: top;
}

.mb-specs-table th {
    text-align: left;
    font-weight: 500;
    color: #555;
    white-space: nowrap;
}

.mb-specs-table td {
    text-align: left;
    color: #111;
}

/* LEKKIE ODDZIELENIE WIERSZY */
.mb-specs-table tr + tr th,
.mb-specs-table tr + tr td {
    border-top: 1px solid #e5e5e5;
}

/* ============================================================
   RESPONSYWNOŚĆ
   ============================================================ */

@media (max-width: 900px) {
    .mb-viewer-container {
        grid-template-columns: 1fr;
    }

    .mb-viewer-media {
        order: 1;
    }

    .mb-viewer-data {
        order: 2;
    }

    .mb-viewer-canvas {
        min-height: 260px;
    }
}
/* ============================================================
   PRZYCISK SORTOWANIA — 38×38 (SYSTEMOWY)
   ============================================================ */

.mb-sort-btn {
    width: 38px;
    height: 38px;
    padding: 6px;

    box-sizing: border-box;

    background: #fff;
    border: 1px solid #ebebeb;
    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    transition: border-color 0.1s ease;
}

/* hover — IDENTYCZNY jak grid-btn i filtry */
.mb-sort-btn:hover {
    border-color: #dadada;
}


/* ============================================================
   IKONA SORTU — 2 TRÓJKĄTY (CSS)
   ============================================================ */

.mb-sort-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;

    pointer-events: none;
}

.mb-triangle {
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
}

/* ▲ */
.mb-triangle-up {
    border-bottom: 7px solid #cfcfd1;   /* nieaktywny */
}

/* ▼ */
.mb-triangle-down {
    border-top: 7px solid #cfcfd1;      /* nieaktywny */
}


/* ============================================================
   STANY SORTOWANIA
   ============================================================ */

/* ASC — zapala się górny */
.mb-sort-btn[data-sort="asc"] .mb-triangle-up {
    border-bottom-color: #24820b;
}

/* DESC — zapala się dolny */
.mb-sort-btn[data-sort="desc"] .mb-triangle-down {
    border-top-color: #24820b;
}


/* ============================================================
   TABS HEADER — LAYOUT
   ============================================================ */

.tabs-header-bar {
    display: flex;
    align-items: center;
}

/* tytuł po lewej */
.tabs-heading {
    flex: 0 0 auto;
}

/* grupa przycisków po prawej */
.tabs-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tabs-header-bar {
    position: relative;
    z-index: 50;
}
.mb-test {
    position: relative;
}

/* ============================================================
   PRZYCISK LUPY — SYSTEMOWY 38×38
   (logika w JS, CSS tylko rysuje)
   ============================================================ */

.mb-zoom-btn {
    width: 38px;
    height: 38px;
    padding: 6px;

    box-sizing: border-box;

    background: #fff;
    border: 1px solid #ebebeb;
    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    transition: border-color 0.1s ease, opacity 0.1s ease;
}

/* hover — identyczny jak inne przyciski */
.mb-zoom-btn:hover {
    border-color: #dadada;
}

/* stan niedostępny — sterowany WYŁĄCZNIE przez JS */
.mb-zoom-btn:disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

/* ============================================================
   IKONA LUPY (CSS ONLY)
   ============================================================ */

.mb-zoom-icon {
    position: relative;
    width: 18px;
    height: 18px;
}

.mb-zoom-glass {
    position: absolute;
    width: 12px;
    height: 12px;

    box-sizing: border-box;

    border: 2px solid #cfcfd1;
    border-radius: 50%;

    top: 1px;
    left: 1px;
}

.mb-zoom-glass::after {
    content: '';
    position: absolute;

    width: 8px;
    height: 2px;

    background: #cfcfd1;

    bottom: -4px;
    right: -4px;

    transform: rotate(60deg);
}

/* ============================================================
   STAN AKTYWNY (LUPA ON)
   ============================================================ */

.mb-zoom-btn[data-zoom="on"] .mb-zoom-glass {
    border-color: #24820b;
}

.mb-zoom-btn[data-zoom="on"] .mb-zoom-glass::after {
    background: #24820b;
}

/* ============================================================
   TECHNICAL ZOOM — HOVER (STEROWANY JS)
   ============================================================ */

/* baza — brak fałszywego affordance */
.mb-card-image {
    position: relative;
    overflow: hidden;
    cursor: default;
}

/* kursor lupy TYLKO gdy:
   - JS ustawi .zoom-enabled
   - liczba kolumn ≥ 3
*/
.mb-test.zoom-enabled[data-cols="3"] .mb-card-image,
.mb-test.zoom-enabled[data-cols="4"] .mb-card-image {
    cursor: zoom-in;
}

/* aktywny zoom */
.mb-card-image.zoom-active {
    image-rendering: crisp-edges;
    background-repeat: no-repeat;
    background-size: 200%;
}

/* ukrycie oryginalnego <img> podczas zoomu */
.mb-card-image.zoom-active img {
    opacity: 0;
}
/* ============================================================
   LUPA — TYLKO DESKTOP (HOVER)
   ============================================================ */

/* urządzenia dotykowe (iPad, mobile) */
@media (hover: none), (pointer: coarse) {

    .mb-zoom-btn {
        display: none !important;
    }

}
/* ============================================================
   TABS HEADING — SYSTEMOWY LABEL (FINAL)
   ============================================================ */


.tabs-heading {
    display: inline-flex;
    align-items: center;
    gap: 10px;

    height: 38px;
    padding: 0;

    background: none;
    border: none;

    font-size: 15px;
    font-weight: 500;

    box-sizing: border-box;
}


/* ============================================================
   IKONA NAGŁÓWKA — 3×3 (SYSTEMOWA)
   ============================================================ */

.mb-heading-icon {
    width: 38px;
    height: 38px;
    padding: 6px;

    box-sizing: border-box;

    background: #fff;
    border: 0px solid #ebebeb;

    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
}

/* kwadraciki — systemowy zielony */
.mb-heading-icon span {
    display: block;
    width: 100%;
    height: 100%;
    background: #24820b;
}


/* ============================================================
   TEKST NAGŁÓWKA — LABEL
   ============================================================ */

.mb-heading-text {
    white-space: nowrap;
    color: #777;
}
