.custom-gallery-widget .gallery-grid {
    display: grid;
    width: 100%;
}
/* Masonry Layout using CSS Columns for better browser support */
.gallery-grid.masonry-layout {
    display: block;
    column-fill: balance;
}
.gallery-grid.masonry-layout.masonry-columns-2 {
    column-count: 2;
}
.gallery-grid.masonry-layout.masonry-columns-3 {
    column-count: 3;
}
.gallery-grid.masonry-layout.masonry-columns-4 {
    column-count: 4;
}
.gallery-grid.masonry-layout.masonry-columns-5 {
    column-count: 5;
}
.gallery-grid.masonry-layout.masonry-columns-6 {
    column-count: 6;
}
/* Responsive masonry columns */
@media (max-width: 1024px) {
    .gallery-grid.masonry-layout.masonry-columns-4,
    .gallery-grid.masonry-layout.masonry-columns-5,
    .gallery-grid.masonry-layout.masonry-columns-6 {
        column-count: 3;
    }
}
@media (max-width: 768px) {
    .gallery-grid.masonry-layout.masonry-columns-3,
    .gallery-grid.masonry-layout.masonry-columns-4,
    .gallery-grid.masonry-layout.masonry-columns-5,
    .gallery-grid.masonry-layout.masonry-columns-6 {
        column-count: 2;
    }
}
@media (max-width: 480px) {
    .gallery-grid.masonry-layout {
        column-count: 1 !important;
    }
}
.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    display: inline-block;
    width: 100%;
}
.gallery-grid.masonry-layout .gallery-item {
    break-inside: avoid;
    page-break-inside: avoid;
}
.gallery-item img {
    width: 100%;
    height: auto;
    display: block;
}
.gallery-grid:not(.masonry-layout) .gallery-item img {
    height: 100%;
    object-fit: cover;
}
.overlay {
    position: absolute;
    bottom: 0;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    color: white;
    width: 100%;
    padding: 30px 15px 15px;
    text-align: center;
    opacity: 1;
}

.like-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    margin: 10px;
    color: #ccc;
}
.like-btn.liked { color: #e91e63; animation: pulse 0.4s; }

.comment-trigger {
    color: #fff;
    text-decoration: underline;
    font-size: 14px;
    cursor: pointer;
    transition: color 0.3s;
}
.comment-trigger:hover {
    color: #4CAF50;
}

/* Lightbox for Image View */
#gallery-lightbox {
    display: none;
    position: fixed;
    z-index: 9998;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.95);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 20px;
    text-align: center;
}
#gallery-lightbox.active { display: flex; }
#lightbox-img { max-width: 90%; max-height: 70vh; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.lightbox-close { 
    position: absolute; 
    top: 20px; 
    right: 35px; 
    font-size: 50px; 
    color: white; 
    cursor: pointer; 
    transition: transform 0.3s;
    z-index: 10000;
}
.lightbox-close:hover { transform: scale(1.2); }
#lightbox-caption { 
    margin-top: 20px; 
    color: white; 
    font-size: 18px; 
}

/* Comments Modal - Beautiful Popup */
#comments-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity 0.3s ease;
}
#comments-modal.active {
    display: flex;
    opacity: 1;
}
body.modal-open {
    overflow: hidden;
}
.comments-modal-container {
    background: #ffffff;
    border-radius: 20px;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
    overflow: hidden;
}
@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
.comments-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 20px 20px 0 0;
}
.comments-modal-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}
.comments-modal-image {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    object-fit: cover;
    border: 3px solid rgba(255,255,255,0.3);
}
.comments-modal-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}
.comments-modal-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 28px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    line-height: 1;
}
.comments-modal-close:hover {
    background: rgba(255,255,255,0.3);
    transform: rotate(90deg);
}
.comments-modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
}
#comments-list {
    margin-bottom: 30px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}
#comments-list::-webkit-scrollbar {
    width: 6px;
}
#comments-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}
#comments-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}
#comments-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}
.loading-comments {
    text-align: center;
    padding: 40px;
    color: #666;
}
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.no-comments {
    text-align: center;
    padding: 40px;
    color: #999;
    font-style: italic;
}
.error-message {
    text-align: center;
    padding: 20px;
    background: #fee;
    color: #c33;
    border-radius: 8px;
    margin-bottom: 20px;
}
.comment-message {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    animation: slideDown 0.3s ease;
}
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.comment-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.comment-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
.comment-item { 
    background: #f8f9fa; 
    padding: 20px; 
    margin-bottom: 15px; 
    border-radius: 12px;
    border-left: 4px solid #667eea;
    transition: transform 0.2s, box-shadow 0.2s;
}
.comment-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.comment-item strong { 
    display: block; 
    margin-bottom: 8px; 
    color: #333;
    font-size: 16px;
}
.comment-item p { 
    margin: 8px 0; 
    color: #555;
    line-height: 1.6;
}
.comment-item small { 
    color: #999; 
    font-size: 12px;
}
.comment-form-wrapper { 
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 25px; 
    border-radius: 12px;
    border: 1px solid #e0e0e0;
}
.comment-form-wrapper h4 { 
    margin: 0 0 20px 0;
    color: #333;
    font-size: 18px;
}
.comment-form-wrapper form { 
    margin-top: 0;
}
.comment-form-wrapper input[type="text"],
.comment-form-wrapper input[type="email"] { 
    width: 100%; 
    padding: 12px 15px; 
    margin-bottom: 15px; 
    border-radius: 8px; 
    border: 2px solid #e0e0e0;
    font-size: 14px;
    transition: border-color 0.3s;
    box-sizing: border-box;
}
.comment-form-wrapper input[type="text"]:focus,
.comment-form-wrapper input[type="email"]:focus {
    outline: none;
    border-color: #667eea;
}
.comment-form-wrapper textarea { 
    width: 100%; 
    padding: 12px 15px; 
    margin-bottom: 15px; 
    border-radius: 8px; 
    border: 2px solid #e0e0e0;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
    transition: border-color 0.3s;
    box-sizing: border-box;
}
.comment-form-wrapper textarea:focus {
    outline: none;
    border-color: #667eea;
}
.comment-form-wrapper button[type="submit"] { 
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white; 
    border: none; 
    padding: 12px 30px; 
    border-radius: 8px; 
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}
.comment-form-wrapper button[type="submit"]:hover { 
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}
.comment-form-wrapper button[type="submit"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1); }
}