/**
 * Map360 Frontend Styles
 */

/* Wrapper */
.map360-wrapper {
    position: relative;
    overflow: hidden;
    background: #1a1a1a;
}

/* Viewer container */
.map360-viewer {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Scene layers (for crossfade transitions) */
.map360-scene-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Override Pannellum defaults */
.map360-viewer .pnlm-container {
    background: #1a1a1a;
}

/* ========================================
   Fade Transition Overlay
   ======================================== */

.map360-fade-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease-in-out;
    z-index: 100;
}

.map360-fade-overlay.active {
    opacity: 1;
}

/* ========================================
   Loading Indicator
   ======================================== */

.map360-viewer.map360-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: map360-spin 0.8s linear infinite;
    z-index: 1000;
}

@keyframes map360-spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   Hotspot Base Styles
   ======================================== */

.map360-viewer .pnlm-hotspot {
    cursor: pointer;
}

/* ========================================
   Hotspot Custom Styles
   ======================================== */

.map360-viewer .map360-hotspot {
    width: 26px !important;
    height: 26px !important;
    border-radius: 50% !important;
    cursor: pointer;
}

/* ========================================
   Hotspot Type Styles
   ======================================== */

/* Info hotspot - white with blue border */
.map360-viewer .map360-hotspot-info {
    background-color: rgba(255, 255, 255, 0.95) !important;
    border: 2px solid #0073aa !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Scene hotspot - blue with white border */
.map360-viewer .map360-hotspot-scene {
    background-color: rgba(0, 115, 170, 0.95) !important;
    border: 2px solid #fff !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Link hotspot - green with white border */
.map360-viewer .map360-hotspot-link {
    background-color: rgba(46, 204, 113, 0.95) !important;
    border: 2px solid #fff !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Custom icon hotspot */
.map360-viewer .map360-hotspot-custom-icon {
    background-color: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
}

.map360-viewer .map360-hotspot-custom-icon img {
    pointer-events: none;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

/* ========================================
   Hotspot Labels
   ======================================== */

.map360-hotspot-label {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    pointer-events: none;
    line-height: 1.3;
    z-index: 1;
}

.map360-label-above {
    bottom: 100%;
    margin-bottom: 6px;
}

.map360-label-below {
    top: 100%;
    margin-top: 6px;
}

/* ========================================
   Tooltip Styling
   ======================================== */

.map360-viewer div.pnlm-tooltip span {
    background-color: rgba(0, 0, 0, 0.85);
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 4px;
    white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.map360-viewer div.pnlm-tooltip:hover span:after {
    border-color: rgba(0, 0, 0, 0.85) transparent transparent transparent;
}

/* ========================================
   Pannellum Loading State
   ======================================== */

.map360-viewer .pnlm-load-box {
    background-color: rgba(0, 0, 0, 0.8);
}

/* ========================================
   Error Message
   ======================================== */

.map360-error {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    text-align: center;
}

/* ========================================
   Scene Title
   ======================================== */

.map360-show-title .pnlm-panorama-info {
    display: block;
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 8px 16px;
    color: #fff;
    z-index: 2;
    pointer-events: none;
}

.map360-show-title .pnlm-title-box {
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.02em;
    margin: 0;
    padding: 0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    .map360-wrapper {
        min-height: 300px;
    }

    /* Hide zoom controls on mobile */
    .map360-viewer .pnlm-zoom-controls {
        display: none;
    }
}

/* ========================================
   Fullscreen Mode
   ======================================== */

.map360-viewer:-webkit-full-screen .pnlm-container,
.map360-viewer:-moz-full-screen .pnlm-container,
.map360-viewer:-ms-fullscreen .pnlm-container,
.map360-viewer:fullscreen .pnlm-container {
    width: 100vw !important;
    height: 100vh !important;
}

/* Fullscreen wrapper */
.map360-wrapper:-webkit-full-screen,
.map360-wrapper:fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
}

.map360-wrapper:-webkit-full-screen .map360-viewer,
.map360-wrapper:fullscreen .map360-viewer {
    height: 100vh !important;
}

/* Mobile fullscreen button */
.map360-mobile-fullscreen {
    display: none;
}

@media (pointer: coarse) {
    /* Hide Pannellum's built-in fullscreen button on touch devices
       to avoid overlap with our mobile fullscreen button */
    .map360-viewer .pnlm-fullscreen-toggle-button,
    .map360-viewer .pnlm-fullscreen-toggle-button-inactive,
    .map360-viewer .pnlm-fullscreen-toggle-button-active {
        display: none !important;
    }

    .map360-mobile-fullscreen {
        display: flex;
        position: absolute;
        top: 8px;
        right: 8px;
        z-index: 20;
        width: 36px;
        height: 36px;
        align-items: center;
        justify-content: center;
        background: rgba(0, 0, 0, 0.5);
        color: #fff;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        transition: background 0.2s;
    }

    /* Explicit SVG sizing — HTML width/height attributes are unreliable on mobile */
    .map360-mobile-fullscreen svg,
    .map360-mobile-gyro svg {
        width: 20px !important;
        height: 20px !important;
        min-width: 20px;
        min-height: 20px;
        flex-shrink: 0;
    }

    .map360-mobile-fullscreen:active {
        background: rgba(0, 0, 0, 0.7);
    }

    .map360-mobile-fullscreen.active {
        background: rgba(59, 130, 246, 0.7);
    }

    /* Gyroscope button - positioned below fullscreen */
    .map360-mobile-gyro {
        display: flex;
        position: absolute;
        top: 52px;
        right: 8px;
        z-index: 20;
        width: 36px;
        height: 36px;
        align-items: center;
        justify-content: center;
        background: rgba(0, 0, 0, 0.5);
        color: #fff;
        border: none;
        border-radius: 6px;
        cursor: pointer;
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        transition: background 0.2s;
    }

    .map360-mobile-gyro:active {
        background: rgba(0, 0, 0, 0.7);
    }

    .map360-mobile-gyro.active {
        background: rgba(59, 130, 246, 0.7);
    }
}

/* CSS fullscreen fallback for iOS (no native Fullscreen API) */
.map360-fs-active {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important; /* iOS: accounts for address bar */
    z-index: 99999 !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #000 !important;
}

.map360-fs-active .map360-viewer {
    height: 100vh !important;
    height: 100dvh !important;
    width: 100% !important;
}

body.map360-fs-noscroll {
    overflow: hidden !important;
}
