/* ===========================
   CSS VARIABLES & RESET
=========================== */

:root {
    /* Modal Colors */
    --modal-overlay: rgba(0, 0, 0, 0.9);
    --modal-overlay-alt: rgba(0, 0, 0, 0.95);
    --button-bg: rgba(0, 0, 0, 0.7);
    --button-bg-hover: rgba(0, 0, 0, 0.9);
    --button-bg-active: rgba(0, 0, 0, 0.8);
    --caption-bg: rgba(0, 0, 0, 0.6);
    --download-hover: rgba(79, 70, 229, 0.9);
    
    /* Modal Spacing */
    --modal-padding-desktop: 80px 20px 140px;
    --modal-padding-tablet: 60px 15px 120px;
    --modal-padding-mobile: 50px 10px 100px;
    
    /* Button Sizes */
    --btn-size-desktop: 50px;
    --btn-size-tablet: 45px;
    --btn-size-mobile: 42px;
    --btn-size-small: 36px;
    
    /* Modal Z-Index */
    --modal-z-index: 9999;
    --modal-controls-z-index: 10000;
    
    /* Border Radius */
    --modal-radius: 8px;
    --button-radius: 50%;
    --caption-radius: 25px;
    
    /* Panorama Dimensions */
    --panorama-width-desktop: 90vw;
    --panorama-height-desktop: 70vh;
    --panorama-max-width: 1200px;
    --panorama-max-height: 800px;
    --panorama-min-width: 300px;
    --panorama-min-height: 400px;
}

/* ===========================
   MAIN MODAL STRUCTURE
=========================== */

.gallery-modal {
    display: none;
    position: fixed;
    z-index: var(--modal-z-index);
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-overlay);
    backdrop-filter: blur(5px);
    transition: opacity 0.3s ease;
}

.gallery-modal.show {
    display: block;
    opacity: 1;
}

.gallery-modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.gallery-modal-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--modal-padding-desktop);
    overflow: hidden;
}

.gallery-modal-container img,
.gallery-modal-container video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--modal-radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* ===========================
   MODAL CONTROLS
=========================== */

.gallery-close {
    position: absolute;
    top: calc(20px + var(--navbar-height, 60px));
    right: 30px;
    color: white;
    font-weight: bold;
    cursor: pointer;
    z-index: var(--modal-controls-z-index);
    width: var(--btn-size-desktop);
    height: var(--btn-size-desktop);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--button-radius);
    background: var(--button-bg);
    transition: all 0.2s ease;
    border: none;
    line-height: 1;
}

.gallery-close svg {
    width: 35px;
    height: 35px;
    stroke: currentColor;
}

.gallery-close:hover,
.gallery-close:focus {
    background: var(--button-bg-hover);
    transform: scale(1.1);
}

/* ===========================
   GALLERY NAVIGATION
=========================== */

.gallery-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    z-index: var(--modal-controls-z-index);
}

.gallery-btn {
    background: var(--button-bg);
    border: none;
    color: white;
    width: var(--btn-size-desktop);
    height: var(--btn-size-desktop);
    border-radius: var(--button-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    font-size: 0;
}

.gallery-btn:hover,
.gallery-btn:focus {
    background: var(--button-bg-hover);
    transform: scale(1.1);
    outline: none;
}

.gallery-btn:active {
    transform: scale(0.95);
}

.gallery-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* Button-specific adjustments */
.gallery-prev svg {
    margin-right: 2px;
}

.gallery-next svg {
    margin-left: 2px;
}

.gallery-download:hover {
    background: var(--download-hover);
}

/* ===========================
   GALLERY INFO & CAPTIONS
=========================== */

.gallery-info {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    color: white;
    z-index: var(--modal-controls-z-index);
    max-width: 80%;
}

.gallery-caption {
    font-size: 16px;
    line-height: 1.5;
    background: var(--caption-bg);
    padding: 12px 24px;
    border-radius: var(--caption-radius);
    backdrop-filter: blur(10px);
    margin: 0;
    font-family: system-ui, -apple-system, sans-serif;
}

.gallery-caption:empty {
    display: none;
}

/* ===========================
   PANORAMA VIEWER
=========================== */

.panorama-scene-container {
    width: var(--panorama-width-desktop) !important;
    height: var(--panorama-height-desktop) !important;
    max-width: var(--panorama-max-width) !important;
    max-height: var(--panorama-max-height) !important;
    min-width: var(--panorama-min-width) !important;
    min-height: var(--panorama-min-height) !important;
    position: relative !important;
    background: #000;
    border-radius: var(--modal-radius);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.panorama-scene-container a-scene {
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    border-radius: var(--modal-radius);
    overflow: hidden;
}

/* ===========================
   LOADING & ERROR STATES
=========================== */

.panorama-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    z-index: 10;
    font-family: system-ui, -apple-system, sans-serif;
}

.panorama-loading p {
    margin: 15px 0 0 0;
    font-size: 16px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-left-color: #4f46e5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.panorama-error {
    color: #ff6b6b;
    text-align: center;
    font-family: system-ui, -apple-system, sans-serif;
}

.panorama-error svg {
    margin-bottom: 15px;
}

.panorama-error p {
    margin: 10px 0;
    font-size: 16px;
    font-weight: 600;
}

.panorama-error small {
    display: block;
    margin-top: 8px;
    font-size: 14px;
    opacity: 0.8;
}

/* ===========================
   ANIMATIONS
=========================== */

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ===========================
   ACCESSIBILITY
=========================== */

.gallery-btn:focus,
.gallery-close:focus {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .gallery-modal {
        background-color: var(--modal-overlay-alt);
    }
    
    .gallery-btn,
    .gallery-close {
        background: var(--button-bg-hover);
        border: 1px solid rgba(255, 255, 255, 0.3);
    }
    
    .gallery-caption {
        background: var(--button-bg-hover);
        border: 1px solid rgba(255, 255, 255, 0.3);
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .gallery-modal,
    .gallery-btn,
    .gallery-close,
    .loading-spinner {
        animation: none;
        transition: none;
    }
    
    .loading-spinner {
        border-left-color: #4f46e5;
        transform: none;
    }
}


