/* Gallery Page Specific Styles */

/* Gallery Section Layout */
.gallery-section {
    padding: 80px 0;
    padding-top: calc(80px + var(--header-height));
    background-color: var(--background-light);
}

.gallery-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 10px;
    width: 100%;
    box-sizing: border-box;
}

.gallery-header-section {
    padding: 3px 0;
    text-align: center;
    background-color: var(--secondary-color);
}

.gallery-header-section .section-subtitle {
    color: var(--primary-color);
    font-size: 1.4rem;
    margin-top: 5px;
}

.section-header {
    text-align: center;
    margin-top: 30px;
}

.section-header h1 {
    font-size: 36px;
    margin-bottom: 15px;
    color: var(--heading-color);
}

.section-header p {
    font-size: 18px;
    color: var(--primary-color);
}

/* Gallery Grid System */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    width: 100%;
}

/* Gallery Item Styling */
.gallery-item {
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.gallery-item:hover {
    transform: translateY(-5px);
}

.gallery-item.sortable-ghost {
    opacity: 0.5;
    background: #f0f0f0;
}

.gallery-item.sortable-chosen {
    cursor: grabbing;
}

.gallery-item.sortable-drag {
    opacity: 0.8;
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

/* Add a visual indicator for draggable items */
.gallery-item[draggable="true"]::after {
    content: '⋮⋮';
    position: absolute;
    top: 10px;
    right: 10px;
    color: #666;
    font-size: 20px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.gallery-item[draggable="true"]:hover::after {
    opacity: 1;
}

/* Ensure the add new item button stays at the end */
.gallery-item.add-new-item {
    cursor: pointer;
}

.gallery-item.add-new-item::after {
    display: none;
}

/* Admin controls styling */
.gallery-admin-controls {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding: 15px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
}

.gallery-admin-controls button {
    flex: 1;
    padding: 14px 18px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s ease;
    min-height: 52px;
    min-width: calc(50% - 6px); /* Make buttons wider, accounting for gap */
}

.edit-button {
    background-color: #4285f4;
    color: white;
}

.edit-button:hover {
    background-color: #3367d6;
}

.delete-button {
    background-color: #ea4335;
    color: white;
}

.delete-button:hover {
    background-color: #d33426;
}

.gallery-image {
    position: relative;
    width: 100%;
    padding-top: 75%; /* 4:3 aspect ratio */
    overflow: hidden;
}

.gallery-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-image img {
    transform: scale(1.05);
}

.gallery-info {
    padding: 15px;
    background: #fff;
    flex-grow: 1;
}

.gallery-info h3 {
    margin: 0 0 8px;
    font-size: 1.1rem;
    color: #333;
}

.gallery-info p {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

/* Overlay Effect - FIX: Make it non-interactive for mouse events */
.gallery-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;
    pointer-events: none; /* THIS FIXES THE SCROLLING ISSUE */
}

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

/* Lightbox Styles */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.lightbox.active {
    display: flex;
    opacity: 1;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 80vh;
    margin: auto;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    border: 2px solid white;
    transition: opacity 0.3s ease;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 40px;
    color: white;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 2100;
}

.lightbox-nav {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    box-sizing: border-box;
    pointer-events: none; /* This allows clicks to pass through */
}

.lightbox-nav button {
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    font-size: 30px;
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.3s;
    pointer-events: auto; /* Make only the buttons clickable */
}

.lightbox-nav button:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Responsive Adjustments */
@media (max-width: 992px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .gallery-section {
        padding: 60px 0;
        padding-top: calc(60px + var(--header-height));
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        grid-gap: 15px;
    }

    .section-header h1 {
        font-size: 30px;
    }

    .section-header p {
        font-size: 16px;
    }

    .lightbox-nav button {
        font-size: 24px;
        padding: 8px 12px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        grid-gap: 10px;
    }

    .gallery-info h3 {
        font-size: 18px;
    }

    .gallery-info p {
        font-size: 12px;
    }

    .lightbox-close {
        top: 10px;
        right: 10px;
        font-size: 30px;
    }
}

/* Mobile view for gallery overlay */
@media (max-width: 768px) {
    /* Show overlay text for mobile devices by default */
    .gallery-item .gallery-overlay {
        opacity: 1;
        background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.4) 30%, rgba(0,0,0,0) 60%);
        top: auto;
        height: 50%;
        bottom: 0;
        display: block;
        padding: 10px;
    }

    .gallery-item .gallery-info {
        position: absolute;
        bottom: 0;
        padding: 15px;
        text-align: right;
        width: 100%;
        background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.4) 60%, rgba(0,0,0,0) 100%);
        z-index: 2; /* Ensure text appears above admin controls */
    }

    .gallery-item .gallery-info h3 {
        font-size: 16px;
        margin-bottom: 5px;
        color: white;
    }

    .gallery-item .gallery-info p {
        font-size: 12px;
        display: block;
        margin: 0;
        color: rgba(255, 255, 255, 0.9);
    }

    /* Admin controls in mobile view - position below the image */
    .gallery-admin-controls {
        position: relative;
        display: flex;
        gap: 12px;
        margin-top: 0; /* Remove top margin */
        padding: 12px;
        background: white;
        width: 100%;
        box-sizing: border-box;
        border-top: 1px solid #eee;
        z-index: 1; /* Lower than text overlay */
    }

    .gallery-admin-controls button {
        flex: 1;
        padding: 14px 18px;
        font-size: 16px;
        min-height: 52px;
        border-radius: 8px;
        font-weight: 600;
        min-width: calc(50% - 6px); /* Make buttons wider, accounting for gap */
    }

    /* For admin items, ensure the image container has proper positioning */
    .gallery-item.admin-item {
        display: flex;
        flex-direction: column;
        background: white;
        border-radius: 8px;
        overflow: hidden;
    }

    .gallery-item.admin-item .gallery-image-container {
        position: relative;
        flex: 1;
        /* Ensure the image container maintains its aspect ratio */
        padding-top: 75%; /* 4:3 aspect ratio */
    }

    .gallery-item.admin-item .gallery-image {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }

    .gallery-item.admin-item .gallery-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* Ensure text stays on the image for admin items */
    .gallery-item.admin-item .gallery-info {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 15px;
        text-align: right;
        background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.4) 60%, rgba(0,0,0,0) 100%);
        z-index: 2;
    }

    /* Disable hover transform effect on mobile */
    .gallery-item:hover {
        transform: none;
    }

    .gallery-item:hover img {
        transform: none;
    }
}

/* For very small screens, reduce text size further */
@media (max-width: 480px) {
    .gallery-item .gallery-info h3 {
        font-size: 14px;
    }

    .gallery-item .gallery-info p {
        font-size: 11px;
    }

    .gallery-admin-controls button {
        padding: 14px 18px;
        font-size: 16px;
        min-height: 52px;
        border-radius: 8px;
        font-weight: 600;
    }
}

/* Lightbox caption styling */
.lightbox-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.5) 60%, rgba(0,0,0,0) 100%);
    color: white;
    padding: 20px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Show caption when lightbox is active */
.lightbox.active .lightbox-caption {
    opacity: 1;
}

.lightbox-caption h3 {
    font-size: 22px;
    margin-bottom: 8px;
    color: white;
}

.lightbox-caption p {
    font-size: 16px;
    margin: 0;
    color: rgba(255, 255, 255, 0.9);
}

/* Adjust for mobile */
@media (max-width: 768px) {
    .lightbox-caption {
        padding: 15px;
    }

    .lightbox-caption h3 {
        font-size: 18px;
        margin-bottom: 5px;
    }

    .lightbox-caption p {
        font-size: 14px;
    }
}

/* Additional adjustment for smaller screens */
@media (max-width: 480px) {
    .lightbox-content {
        max-width: 95%;
    }

    .lightbox-caption h3 {
        font-size: 16px;
    }

    .lightbox-caption p {
        font-size: 12px;
    }
}

/* Alert Messages */
.alert {
    padding: 15px;
    margin: 15px 0;
    border-radius: 4px;
    text-align: center;
}

.alert-success {
    background-color: #dff0d8;
    color: #3c763d;
    border: 1px solid #d6e9c6;
}

.alert-error {
    background-color: #f2dede;
    color: #a94442;
    border: 1px solid #ebccd1;
}

/* Delete Modal Styles */
.delete-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.delete-modal-content {
    background-color: white;
    padding: 25px;
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.delete-modal-content h2 {
    color: #dc3545;
    margin-bottom: 15px;
}

.delete-modal-content p {
    margin-bottom: 10px;
}

.delete-modal-content .warning {
    color: #dc3545;
    font-weight: bold;
    margin: 15px 0;
}

.delete-modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.delete-modal-buttons button {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.confirm-delete {
    background-color: #dc3545;
    color: white;
}

.confirm-delete:hover {
    background-color: #c82333;
}

.cancel-delete {
    background-color: #6c757d;
    color: white;
}

.cancel-delete:hover {
    background-color: #5a6268;
}

/* Upload Button in Gallery Item */
.add-new-item {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
    transition: all 0.3s ease;
    cursor: pointer;
}

.add-new-item:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

.add-new-item .upload-button {
    width: 100%;
    height: 100%;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: none;
    border: none;
    color: #6c757d;
    transition: all 0.3s ease;
}

.add-new-item .upload-button:hover {
    background: none;
    color: #495057;
}

.add-new-item .upload-button i {
    font-size: 2.5rem;
}

.add-new-item .upload-button span {
    font-size: 1.1rem;
}

/* Remove old upload button styles */
.gallery-admin-upload {
    display: none;
}

/* Upload Modal */
.upload-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
}

.upload-modal.active {
    display: block;
}

.upload-modal-content {
    background-color: #fff;
    margin: 2rem auto;
    padding: 2rem;
    border-radius: 8px;
    max-width: 600px;
    position: relative;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
}

.upload-modal h2 {
    margin-bottom: 1.5rem;
    color: #333;
    text-align: center;
    position: sticky;
    top: 0;
    background-color: #fff;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #555;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-group input[type="file"] {
    width: 100%;
    padding: 8px 0;
}

.image-preview {
    width: 100%;
    height: 200px;
    border: 2px dashed #ccc;
    border-radius: 8px;
    margin: 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f8f8;
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
}

.image-preview:hover {
    border-color: #666;
    background-color: #f0f0f0;
}

.preview-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.preview-container img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

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

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

.preview-overlay i {
    font-size: 2em;
    margin-bottom: 10px;
}

.form-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
    position: sticky;
    bottom: 0;
    background-color: #fff;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.submit-button,
.cancel-button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s ease;
}

.submit-button {
    background-color: #4CAF50;
    color: white;
}

.submit-button:hover {
    background-color: #45a049;
}

.cancel-button {
    background-color: #f44336;
    color: white;
}

.cancel-button:hover {
    background-color: #da190b;
}

/* Modal Styles */
.edit-modal,
.delete-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

/* When modal is active */
.edit-modal.active,
.delete-modal.active {
    display: flex;
}

.edit-modal-content,
.delete-modal-content {
    position: relative;
    background: white;
    padding: 25px;
    width: 90%;
    max-width: 500px;
    border-radius: 8px;
    margin: 20px;
}

.edit-modal input,
.edit-modal textarea {
    width: 100%;
    margin-bottom: 15px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.edit-modal textarea {
    height: 100px;
}

.edit-modal-buttons,
.delete-modal-buttons {
    text-align: left;
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

.edit-modal-buttons button,
.delete-modal-buttons button {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.edit-modal-buttons .save,
.delete-modal-buttons .confirm-delete {
    background: #4CAF50;
    color: white;
}

.edit-modal-buttons .cancel,
.delete-modal-buttons .cancel-delete {
    background: #f44336;
    color: white;
}

/* SweetAlert2 mobile responsiveness */
@media (max-width: 768px) {
    .swal2-popup {
        width: 90% !important;
        margin: 1rem auto !important;
        max-width: 350px !important;
    }

    .swal2-title {
        font-size: 1.2rem !important;
        padding: 0 10px !important;
    }

    .swal2-content {
        font-size: 0.9rem !important;
        padding: 0 10px !important;
    }

    .swal2-actions {
        padding: 0 10px 10px 10px !important;
    }

    .swal2-confirm,
    .swal2-cancel {
        font-size: 0.9rem !important;
        padding: 8px 16px !important;
    }
}

@media (max-width: 480px) {
    .swal2-popup {
        width: 95% !important;
        max-width: 300px !important;
        margin: 0.5rem auto !important;
    }

    .swal2-title {
        font-size: 1.1rem !important;
    }

    .swal2-content {
        font-size: 0.85rem !important;
    }
}

/* SweetAlert2 Form Styling */
.swal2-popup .form-group {
    margin-bottom: 15px;
    text-align: right;
}

.swal2-popup .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.swal2-popup .swal2-input {
    width: 100%;
    margin: 5px 0;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.swal2-popup .swal2-textarea {
    width: 100%;
    margin: 5px 0;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    min-height: 80px;
    resize: vertical;
    box-sizing: border-box;
    font-family: inherit;
}

.swal2-popup .swal2-input:focus,
.swal2-popup .swal2-textarea:focus {
    outline: none;
    border-color: #4285f4;
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
}