/* Gallery Styles */
.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Ensure gallery images always use square aspect ratio, overriding any club-specific styles */
.gallery-item .gallery-image-container {
    aspect-ratio: 1 !important;
    height: auto !important;
}

.gallery-item .gallery-image {
    height: 100% !important;
    width: 100% !important;
    aspect-ratio: 1 !important;
}

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

.gallery-image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 12px 12px 0 0;
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.3s ease;
    border-radius: 0;
}

.gallery-image:hover {
    transform: scale(1.08);
}

.gallery-image-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-image-overlay {
    opacity: 1;
}

/* Upload Modal Styles */
#imagePreviewContainer {
    max-height: 400px;
    overflow-y: auto;
}

.image-preview {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #e9ecef;
    background: #f8f9fa;
}

.image-preview img {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.image-preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-preview:hover .image-preview-overlay {
    opacity: 1;
}

.remove-preview-btn {
    background: rgba(220, 53, 69, 0.9);
    border: none;
    color: white;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.remove-preview-btn:hover {
    background: rgba(220, 53, 69, 1);
}

/* Alt Text Input */
.alt-text-input {
    margin-top: 8px;
}

.alt-text-input input {
    font-size: 0.875rem;
    border-radius: 4px;
}

/* Progress Bar */
.progress {
    height: 8px;
    border-radius: 4px;
    background-color: #e9ecef;
}

.progress-bar {
    background: linear-gradient(90deg, #007bff, #0056b3);
    transition: width 0.3s ease;
}

/* Image Modal Styles */
#modalImage {
    max-height: 80vh;
    width: auto;
    border-radius: 8px;
}

#imageNavigation {
    padding: 20px 0;
}

#imageCounter {
    font-weight: 500;
    color: #6c757d;
}

/* Delete Button Styles */
.delete-image-btn {
    background: rgba(220, 53, 69, 0.9);
    border: none;
    color: white;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.delete-image-btn:hover {
    background: rgba(220, 53, 69, 1);
    color: white;
    transform: scale(1.1);
}

.delete-image-btn:focus {
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25);
    outline: none;
}

/* Empty State */
.empty-gallery {
    padding: 60px 20px;
    text-align: center;
}

.empty-gallery i {
    color: #dee2e6;
}

.empty-gallery h3 {
    margin: 20px 0 10px;
    color: #6c757d;
}

.empty-gallery p {
    color: #adb5bd;
    max-width: 400px;
    margin: 0 auto 30px;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .gallery-image-container {
        aspect-ratio: 1;
    }
    
    .modal-dialog.modal-xl {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    #modalImage {
        max-height: 70vh;
    }
    
    .btn-group .btn {
        font-size: 0.875rem;
        padding: 8px 12px;
    }
}

@media (max-width: 576px) {
    .gallery-image-container {
        aspect-ratio: 1;
    }
    
    #modalImage {
        max-height: 60vh;
    }
    
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        margin-bottom: 8px;
        border-radius: 6px !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .gallery-item {
        background: var(--rugby-green);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
    
    .gallery-item:hover {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    }
    
    .image-preview {
        background: var(--rugby-green);
        border-color: var(--rugby-dark-green);
    }
    
    .empty-gallery i {
        color: var(--rugby-dark-green);
    }
    
    .empty-gallery h3 {
        color: #a0aec0;
    }
    
    .empty-gallery p {
        color: #718096;
    }
    
    #imageCounter {
        color: #a0aec0;
    }
}

/* Animation for new images */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gallery-item.new-upload {
    animation: fadeInUp 0.5s ease forwards;
}

/* Loading states */
.gallery-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #6c757d;
}

.gallery-loading i {
    margin-right: 8px;
}

/* Error states */
.upload-error {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.875rem;
}

.upload-success {
    background-color: #d1edff;
    border-color: #b6d7ff;
    color: #004085;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.875rem;
}
