/* AKGallery Styles */

.akgallery-wrapper {
    position: relative;
    margin: 20px 0;
    display: flex;
    align-items: center;
    gap: 20px;
}

.akgallery-container {
    flex: 1;
    overflow: hidden;
    border-radius: 8px;
}

.akgallery-track {
    width: 100%;
    overflow: hidden;
}

.akgallery-slider {
    display: flex;
    transition: transform 0.5s ease-in-out;
    width: 100%;
}

.akgallery-slide {
    flex: 0 0 auto;
    padding: 0 8px;
    box-sizing: border-box;
}

.akgallery-slide-inner {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: #f5f5f5;
}

.akgallery-slide-inner:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.akgallery-slide img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.akgallery-slide-inner:hover img {
    transform: scale(1.05);
}

.akgallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 20px 15px 15px;
    font-size: 14px;
    line-height: 1.4;
}

/* Navigation Arrows - Outside the carousel */
.akgallery-arrow {
    background: transparent;
    color: #ffb400;
    border: none;
    width: auto;
    height: auto;
    border-radius: 0;
    font-size: 70px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    z-index: 10;
    line-height: 1;
    padding: 0 20px;
}

.akgallery-arrow:hover {
    color: #e5a200;
    transform: scale(1.2);
}

.akgallery-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.akgallery-arrow:disabled:hover {
    color: #ffb400;
    transform: none;
}

/* Dots Navigation */
.akgallery-dots {
    text-align: center;
    margin-top: 20px;
}

.akgallery-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: none;
    background: #ccc;
    margin: 0 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.akgallery-dot:hover {
    background: #999;
    transform: scale(1.2);
}

.akgallery-dot.active {
    background: #333;
}

/* Modal Styles with Enhanced Z-index Management */
.akgallery-modal {
    position: fixed;
    z-index: 2147483647 !important; /* Maximum z-index value */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    /* Ensure modal stays on top */
    isolation: isolate;
}

.akgallery-modal.active {
    opacity: 1;
    visibility: visible;
    z-index: 2147483647 !important;
}

/* Create new stacking context for modal content */
.akgallery-modal-content {
    position: relative;
    margin: auto;
    max-width: 90%;
    max-height: 90%;
    top: 50%;
    transform: translateY(-50%);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2147483647;
}

.akgallery-modal-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    margin-bottom: 20px;
}

.akgallery-modal-caption {
    color: white;
    font-size: 18px;
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 8px;
    max-width: 80%;
    line-height: 1.4;
}

.akgallery-modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 60px;
    font-weight: bold;
    cursor: pointer;
    z-index: 2147483647;
    transition: color 0.3s ease, transform 0.2s ease;
    line-height: 1;
}

.akgallery-modal-close:hover {
    color: #ccc;
    transform: scale(1.1);
}

.akgallery-modal-prev,
.akgallery-modal-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    color: white;
    border: none;
    width: auto;
    height: auto;
    border-radius: 0;
    font-size: 80px;
    font-weight: bold;
    cursor: pointer;
    z-index: 2147483647;
    transition: all 0.3s ease;
    line-height: 1;
    padding: 0 30px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.akgallery-modal-prev:hover,
.akgallery-modal-next:hover {
    color: #ffb400;
    transform: translateY(-50%) scale(1.2);
}

.akgallery-modal-prev {
    left: 20px;
}

.akgallery-modal-next {
    right: 20px;
}

/* Prevent body scroll when modal is open */
body.akgallery-modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

/* Divi-specific fixes to prevent z-index conflicts */
.akgallery-modal.active ~ * {
    z-index: auto !important;
}

/* Force all Divi elements to stay below modal */
body.akgallery-modal-open .et_pb_section,
body.akgallery-modal-open .et_pb_row,
body.akgallery-modal-open .et_pb_column,
body.akgallery-modal-open .et_pb_module {
    z-index: auto !important;
    position: relative !important;
}

/* Additional insurance for Divi Builder elements */
body.akgallery-modal-open #et-main-area,
body.akgallery-modal-open #main-content,
body.akgallery-modal-open .et-l {
    z-index: 1 !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .akgallery-wrapper {
        gap: 10px;
    }
    
    .akgallery-arrow {
        font-size: 50px;
        padding: 0 10px;
    }
    
    .akgallery-slide img {
        height: 150px;
    }
    
    .akgallery-modal-prev,
    .akgallery-modal-next {
        font-size: 60px;
        padding: 0 20px;
    }
    
    .akgallery-modal-content {
        max-width: 95%;
    }
}

@media (max-width: 480px) {
    .akgallery-wrapper {
        flex-direction: column;
        gap: 15px;
    }
    
    .akgallery-arrow {
        order: 2;
    }
    
    .akgallery-prev {
        order: 1;
    }
    
    .akgallery-next {
        order: 3;
    }
    
    .akgallery-container {
        order: 2;
    }
    
    .akgallery-slide img {
        height: 200px;
    }
    
    .akgallery-caption {
        font-size: 12px;
        padding: 15px 10px 10px;
    }
    
    .akgallery-modal-prev {
        left: 10px;
    }
    
    .akgallery-modal-next {
        right: 10px;
    }
}

/* Loading Animation */
.akgallery-loading {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #333;
    border-radius: 50%;
    animation: akgallery-spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes akgallery-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Admin Styles */
.akgallery-image-placeholder {
    border: 2px dashed #ccc;
    background: #f9f9f9;
    height: 100px;
    width: 150px;
}