/* Piwigo-Style Gallery Module */

.piwigo-gallery {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    width: 100%;
    padding: 20px;
    background: #fff;
    box-sizing: border-box;
}

/* Admin Bar */
.pw-admin-bar {
    margin-bottom: 20px;
    padding: 10px 15px;
    background: #343a40;
    border-radius: 6px;
}

.pw-admin-btn {
    display: inline-block;
    padding: 8px 16px;
    background: #28a745;
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
}

.pw-admin-btn:hover {
    background: #218838;
}

/* Breadcrumb */
.pw-breadcrumb {
    padding: 10px 0;
    font-size: 13px;
    color: #6c757d;
    margin-bottom: 20px;
}

.pw-breadcrumb-link {
    color: #0066cc;
    text-decoration: none;
}

.pw-breadcrumb-link:hover {
    text-decoration: underline;
}

.pw-breadcrumb-separator {
    color: #999;
    margin: 0 6px;
}

.pw-breadcrumb-current {
    color: #333;
}

/* Stats */
.pw-stats {
    margin-bottom: 20px;
    font-size: 15px;
    color: #6c757d;
}

.pw-total-count {
    background: #e9ecef;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 500;
}

/* Albums Grid - Piwigo Style */
.pw-albums-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 30px;
    justify-content: flex-start;
}

.pw-album-card {
    position: relative;
    width: 400px !important;
    height: 300px;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
    cursor: pointer;
}

.pw-album-card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    transform: translateY(-3px);
}

.pw-album-card a {
    text-decoration: none !important;
    color: inherit;
    display: block;
    width: 100%;
    height: 100%;
}

.pw-album-thumb {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #2c3e50;
}

.pw-album-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.pw-album-card:hover .pw-album-img {
    transform: scale(1.08);
}

.pw-item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,0.85) 100%);
    pointer-events: none;
}

.pw-item-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 12px;
    z-index: 2;
}

.pw-item-title {
    margin: 0 0 2px 0;
    
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pw-album-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,0.85) 100%);
    pointer-events: none;
}

.pw-album-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 12px;
    z-index: 2;
}

.pw-album-title {
    margin: 0 0 2px 0;
    font-size: 24px;
    font-weight: 600;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pw-album-count {
    font-size: 12px;
    color: #ff9500;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

/* Sub-Albums Section */
.pw-subalbums-title,
.pw-photos-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 20px 0 15px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
}

.pw-subalbums-grid {
    margin-bottom: 30px;
}

.pw-subalbum-card {
    width: 160px;
    height: 120px;
}

.pw-subalbum-card .pw-album-info {
    padding: 6px 8px;
}

.pw-subalbum-card .pw-album-name {
    font-size: 12px;
}

.pw-subalbum-card .pw-album-count {
    font-size: 10px;
}

/* Photos Toolbar */
.pw-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px 15px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    flex-wrap: wrap;
    gap: 12px;
}

.pw-search {
    display: flex;
    gap: 0;
}

.pw-search-input {
    padding: 8px 14px;
    border: 1px solid #ced4da;
    border-radius: 4px 0 0 4px;
    font-size: 14px;
    min-width: 200px;
    outline: none;
}

.pw-search-input:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.15);
}

.pw-search-btn {
    padding: 8px 14px;
    background: #007bff;
    color: #fff;
    border: 1px solid #007bff;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    font-size: 14px;
}

.pw-search-btn:hover {
    background: #0056b3;
}

.pw-sort-select {
    padding: 8px 14px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
}

/* Photos Grid - Justified Layout */
.pw-photos-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 30px;
}

.pw-photo-item {
    position: relative;
    overflow: hidden;
    aspect-ratio: 1;
    background: #e9ecef;
    border-radius: 4px;
    z-index: 0;
}

.pw-photo-item a {
    display: block;
    width: 100%;
    height: 100%;
}

.pw-photo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.pw-photo-item:hover .pw-photo-img {
    transform: scale(1.05);
    filter: brightness(0.9);
}

/* No Content */
.pw-no-content {
    text-align: center;
    padding: 60px 20px;
    background: #fff;
    border-radius: 8px;
    color: #6c757d;
    font-size: 16px;
}

/* Pagination */
.pw-pagination {
    margin-top: 25px;
    text-align: center;
}

.pw-pager {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    padding: 10px 15px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.pw-page-link {
    display: inline-block;
    padding: 6px 12px;
    color: #495057;
    text-decoration: none !important;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
}

.pw-page-link:hover {
    background: #e9ecef;
    color: #212529;
}

.pw-page-current {
    background: #007bff !important;
    color: #fff !important;
}

.pw-page-prev,
.pw-page-next {
    font-weight: 500;
}

.pw-page-ellipsis {
    padding: 6px 8px;
    color: #adb5bd;
}

/* Lightbox - Piwigo Style */
.pw-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pw-lightbox-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pw-lightbox-content {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    max-width: calc(100% - 200px);
    max-height: calc(100% - 120px);
}

.pw-lightbox-content img,
.pw-lightbox-content video {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    transition: opacity 0.3s ease;
}

.pw-lightbox-content audio {
    width: 400px;
    max-width: 90vw;
}

.pw-lightbox-close {
    position: fixed;
    top: 15px;
    right: 20px;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    font-size: 28px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.pw-lightbox-close:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.1);
}

/* Navigation with thumbnails - Piwigo style */
.pw-lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 5;
}

.pw-lightbox-nav-prev {
    left: 10px;
    flex-direction: row;
}

.pw-lightbox-nav-next {
    right: 10px;
    flex-direction: row;
}

.pw-nav-thumb-container {
    width: 60px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.3);
    transition: all 0.2s;
    opacity: 0.6;
}

.pw-lightbox-nav:hover .pw-nav-thumb-container {
    border-color: rgba(255,255,255,0.7);
    opacity: 1;
}

.pw-nav-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pw-lightbox-prev,
.pw-lightbox-next {
    background: rgba(0,0,0,0.5);
    border: none;
    color: #fff;
    font-size: 22px;
    width: 40px;
    height: 60px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pw-lightbox-nav-prev .pw-lightbox-prev {
    border-radius: 0 4px 4px 0;
    margin-left: -2px;
}

.pw-lightbox-nav-next .pw-lightbox-next {
    border-radius: 4px 0 0 4px;
    margin-right: -2px;
}

.pw-lightbox-prev:hover,
.pw-lightbox-next:hover {
    background: rgba(0,0,0,0.7);
}

/* Info panel with title, description, and counter */
.pw-lightbox-info {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    padding: 40px 20px 20px;
    text-align: center;
}

.pw-lightbox-title {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.pw-lightbox-description {
    color: rgba(255,255,255,0.8);
    font-size: 14px;
    margin: 0 0 10px 0;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.pw-lightbox-counter {
    color: rgba(255,255,255,0.6);
    font-size: 13px;
}

/* Video/Audio thumbnail overlays */
.pw-media-thumb {
    position: relative;
    width: 100%;
    height: 100%;
}

.pw-video-thumb .pw-play-icon,
.pw-audio-thumb .pw-audio-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    opacity: 0.9;
    pointer-events: none;
}

.pw-video-thumb .pw-play-icon {
    width: 50px;
    height: 50px;
    background: rgba(0,0,0,0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    padding-left: 4px;
}

.pw-audio-thumb .pw-audio-icon {
    width: 50px;
    height: 50px;
    background: rgba(102,51,153,0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

/* ================================================
   PHOTO DETAIL PAGE (Piwigo-style)
   ================================================ */
.pw-detail-view {
    background: #2a2a2a;
    border-radius: 8px;
    overflow: hidden;
}

/* Toolbar at top */
.pw-detail-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #333;
    border-bottom: 1px solid #444;
}

.pw-detail-toolbar-left,
.pw-detail-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pw-detail-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #444;
    border: none;
    border-radius: 4px;
    color: #ccc;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.pw-detail-tool-btn:hover {
    background: #555;
    color: #fff;
    text-decoration: none;
}

.pw-detail-nav-btn {
    background: #555;
}

.pw-detail-counter {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    padding: 0 10px;
}

.pw-detail-container {
    display: flex;
    gap: 0;
    min-height: 500px;
}

/* Main media area - left side */
.pw-detail-media {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
    padding: 20px;
}

.pw-detail-img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.4);
}

.pw-detail-video {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 4px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.4);
}

.pw-detail-audio-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 40px;
}

.pw-detail-audio-art {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.4);
}

.pw-detail-audio {
    width: 100%;
    max-width: 400px;
}

/* Info panel - right side */
.pw-detail-info {
    width: 280px;
    background: #404040;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Prev/Next thumbnail navigation */
.pw-detail-nav-thumbs {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.pw-detail-thumb-link {
    display: block;
    width: 70px;
    height: 70px;
    border-radius: 4px;
    overflow: hidden;
    border: 2px solid #555;
    transition: all 0.2s;
}

.pw-detail-thumb-link:hover {
    border-color: #fff;
    transform: scale(1.05);
}

.pw-detail-thumb-prev {
    position: relative;
}

.pw-detail-thumb-prev::before {
    content: '◄';
    position: absolute;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-size: 12px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    z-index: 1;
}

.pw-detail-thumb-next {
    position: relative;
}

.pw-detail-thumb-next::before {
    content: '►';
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-size: 12px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    z-index: 1;
}

.pw-detail-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Meta info fields */
.pw-detail-meta {
    flex: 1;
}

.pw-detail-title {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 20px 0;
    line-height: 1.3;
}

.pw-detail-field {
    margin-bottom: 15px;
}

.pw-detail-label {
    display: block;
    color: #999;
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.pw-detail-value {
    display: block;
    color: #fff;
    font-size: 14px;
}

.pw-detail-link {
    color: #f90;
    text-decoration: none;
}

.pw-detail-link:hover {
    color: #fb0;
    text-decoration: underline;
}

.pw-detail-date {
    color: #f90;
}

.pw-detail-desc {
    color: #ccc;
    font-size: 14px;
    line-height: 1.5;
    margin: 4px 0 0 0;
}

/* Responsive Design */
@media (max-width: 992px) {
    .pw-album-card {
        width: 180px;
        height: 135px;
    }
    .pw-photos-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    .piwigo-gallery {
        padding: 10px;
    }
    .pw-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .pw-search {
        width: 100%;
    }
    .pw-search-input {
        flex: 1;
        min-width: auto;
    }
    .pw-albums-grid {
        justify-content: center;
    }
    .pw-album-card {
        width: 160px;
        height: 120px;
    }
    .pw-album-title {
        font-size: 12px;
    }
    .pw-album-count {
        font-size: 11px;
    }
    .pw-photos-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }
    .pw-lightbox-prev,
    .pw-lightbox-next {
        width: 45px;
        height: 60px;
        font-size: 22px;
    }
    /* Detail page responsive */
    .pw-detail-container {
        flex-direction: column;
    }
    .pw-detail-info {
        width: 100%;
    }
    .pw-detail-nav-thumbs {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .pw-album-card {
        width: calc(50% - 8px);
        height: 100px;
    }
    .pw-photos-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .pw-detail-thumb-link {
        width: 55px;
        height: 55px;
    }
}
