/* Menu Structure Popup Styles - Vertical Nav */

.menu-structure-popup {
    position: fixed;
    left: 50px;
    top: 50%;
    transform: translateY(-50%);
    width: 280px;
    max-width: 80vw;
    max-height: 60vh;
    background: rgba(33, 37, 41, 0.8);
    border: 1px solid rgba(108, 117, 125, 0.3);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    z-index: 10000;
    cursor: move;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.menu-structure-popup .popup-header {
    background: rgba(52, 58, 64, 0.9);
    color: #f8f9fa;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(108, 117, 125, 0.3);
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    flex-shrink: 0;
}

.menu-structure-popup .popup-title {
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    color: #f8f9fa;
}

.menu-structure-popup .popup-close {
    background: none;
    border: none;
    color: #adb5bd;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    touch-action: manipulation;
}

.menu-structure-popup .popup-close:hover {
    background-color: rgba(248, 249, 250, 0.15);
    color: #f8f9fa;
    transform: scale(1.1);
}

.menu-structure-popup .popup-close:active {
    background-color: rgba(248, 249, 250, 0.25);
    transform: scale(0.95);
}

.menu-structure-popup .popup-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #6c757d transparent;
}

/* Custom scrollbar for WebKit browsers */
.popup-content::-webkit-scrollbar {
    width: 6px;
}

.popup-content::-webkit-scrollbar-track {
    background: transparent;
}

.popup-content::-webkit-scrollbar-thumb {
    background-color: rgba(108, 117, 125, 0.6);
    border-radius: 3px;
}

.popup-content::-webkit-scrollbar-thumb:hover {
    background-color: rgba(173, 181, 189, 0.8);
}

/* Menu navigation styles */
.menu-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.menu-nav-item {
    border-bottom: 1px solid rgba(108, 117, 125, 0.3);
    transition: background-color 0.2s;
}

.menu-nav-item:hover {
    background-color: rgba(248, 249, 250, 0.1);
}

.menu-nav-item:last-child {
    border-bottom: none;
}

/* Menu Group Styles */
.menu-group-item {
    background-color: rgba(52, 58, 64, 0.5);
}

.menu-group-link {
    border-bottom: 1px solid rgba(108, 117, 125, 0.5);
    background-color: rgba(52, 58, 64, 0.3);
}

.menu-group-link:hover {
    background-color: rgba(52, 58, 64, 0.5);
}

.menu-group-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background-color: var(--thumbnail-highlight-color, #ffc107);
    color: #212529;
    border-radius: 4px;
    font-size: 14px;
    margin-right: 12px;
    flex-shrink: 0;
}

.menu-group-title {
    font-weight: 600;
    color: #ffc107;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.5px;
}

/* Scene Item Styles */
.scene-nav-item {
    padding-left: 12px;
}

.scene-nav-link {
    padding: 8px 16px;
}

.scene-nav-link[onclick] {
    cursor: pointer;
}

.scene-nav-link[onclick]:hover {
    background-color: rgba(13, 110, 253, 0.2);
    border-left: 3px solid #0d6efd;
}

.scene-thumbnail {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    overflow: hidden;
    margin-right: 12px;
    flex-shrink: 0;
    background-color: rgba(108, 117, 125, 0.3);
}

.scene-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.menu-nav-link {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    text-decoration: none;
    color: #f8f9fa;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.menu-nav-link:hover {
    color: #f8f9fa;
    text-decoration: none;
}

.menu-nav-content {
    flex: 1;
    min-width: 0;
}

.menu-nav-title {
    font-weight: 500;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #f8f9fa;
}

.menu-nav-subtitle {
    font-size: 0.75rem;
    color: #adb5bd;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.thumbnail-fallback {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(108, 117, 125, 0.5);
    color: #adb5bd;
    font-size: 16px;
}

/* Empty state */
.menu-nav-empty {
    padding: 40px 20px;
    text-align: center;
    color: #adb5bd;
}

.menu-nav-empty i {
    font-size: 2rem;
    margin-bottom: 12px;
    display: block;
    color: #6c757d;
}

/* Error state */
.menu-nav-error {
    padding: 40px 20px;
    text-align: center;
    color: #dc3545;
}

.menu-nav-error i {
    font-size: 2rem;
    margin-bottom: 12px;
    display: block;
}

.menu-nav-error .small {
    color: #adb5bd;
}

/* Loading state */
#menu-structure-loading {
    color: #6c757d;
}

#menu-structure-loading .spinner-border {
    width: 1.5rem;
    height: 1.5rem;
}

/* Responsive */
@media (max-width: 480px) {
    .menu-structure-popup {
        width: 80vw;
        max-width: 80vw;
        left: 10vw;
        margin: 0;
    }
    
    .menu-nav-scene.indented {
        margin-left: 15px;
    }
}

/* Additional mobile safety for very small screens */
@media (max-width: 320px) {
    .menu-structure-popup {
        width: 80vw;
        max-width: 80vw;
        left: 10vw;
        font-size: 0.85rem;
    }
    
    .menu-nav-title {
        font-size: 0.8rem;
    }
    
    .scene-thumbnail {
        width: 35px;
        height: 35px;
    }
    
    .menu-structure-popup .popup-close {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        font-size: 1.3rem;
    }
}

/* Bootstrap utility classes fallbacks */
.me-2 { margin-right: 0.5rem !important; }
.py-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-1 { margin-top: 0.25rem !important; }
.text-center { text-align: center !important; }
.small { font-size: 0.875em; }
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Spinner */
.spinner-border {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    vertical-align: -0.125em;
    border: 0.25em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spinner-border 0.75s linear infinite;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.2em;
}

@keyframes spinner-border {
    to { transform: rotate(360deg); }
}

/* Fullscreen Mode Styles */
.krpano-fullscreen-mode .menu-structure-popup {
    z-index: 2147483647 !important;
    position: fixed !important;
    /* Ensure popup is visible above fullscreen krpano */
}

.krpano-fullscreen-mode .grid-menu-overlay {
    z-index: 2147483647 !important;
    position: fixed !important;
    /* Ensure grid menu is visible above fullscreen krpano */
}

/* Additional fullscreen compatibility */
.krpano-fullscreen-mode .menu-structure-popup,
.krpano-fullscreen-mode .grid-menu-overlay {
    /* Force hardware acceleration for better performance */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Native fullscreen mode styles */
.krpano-fullscreen-mode {
    background: #000;
}

.krpano-fullscreen-mode #krpano-container,
.krpano-fullscreen-mode #pano {
    width: 100vw !important;
    height: 100vh !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 1 !important;
}

/* Tour Info Overlay Styles */
.tour-info-overlay {
    pointer-events: none; /* Allow clicks to pass through to krpano */
    transition: opacity 0.3s ease;
    z-index: 5000 !important; /* Above krpano but below popup menus */
}

/* Specific positioning for VR viewer vs Editor */
body:not(.editor-mode) .tour-info-overlay {
    position: fixed !important; /* vr.php uses fixed positioning */
}

.editor-mode .tour-info-overlay,
#krpano-container .tour-info-overlay {
    position: absolute !important; /* edittour.php uses absolute positioning relative to krpano container */
}

/* Force text colors for tour info overlay */
.tour-info-overlay .text-white,
.tour-info-overlay .card-title {
    color: #ffffff !important;
}

.tour-info-overlay .text-light,
.tour-info-overlay .card-text {
    color: #f8f9fa !important;
}

/* Ensure proper spacing and typography */
.tour-info-overlay {
    font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
}

.tour-info-overlay .card-body {
    padding: 0.25rem 1rem 1rem 1rem !important; /* Reduced top padding from 1rem to 0.75rem */
}

.tour-info-overlay .mb-2 {
    margin-bottom: 0.5rem !important;
}

.tour-info-overlay .mb-0 {
    margin-bottom: 0 !important;
}

/* Specific adjustments for vr.php vs editor.php */
body:not(.editor-mode) .tour-info-overlay .card-body {
    padding: 0.25rem 1rem 1rem 1rem !important; /* Less top padding for vr.php */
}

.editor-mode .tour-info-overlay .card-body {
    padding: 1rem !important; /* Standard padding for edittour.php */
}

.tour-info-overlay .card {
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    border-radius: 8px !important;
    pointer-events: auto; /* Re-enable pointer events on the card itself */
}

.tour-info-overlay .card-title {
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    font-size: 1.1rem;
}

.tour-info-overlay .card-text {
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    opacity: 0.9;
}

/* Fullscreen mode adjustments for tour info */
.krpano-fullscreen-mode .tour-info-overlay {
    position: fixed !important;
    z-index: 999999 !important;
}

/* Hide tour info overlay on very small screens */
@media (max-width: 576px) {
    .tour-info-overlay {
        display: none;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .tour-info-overlay {
        max-width: 280px !important;
    }
    
    .tour-info-overlay .card-title {
        font-size: 1rem;
    }
    
    .tour-info-overlay .card-text {
        font-size: 0.8rem;
    }
}