/**
 * Pusedainos Wiki - Gallery Styles
 *
 * Styles for public gallery page, article carousel, lightbox,
 * and admin gallery management.
 */

/* ===== Public Gallery Page ===== */
.gallery-page .gallery-subtitle {
    color: #666;
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

/* Filter Tabs */
.gallery-filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1.5rem 0;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e5e5;
}

.filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 0.85rem;
    color: #555;
    text-decoration: none;
    transition: all 0.2s;
    background: white;
}

.filter-tab:hover {
    border-color: #8b0000;
    color: #8b0000;
    background: #fff5f5;
}

.filter-tab.active {
    background: #8b0000;
    color: white;
    border-color: #8b0000;
}

.filter-count {
    font-size: 0.75rem;
    background: rgba(0, 0, 0, 0.1);
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
}

.filter-tab.active .filter-count {
    background: rgba(255, 255, 255, 0.25);
}

/* Gallery Group */
.gallery-group {
    margin-bottom: 2.5rem;
}

.gallery-group-header {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #8b0000;
}

.gallery-group-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.gallery-group-header h2 a {
    color: #1a1a1a;
    text-decoration: none;
}

.gallery-group-header h2 a:hover {
    color: #8b0000;
}

.gallery-group-category {
    font-size: 0.8rem;
    color: #666;
    background: #f0f0f0;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.gallery-group-count {
    font-size: 0.8rem;
    color: #999;
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.gallery-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 1;
    background: #f5f5f5;
    transition: transform 0.2s, box-shadow 0.2s;
}

.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.gallery-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-item-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: white;
    font-size: 0.75rem;
    line-height: 1.3;
}

/* Hidden gallery items (only used for lightbox data) */
.gallery-item--hidden {
    display: none !important;
}

/* "Show more" overlay on last visible image */
.gallery-more-item {
    text-decoration: none;
    display: block;
}

.gallery-more-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    transition: background 0.2s;
}

.gallery-more-item:hover .gallery-more-overlay {
    background: rgba(0, 0, 0, 0.75);
}

.gallery-more-count {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.gallery-more-label {
    font-size: 0.8rem;
    margin-top: 0.25rem;
    opacity: 0.85;
}

.gallery-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #999;
}

/* ===== Lightbox ===== */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.lightbox-content {
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-caption {
    color: white;
    font-size: 0.95rem;
    margin-top: 0.75rem;
    text-align: center;
    max-width: 600px;
}

.lightbox-counter {
    position: absolute;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: white;
    font-size: 2.5rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    z-index: 2;
    line-height: 1;
}

.lightbox-close:hover {
    opacity: 1;
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 3rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    opacity: 0.6;
    transition: opacity 0.2s, background 0.2s;
    z-index: 2;
    line-height: 1;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
    left: 1rem;
}

.lightbox-next {
    right: 1rem;
}

/* ===== Article Carousel ===== */
.article-gallery-section {
    margin-top: 2rem;
}

.article-carousel {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.carousel-track-wrapper {
    flex: 1;
    overflow: hidden;
    border-radius: 8px;
}

.carousel-track {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0.25rem 0;
}

.carousel-track::-webkit-scrollbar {
    display: none;
}

.carousel-slide {
    flex: 0 0 auto;
    width: 220px;
    height: 165px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: #f5f5f5;
    transition: transform 0.2s;
}

.carousel-slide:hover {
    transform: scale(1.03);
}

.carousel-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.carousel-btn {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid #ddd;
    background: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    transition: all 0.2s;
    line-height: 1;
}

.carousel-btn:hover {
    background: #8b0000;
    color: white;
    border-color: #8b0000;
}

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* ===== Admin Gallery ===== */
.gallery-admin {
    max-width: 1200px;
}

.gallery-upload-section {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border: 1px solid #e5e5e5;
}

.upload-header h2 {
    margin: 0 0 0.25rem;
    font-size: 1.25rem;
}

/* Dropzone */
.gallery-dropzone {
    border: 2px dashed #ccc;
    border-radius: 12px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    transition: all 0.2s;
    margin-top: 1rem;
    background: #fafafa;
}

.gallery-dropzone.dragover {
    border-color: #8b0000;
    background: #fff5f5;
}

.dropzone-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.dropzone-text {
    font-size: 1.1rem;
    color: #333;
    margin: 0 0 0.25rem;
}

.dropzone-subtext {
    font-size: 0.85rem;
    color: #999;
    margin: 0 0 1rem;
}

/* Batch tag section */
.gallery-batch-tag {
    margin-top: 1.5rem;
}

.gallery-batch-tag h3 {
    font-size: 1rem;
    margin: 0 0 0.25rem;
}

/* Article tag selector */
.article-tag-selector {
    margin-bottom: 1rem;
}

.tag-search-wrapper {
    position: relative;
}

.tag-search-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.tag-search-input:focus {
    outline: none;
    border-color: #8b0000;
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.1);
}

.tag-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.tag-dropdown-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    border-bottom: 1px solid #f0f0f0;
}

.tag-dropdown-item:hover {
    background: #f5f5f5;
}

.tag-dropdown-item:last-child {
    border-bottom: none;
}

.tag-category {
    font-size: 0.75rem;
    color: #999;
}

.tag-dropdown-empty {
    padding: 0.75rem;
    color: #999;
    font-size: 0.85rem;
    text-align: center;
}

.selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: #e8f4f8;
    border: 1px solid #b8dae8;
    border-radius: 16px;
    font-size: 0.8rem;
    color: #1a5276;
}

.tag-remove {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 0;
    font-size: 1.1rem;
    line-height: 1;
}

.tag-remove:hover {
    color: #e53e3e;
}

/* Upload preview grid */
.upload-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}

.upload-preview-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #f5f5f5;
    padding: 0.5rem;
    text-align: center;
}

.upload-preview-item .preview-thumb {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
}

.upload-preview-item .preview-name {
    display: block;
    font-size: 0.7rem;
    color: #666;
    margin-top: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-remove {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.upload-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* Progress bar */
.progress-bar {
    height: 6px;
    background: #e5e5e5;
    border-radius: 3px;
    overflow: hidden;
    margin: 0.75rem 0 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #8b0000, #a00000);
    border-radius: 3px;
    transition: width 0.3s;
    width: 0%;
}

.progress-text {
    font-size: 0.85rem;
    color: #666;
    margin: 0;
}

/* ===== Bulk Actions Bar ===== */
.bulk-actions-bar {
    background: #1a1a1a;
    color: white;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    opacity: 0.4;
    transition: opacity 0.2s;
}

.bulk-actions-bar.active {
    opacity: 1;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.bulk-actions-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.bulk-select-all-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
}

.bulk-select-all-label input {
    cursor: pointer;
}

.bulk-count {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
}

.bulk-actions-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Admin gallery grid */
.gallery-grid-section {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid #e5e5e5;
}

.gallery-grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.gallery-grid-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.gallery-grid-header .count {
    color: #999;
    font-weight: normal;
    font-size: 0.9rem;
}

.gallery-filters select {
    padding: 0.4rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.85rem;
}

.gallery-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

.gallery-admin-card {
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #e5e5e5;
    transition: border-color 0.15s, box-shadow 0.15s;
    cursor: pointer;
}

.gallery-admin-card:hover {
    border-color: #bbb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.gallery-admin-card:has(.gallery-select-cb:checked) {
    border-color: #8b0000;
    box-shadow: 0 0 0 2px rgba(139, 0, 0, 0.2);
}

.gallery-card-image {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background: #f5f5f5;
}

.gallery-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Checkbox on card */
.gallery-card-checkbox {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 5;
    cursor: pointer;
}

.gallery-card-checkbox input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #8b0000;
}

.gallery-card-info {
    padding: 0.4rem 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem;
    min-height: 2rem;
}

.gallery-card-info .card-tags {
    font-size: 0.7rem;
    color: #666;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.gallery-card-info .card-tags-empty {
    color: #ccc;
    font-style: italic;
}

.card-actions {
    display: flex;
    gap: 0.15rem;
    flex-shrink: 0;
}

.card-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.15s;
    line-height: 1;
}

.card-action-btn:hover {
    background: #f0f0f0;
}

/* Admin modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid #eee;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Edit modal preview */
.edit-modal-preview {
    margin-bottom: 1rem;
    text-align: center;
}

.edit-preview-img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 6px;
    object-fit: contain;
}

/* ===== Article Editor Gallery Section ===== */
.article-gallery-dropzone {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    transition: all 0.2s;
    font-size: 0.85rem;
    color: #666;
    cursor: default;
}

.article-gallery-dropzone.dragover {
    border-color: #8b0000;
    background: #fff5f5;
}

.dropzone-mini-icon {
    font-size: 1.25rem;
    margin-right: 0.25rem;
}

.link-btn {
    background: none;
    border: none;
    color: #8b0000;
    cursor: pointer;
    text-decoration: underline;
    font-size: inherit;
    padding: 0;
}

.mini-gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.mini-gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    background: #f5f5f5;
}

.mini-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.mini-gallery-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.75rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.mini-gallery-item:hover .mini-gallery-remove {
    display: flex;
}

/* Staged (new, not yet uploaded) gallery items */
.mini-gallery-item--staged {
    border: 2px dashed #4caf50;
    background: #e8f5e9;
}

.mini-gallery-item--staged img {
    opacity: 0.85;
}

.staged-badge {
    position: absolute;
    bottom: 2px;
    left: 2px;
    background: #4caf50;
    color: white;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Removed (pending removal) gallery items */
.mini-gallery-item--removed {
    opacity: 0.4;
    border: 2px dashed #e53935;
}

.mini-gallery-item--removed img {
    filter: grayscale(1);
}

.mini-gallery-item--removed::after {
    content: 'Bus pašalinta';
    position: absolute;
    bottom: 2px;
    left: 2px;
    background: #e53935;
    color: white;
    font-size: 0.55rem;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
}

.mini-gallery-item--removed .mini-gallery-remove {
    display: flex;
    background: rgba(76, 175, 80, 0.8);
}

/* Pending changes summary */
.gallery-pending-summary {
    background: #fff3e0;
    border: 1px solid #ffcc80;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    line-height: 1.5;
    color: #e65100;
}

.gallery-pending-summary strong {
    display: block;
    margin-bottom: 0.15rem;
    color: #bf360c;
}

.progress-text {
    font-size: 0.75rem;
    color: #666;
    margin-top: 0.35rem;
    text-align: center;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.5rem;
    }

    .gallery-admin-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.5rem;
    }

    .bulk-actions-bar {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
    }

    .bulk-actions-right {
        flex-wrap: wrap;
    }

    .carousel-slide {
        width: 160px;
        height: 120px;
    }

    .lightbox-prev,
    .lightbox-next {
        font-size: 2rem;
        padding: 0.25rem 0.5rem;
    }

    .gallery-filter-tabs {
        gap: 0.35rem;
    }

    .filter-tab {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    .gallery-group-header {
        flex-direction: column;
        gap: 0.25rem;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .carousel-slide {
        width: 140px;
        height: 105px;
    }

    .carousel-btn {
        width: 28px;
        height: 28px;
        font-size: 1.2rem;
    }

    .mini-gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
