/* Custom Quill Toolbar - Gallery Button */
.ql-toolbar .ql-gallery::before {
    content: "\f302"; /* Font Awesome fa-images */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
}

.ql-toolbar .ql-gallery {
    width: 28px !important;
}

/* Gallery container in editor */
.ql-editor .ql-gallery-container {
    margin: 1.5em 0;
    cursor: pointer;
    transition: all 0.2s;
}

.ql-editor .ql-gallery-container:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ql-editor .ql-gallery-container .edit-gallery-btn {
    opacity: 0;
    transition: opacity 0.2s;
}

.ql-editor .ql-gallery-container:hover .edit-gallery-btn {
    opacity: 1;
}

/* Article gallery styles */
.article-gallery {
    margin: 2rem 0;
}

.article-gallery .gallery-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.article-gallery .gallery-thumbnails::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.article-gallery .gallery-thumbnails::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.article-gallery .gallery-thumbnails::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Lightbox animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#gallery-lightbox {
    animation: fadeIn 0.2s ease-out;
}

/* Gallery Main Container */
.gallery-main-wrapper {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gallery-main-wrapper.aspect-wide {
    aspect-ratio: 16/9;
}

.gallery-main-wrapper.aspect-auto {
    min-height: 400px;
    max-height: 600px;
}

.gallery-main-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: zoom-in;
    transition: opacity 0.3s ease;
    display: block;
}

/* Crop indicator - pokazuje się gdy obraz jest przycięty */
.gallery-crop-indicator {
    position: absolute;
    top: 16px;
    left: 16px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    display: none;
    align-items: center;
    gap: 6px;
    z-index: 10;
    pointer-events: none;
    backdrop-filter: blur(4px);
}

.gallery-crop-indicator i {
    font-size: 14px;
}

.gallery-main-wrapper.is-cropped .gallery-crop-indicator {
    display: flex;
}

.gallery-main-image.loading {
    opacity: 0.5;
}

/* Loading Spinner */
.gallery-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 5;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Error State */
.gallery-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    padding: 20px;
}

.gallery-error i {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Navigation Buttons */
.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s;
    z-index: 10;
}

.gallery-nav:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-50%) scale(1.1);
}

.gallery-nav:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.gallery-nav-prev {
    left: 16px;
}

.gallery-nav-next {
    right: 16px;
}

/* Counter */
.gallery-counter {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10;
}

/* Fullscreen Button */
.gallery-fullscreen-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    z-index: 10;
}

.gallery-fullscreen-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.gallery-fullscreen-btn:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Thumbnails */
.gallery-thumbnails {
    display: none; /* Ukryj miniaturki w głównym widoku */
}

.gallery-thumb {
    position: relative;
    padding-top: 100%;
    background: #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
}

.gallery-thumb:hover {
    transform: scale(1.05);
}

.gallery-thumb:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.gallery-thumb.active {
    border-color: #3b82f6;
}

.gallery-thumb img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Caption */
.gallery-caption {
    margin-top: 12px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
    font-style: italic;
}

/* Lightbox */
.gallery-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease-out;
}

.lightbox-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 10;
    transition: all 0.2s;
}

.lightbox-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.lightbox-close-btn:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.lightbox-image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: calc(100vh - 180px);
    position: relative;
    width: 100%;
    margin-bottom: 20px;
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: opacity 0.3s ease;
}

.lightbox-image.loading {
    opacity: 0.5;
}

.lightbox-nav {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: none;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.2s;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.lightbox-nav:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.lightbox-nav-prev {
    left: 20px;
}

.lightbox-nav-next {
    right: 20px;
}

/* Hide navigation buttons on mobile - swipe only */
@media (max-width: 768px) {
    .lightbox-nav-desktop {
        display: none !important;
    }
}

.lightbox-counter {
    color: white;
    font-size: 16px;
    font-weight: 500;
    flex-shrink: 0;
}

.lightbox-thumbnails {
    display: flex;
    gap: 8px;
    max-width: calc(100vw - 40px);
    overflow-x: auto;
    padding: 8px 0;
    scroll-behavior: smooth;
    flex-shrink: 0;
}

.lightbox-thumbnails::-webkit-scrollbar {
    height: 8px;
}

.lightbox-thumbnails::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.lightbox-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.lightbox-thumbnails::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.lightbox-thumb {
    flex-shrink: 0;
    width: 80px;
    height: 60px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
    opacity: 0.6;
}

.lightbox-thumb:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.lightbox-thumb:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.lightbox-thumb.active {
    border-color: white;
    opacity: 1;
}

.lightbox-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lightbox-keyboard-hint {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
    pointer-events: none;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 8px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .gallery-nav {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .gallery-thumbnails {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }
    
    .lightbox-nav-desktop {
        display: none !important;
    }
    
    .lightbox-image-container {
        max-height: calc(100vh - 140px);
    }
    
    .lightbox-thumbnails {
        padding: 4px 0;
        max-width: calc(100vw - 20px);
        gap: 6px;
    }
    
    .lightbox-thumb {
        width: 60px;
        height: 45px;
    }
    
    .lightbox-keyboard-hint {
        display: none;
    }
}
