.pdf-magazine-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px 0;
}

.pdf-mag-covers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 25px;
    width: 100%;
    margin-bottom: 30px;
}

.pdf-mag-cover-item {
    cursor: pointer;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: #fff;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pdf-mag-cover-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 20px rgba(0,0,0,0.15);
}

.pdf-mag-cover-item img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1.414; /* Proporcje A4 */
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 15px;
    border: 1px solid #eaeaea;
}

.pdf-mag-cover-placeholder {
    width: 100%;
    aspect-ratio: 1 / 1.414;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    margin-bottom: 15px;
    color: #888;
    font-weight: bold;
    padding: 10px;
    box-sizing: border-box;
    text-align: center;
    border: 1px dashed #ccc;
}

.pdf-mag-cover-item h4 {
    margin: 0;
    font-size: 16px;
    color: #222;
    font-family: sans-serif;
    line-height: 1.3;
}

/* Lightbox Overlay */
.pdf-magazine-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.9);
}

.pdf-magazine-lightbox-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.5; /* Przyciemniamy tło (np. drewno), by magazyn był czytelniejszy */
}

.pdf-magazine-close {
    position: absolute;
    top: 20px;
    right: 30px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000000;
    transition: all 0.3s ease;
}

.pdf-magazine-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.pdf-magazine-viewer-area {
    width: 95%;
    max-width: 1800px; /* Zwiększamy maksymalną szerokość w Lightboxie */
    height: 92vh; /* Zajmuje 92% wysokości ekranu */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.pdf-magazine-wrapper {
    position: relative;
    width: 100%;
    height: 100%; /* Wypełnia całą dostępną przestrzeń w viewer-area */
    min-height: 300px;
    background-color: transparent; /* Tło jest teraz na poziomie lightboxa */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 20px;
    box-sizing: border-box;
}

.pdf-magazine-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.3);
    z-index: 10;
    width: 80%;
    max-width: 320px;
}

.loading-cover {
    width: 140px;
    height: auto;
    aspect-ratio: 1 / 1.414;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
    margin-bottom: 20px;
    border: 1px solid rgba(255,255,255,0.1);
}

.loading-text {
    color: #fff;
    font-family: sans-serif;
    font-size: 14px;
    margin-bottom: 12px;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.loading-percentage {
    font-weight: bold;
    color: #4db8ff;
}

.loading-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2);
}

.loading-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #0073aa, #4db8ff);
    border-radius: 10px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(77, 184, 255, 0.5);
}

.flip-book {
    display: none;
    width: 100%;
    height: 100%;
    /* Dodajemy cień pod samym magazynem */
    filter: drop-shadow(0 15px 25px rgba(0,0,0,0.5));
}

.flip-book.stf-ready {
    display: block;
}

.flip-book .page {
    background-color: white;
    overflow: hidden;
    cursor: pointer;
}

/* Gradient imitujący zagięcie strony na środku */
.flip-book .page.--left {
    border-right: 1px solid rgba(0,0,0,0.1);
    box-shadow: inset -10px 0 20px rgba(0,0,0,0.05);
}

.flip-book .page.--right {
    border-left: 1px solid rgba(0,0,0,0.1);
    box-shadow: inset 10px 0 20px rgba(0,0,0,0.05);
}

.flip-book .page canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.qr-overlay {
    position: absolute;
    z-index: 99999 !important;
    pointer-events: auto !important;
}

.pdf-magazine-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    font-family: sans-serif;
    margin-top: 25px;
    background: rgba(20, 20, 20, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 10px 25px;
    border-radius: 50px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    z-index: 10;
}

.pdf-magazine-controls button {
    background: transparent;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: none;
}

.pdf-magazine-controls button:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.1);
}

.pdf-magazine-controls button:active {
    transform: scale(0.95);
}

.download-option:hover {
    background: rgba(255,255,255,0.2) !important;
}

.pdf-magazine-controls .btn-magnify.active {
    background: rgba(77, 184, 255, 0.4) !important;
    color: white;
}

.magnifier-lens {
    position: fixed;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5), inset 0 0 20px rgba(0,0,0,0.2);
    pointer-events: none;
    display: none;
    z-index: 9999999;
    background-color: white;
    overflow: hidden;
    transform: translate(-50%, -50%);
}

.magnifier-lens canvas {
    position: absolute;
    top: 0;
    left: 0;
}

@media (max-width: 1024px) {
    .pdf-magazine-controls .btn-magnify {
        display: none !important;
    }
}

.pdf-magazine-controls .page-info {
    font-size: 16px;
    color: white;
    font-weight: 500;
    letter-spacing: 1px;
    min-width: 80px;
    text-align: center;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.pdf-magazine-controls .current-page {
    width: 45px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    text-align: center;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    padding: 2px 0;
    -moz-appearance: textfield;
    transition: all 0.2s ease;
}

.pdf-magazine-controls .current-page::-webkit-outer-spin-button,
.pdf-magazine-controls .current-page::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.pdf-magazine-controls .current-page:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.2);
    border-color: #4db8ff;
}
