/* =========================================================
   1. RESET I SIATKA GŁÓWNA (GRID)
   ========================================================= */
.woocommerce ul.products,
ul.products {
    display: grid !important;
    /* KLUCZOWE: minmax(0, 1fr) zabrania zawartości (czyli zdjęciom) rozpychać kolumny na boki! Kolumny będą miały SZTYWNĄ i RÓWNĄ szerokość */
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    grid-auto-rows: 1fr !important;
    gap: 24px !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.related ul.products,
.up-sells ul.products,
.cross-sells ul.products {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

.woocommerce ul.products::before, .woocommerce ul.products::after,
ul.products::before, ul.products::after { display: none !important; content: none !important; }

/* =========================================================
   2. GŁÓWNY KONTENER KARTY
   ========================================================= */
.woocommerce ul.products li.tw-modern-card,
ul.products li.tw-modern-card {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    background-color: #ffffff !important;
    border-radius: 14px !important;
    padding: 14px !important; 
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.05) !important;
    transition: box-shadow 0.3s ease, transform 0.2s ease !important;
    margin: 0 !important;
    width: 100% !important; /* Zablokowane na 100% szerokości kolumny, ani piksela więcej */
    max-width: 100% !important; 
    box-sizing: border-box !important;
    overflow: hidden !important;
}

ul.products li.tw-modern-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
    transform: translateY(-4px) !important;
}

.tw-modern-inner {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    height: 100% !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif !important;
}

/* =========================================================
   3. RAMKA NA ZDJĘCIE ("SZTYWNA KLATKA")
   ========================================================= */
.tw-modern-img-wrap {
    /* Zmieniamy background-color */
    background-color: var(--season-bg) !important; 
    
    /* Reszta bez zmian */
    position: relative !important;
    width: 100% !important;
    aspect-ratio: 4 / 5 !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    display: block !important;
    margin-bottom: 16px !important;
    flex-shrink: 0 !important;
}

/* Pojemnik linku też musi sztywno wypełniać klatkę */
.tw-modern-img-link {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}

/* SAMO ZDJĘCIE - Zmuszone do wpasowania się w wyżej zdefiniowany obszar */
.tw-modern-img-wrap img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important; /* Wypełnia równe 100% sztywnego pudełka */
    height: 100% !important; /* Wypełnia równe 100% sztywnego pudełka */
    max-width: 100% !important;
    max-height: 100% !important;
    object-fit: cover !important; /* Ucinanie "od środka" (kadrowanie) wszystkiego co nie pasuje do wymiarów klatki */
    object-position: center !important; /* Kadrowanie zawsze względem środka */
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

/* Pinezka / Wishlist */
.tw-modern-wishlist {
    position: absolute !important;
    top: 10px !important;
    left: 10px !important;
    background: #ffffff !important;
    border: none !important;
    color: #6366f1 !important;
    cursor: pointer !important;
    z-index: 5 !important;
    padding: 6px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important; justify-content: center !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
    transition: transform 0.2s !important;
}

.tw-modern-wishlist:hover { 
    transform: scale(1.1) !important; 
    background-color: var(--season-bg) !important;
    color: var(--season-text) !important;
}

.tw-modern-wishlist svg { width: 16px !important; height: 16px !important; display: block !important; }

/* Badges (Zniżki) */
.tw-modern-badges {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    display: flex !important;
    gap: 4px !important;
    z-index: 5 !important;
}

.tw-badge-sale {
    background-color: var(--season-bg) !important;
    color: var(--season-text) !important;
    border: 1px solid var(--season-border) !important;
    /* Reszta zostaje bez zmian */
    font-size: 11px !important;
    font-weight: 700 !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
}

/* =========================================================
   4. DIVIDER (Linia pod zdjęciem)
   ========================================================= */
.tw-modern-divider {
    width: 100% !important;
    height: 1px !important;
    background-color: #f1f5f9 !important;
    margin: 0 0 14px 0 !important;
    display: block !important;
}

/* =========================================================
   5. SEKCJA INFORMACYJNA
   ========================================================= */
.tw-modern-info {
    display: flex !important;
    flex-direction: column !important;
    flex-grow: 1 !important;
    width: 100% !important;
}

.tw-modern-title-link {
    text-decoration: none !important;
    display: block !important;
    margin-bottom: 8px !important;
    overflow: hidden !important;
}

.tw-modern-title {
    font-size: 15px !important;
    font-weight: 600 !important;
    color: #1e293b !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.4 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* Oceny */
.tw-modern-rating {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    margin-bottom: 16px !important;
    font-size: 13px !important;
    color: #64748b !important;
}

.tw-rating-number {
    font-weight: 700 !important;
    color: #1e293b !important;
    font-size: 14px !important;
}

.tw-modern-rating .star-rating {
    font-size: 13px !important;
    color: #f59e0b !important;
    width: 5.4em !important;
    float: none !important;
    margin: 0 !important;
    display: block !important;
}
.tw-modern-rating .star-rating::before { color: #e2e8f0 !important; }
.tw-modern-rating .star-rating span { color: #f59e0b !important; }

.tw-rating-count {
    display: flex !important;
    align-items: center !important;
    gap: 3px !important;
}

/* =========================================================
   6. DÓŁ KARTY (Cena i Przycisk)
   ========================================================= */
.tw-modern-bottom {
    margin-top: auto !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
}

.tw-modern-price {
    font-size: 19px !important;
    font-weight: 700 !important;
    color: #0f172a !important;
    margin: 0 !important;
    padding: 0 !important;
}

.tw-modern-price ins { text-decoration: none !important; color: #0f172a !important; }
.tw-modern-price del { font-size: 14px !important; color: #94a3b8 !important; margin-right: 6px !important; font-weight: 500 !important; }

/* Przycisk akcji */
ul.products li.tw-modern-card a.tw-modern-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    background-color: #f8fafc !important;
    color: #334155 !important;
    border: 1px solid #e2e8f0 !important;
    padding: 12px 16px !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    box-sizing: border-box !important;
    margin: 0 !important;
}

ul.products li.tw-modern-card a.tw-modern-btn:hover {
    background-color: #6366f1 !important;
    border-color: #6366f1 !important;
    color: #ffffff !important;
}

ul.products li.tw-modern-card a.tw-modern-btn.added { display: flex !important; }
ul.products li.tw-modern-card a.added_to_cart { display: none !important; }

/* =========================================================
   7. MEDIA QUERIES (Responsywność)
   ========================================================= */
@media (max-width: 1440px) { .woocommerce ul.products, ul.products { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 20px !important; } }
@media (max-width: 1024px) { .woocommerce ul.products, ul.products { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 16px !important; } }
@media (max-width: 768px) {
    .woocommerce ul.products, ul.products { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 12px !important; }
    .woocommerce ul.products li.tw-modern-card, ul.products li.tw-modern-card { padding: 10px !important; }
    .tw-modern-title { font-size: 13px !important; }
    .tw-modern-price { font-size: 16px !important; }
    ul.products li.tw-modern-card a.tw-modern-btn { padding: 10px 12px !important; font-size: 12px !important; }
}

/* =========================================================
   POPUP DODANIA DO KOSZYKA (MODAL)
   ========================================================= */
.tw-cart-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(17, 24, 39, 0.65);
    backdrop-filter: blur(4px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Stan aktywny (otwarty popup) */
.tw-cart-popup-overlay.tw-active {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    display: flex !important;
}

.tw-cart-popup-container {
    background-color: #ffffff;
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    padding: 32px 28px 28px 28px;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    transform: scale(0.92);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 90vh;
    overflow-y: auto;
}

.tw-cart-popup-overlay.tw-active .tw-cart-popup-container {
    transform: scale(1);
}

/* Przycisk zamknięcia X */
.tw-cart-popup-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
    transition: color 0.2s ease;
    padding: 4px;
}
.tw-cart-popup-close:hover {
    color: #111827;
}

/* Widoki wewnątrz popupu */
.tw-popup-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
}

/* Ikona Sukcesu z Animacją */
.tw-popup-icon-wrap {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
}

.tw-popup-check-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: block;
    stroke-width: 3;
    stroke: #10b981;
    stroke-miterlimit: 10;
    box-shadow: inset 0px 0px 0px #10b981;
    animation: tw-fill .4s ease-in-out .4s forwards, tw-scale .3s ease-in-out .9s both;
}

.tw-popup-check-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 3;
    stroke-miterlimit: 10;
    stroke: #10b981;
    fill: none;
    animation: tw-stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.tw-popup-check-check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: tw-stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes tw-stroke { 100% { stroke-dashoffset: 0; } }
@keyframes tw-scale { 0%, 100% { transform: none; } 50% { transform: scale3d(1.1, 1.1, 1); } }


/* Nagłówek Popupa */
.tw-popup-title {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 20px 0;
    line-height: 1.3;
}

/* Karta produktu w popupie */
.tw-popup-product-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 16px;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 24px;
    text-align: left;
}

.tw-popup-prod-img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.tw-popup-prod-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tw-popup-prod-title {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
}

.tw-popup-prod-price {
    font-size: 15px;
    font-weight: 700;
    color: var(--season-text, #8d735d);
}

/* Przyciski Akcji */
.tw-popup-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.tw-popup-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.tw-popup-btn-primary {
    background-color: var(--season-text, #111827);
    color: #ffffff;
    border: none;
}
.tw-popup-btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.tw-popup-btn-secondary {
    background-color: #ffffff;
    color: #374151;
    border: 1px solid #d1d5db;
}
.tw-popup-btn-secondary:hover {
    background-color: #f3f4f6;
    color: #111827;
}

/* Spinner ładowania opcji "Dostosuj" */
.tw-popup-spinner-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 0;
    gap: 12px;
    color: #6b7280;
    font-size: 14px;
}
.tw-popup-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--season-text, #111827);
    border-radius: 50%;
    animation: tw-spin 0.8s linear infinite;
}
@keyframes tw-spin { to { transform: rotate(360deg); } }

/* Kontener na bannery */
.promo-badges-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0; /* Odstęp od góry i dołu */
    width: 100%;
}

/* Pojedynczy banner promocyjny */
.custom-promo-badge {
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    box-sizing: border-box;
    /* Kolory tła i tekstu pobierają się dynamicznie z bazy (style inline), 
       ale możesz dodać domyślne, jeśli brakuje danych: */
}

.custom-promo-badge p {
    margin: 0;
}

/* Jeśli chcesz, żeby bannery były nałożone na zdjęcie (np. jako badge w lewym rogu) */
.tw-modern-img-wrap {
    position: relative; /* Wymagane, jeśli chcesz pozycjonować absolutnie */
}

.tw-modern-img-wrap .promo-badges-stack {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
    max-width: calc(100% - 20px);
}