/* 360 Tour CSS Loader & Modal */
.project-tour-360-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 999999;
    display: flex;
    flex-direction: column;
}

body.tour-360-open .chat-fab,
body.tour-360-open .fb_dialog,
body.tour-360-open #zalo-chat-widget {
    display: none !important;
}

.tour-360-gallery-fallback {
    color: #080808;
    background: var(--secondary-color, #c5a97d);
    border: 1px solid var(--secondary-color, #c5a97d);
}

.tour-360-gallery-fallback:hover,
.tour-360-gallery-fallback:focus-visible {
    color: #080808;
    background: #d8c09b;
    border-color: #d8c09b;
}

.tour-360-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
}

.tour-360-content {
    position: relative;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

.tour-360-header {
    display: flex;
    justify-content: space-between;
    padding: 15px 20px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, transparent 100%);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 30;
    pointer-events: none; /* Let clicks pass through except on children */
}

.tour-360-header-actions {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 15px;
}

.tour-360-brand { max-width: 44%; padding: 3px 0; color: #f3eee5; }
.tour-360-brand strong { font-size: 19px; letter-spacing: .16em; }
.tour-360-brand strong span { color: #cfb787; font-size: 12px; }
.tour-360-brand h3 { margin: 5px 0 0; color: #ded9d0; font: 400 12px/1.5 'Be Vietnam Pro', sans-serif; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tour-360-tool { width: 44px; height: 44px; border: 1px solid #80786a; border-radius: 50%; background: #131817d9; color: #f3eee5; }
.project-tour-360-modal button:focus-visible, .project-tour-360-modal select:focus-visible { outline: 3px solid #e7c78c; outline-offset: 3px; }
.project-tour-360-modal button:disabled { opacity: .4; cursor: wait; }
.project-tour-360-modal [hidden] { display: none !important; }
.tour-360-gesture { position: absolute; bottom: 104px; left: 50%; transform: translateX(-50%); z-index: 4; margin: 0; padding: 8px 16px; border-radius: 20px; background: #131817bd; color: #eee8dc; font-size: 12px; text-align: center; width: max-content; max-width: 90%; pointer-events: none; }
.project-tour-360-modal:not([data-mode="view"]) .tour-360-room-navigation,
.project-tour-360-modal:not([data-mode="view"]) .tour-360-gesture { display: none; }
.project-tour-360-modal .pnlm-controls-container { top: 94px; }
.project-tour-360-modal .pnlm-panorama-info { display: none !important; }
.tour-360-viewer:focus { outline: none; }
.tour-360-library-card[aria-current="true"] { border: 2px solid #d5b87e; }
.project-tour-360-modal .tour-hotspot-label { visibility: hidden; position: absolute; bottom: 48px; left: 50%; transform: translateX(-50%); width: max-content; max-width: min(260px, 70vw); padding: 12px 16px; background: #17211ff2; color: #fff; border: 1px solid #c5a97d; border-radius: 8px; font: 400 13px/1.6 'Be Vietnam Pro', sans-serif; white-space: pre-line; overflow-wrap: anywhere; text-align: left; pointer-events: none; }
.project-tour-360-modal .pnlm-hotspot-base { width: 42px; height: 42px; border-radius: 50%; border: 2px solid #e6cc9e; background: #19221fd9 !important; }
.project-tour-360-modal .pnlm-hotspot-base::before { content: 'i'; display: grid; place-items: center; width: 100%; height: 100%; color: #f4dfb7; font: 600 22px/1 sans-serif; }
.project-tour-360-modal .pnlm-scene::before { content: '↑'; }
.project-tour-360-modal .pnlm-hotspot-base:hover .tour-hotspot-label,
.project-tour-360-modal .pnlm-hotspot-base:focus .tour-hotspot-label,
.project-tour-360-modal .pnlm-hotspot-base.is-expanded .tour-hotspot-label { visibility: visible; }

.btn-show-360-library {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 0 16px;
    color: #f3eee5;
    background: rgba(8,8,8,.72);
    border: 1px solid rgba(197,169,125,.68);
    cursor: pointer;
    font-size: 12px;
    letter-spacing: .1em;
    text-transform: uppercase;
}
.btn-show-360-library:hover,
.btn-show-360-library:focus-visible { color: #080808; background: #c5a97d; outline: none; }

.tour-360-selector {
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 5px 30px 5px 15px;
}

.btn-close-tour {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid white;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.2rem;
}

.btn-close-tour:hover, .btn-close-tour:focus {
    background: var(--secondary-color, #c5a97d);
    border-color: var(--secondary-color, #c5a97d);
    color: black;
    outline: none;
}

.tour-360-body {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
}

.tour-360-viewer {
    flex: 1;
    width: 100%;
    height: 100%;
    background: #111;
}

.tour-360-room-navigation {
    position: absolute;
    left: 50%;
    bottom: 24px;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 14px;
    transform: translateX(-50%);
}

.tour-360-room-navigation button {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .5);
    border-radius: 50%;
    color: #f3eee5;
    background: rgba(8, 8, 8, .76);
    backdrop-filter: blur(10px);
    transition: .25s ease;
}

.tour-360-room-navigation button:hover,
.tour-360-room-navigation button:focus-visible {
    color: #080808;
    background: #c5a97d;
    border-color: #c5a97d;
    outline: none;
}

.tour-360-room-navigation > div {
    min-width: 180px;
    padding: 10px 18px;
    text-align: center;
    color: #f3eee5;
    background: rgba(8, 8, 8, .76);
    border: 1px solid rgba(255, 255, 255, .2);
    backdrop-filter: blur(10px);
}

.tour-360-room-navigation span,
.tour-360-room-navigation small { display: block; }
.tour-360-room-navigation span { overflow: hidden; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.tour-360-room-navigation small { margin-top: 3px; color: #c5a97d; font-size: 10px; letter-spacing: .14em; }

.tour-360-library {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: none;
    flex-direction: column;
    padding: 82px clamp(24px, 5vw, 84px) 40px;
    overflow-y: auto;
    color: #f3eee5;
    background: linear-gradient(115deg, rgba(5,5,5,.98), rgba(13,13,12,.94));
}
.tour-360-library.is-visible { display: flex; }
.tour-360-library__header { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 24px; margin-bottom: 28px; }
.tour-360-library__header > div > span { color: #c5a97d; font-size: 11px; font-weight: 700; letter-spacing: .22em; }
.tour-360-library__header h4 {
    margin: 8px 0;
    color: #f3eee5;
    font-family: 'Be Vietnam Pro', 'Segoe UI', Arial, sans-serif;
    font-size: clamp(30px, 3.4vw, 50px);
    font-weight: 500;
    line-height: 1.15;
}
.tour-360-library__header h4,
.tour-360-library__header p,
.tour-360-library-card,
.tour-360-library-card__overlay,
.tour-360-library-card__overlay strong,
.tour-360-library-card__overlay > span {
    letter-spacing: normal;
    word-spacing: normal;
    font-kerning: normal;
    text-rendering: optimizeLegibility;
}
.tour-360-library__header p { margin: 0; color: #a9a49d; }
.tour-360-room-count { padding-bottom: 5px; color: #c5a97d; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }
.tour-360-library-group + .tour-360-library-group { margin-top: 34px; }
.tour-360-library-group > h5 { margin: 0 0 14px; color: #c5a97d; font-size: 13px; letter-spacing: .16em; text-transform: uppercase; }
.tour-360-library-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.tour-360-library-card { position: relative; height: clamp(190px, 25vh, 300px); padding: 0; overflow: hidden; text-align: left; background: #1a1917; border: 1px solid rgba(255,255,255,.12); cursor: pointer; }
.tour-360-library-card img { width: 100%; height: 100%; object-fit: cover; filter: saturate(.8) brightness(.78); transition: transform .5s ease, filter .35s ease; }
.tour-360-library-card__overlay { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; padding: 22px; color: #fff; background: linear-gradient(transparent 35%, rgba(0,0,0,.9)); }
.tour-360-library-card__overlay small { margin-bottom: 7px; color: #c5a97d; font-weight: 700; letter-spacing: .14em; }
.tour-360-library-card__overlay strong {
    font-family: 'Be Vietnam Pro', 'Segoe UI', Arial, sans-serif;
    font-size: clamp(20px, 1.65vw, 28px);
    font-weight: 500;
    line-height: 1.25;
}
.tour-360-library-card__overlay > span { margin-top: 16px; color: #c5a97d; font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.tour-360-library-card:hover img,
.tour-360-library-card:focus-visible img { transform: scale(1.045); filter: saturate(1) brightness(.92); }
.tour-360-library-card:focus-visible { outline: 2px solid #c5a97d; outline-offset: 2px; }
.tour-360-library-card.has-image-error img { visibility: hidden; }

/* Loading & Error States */
.tour-360-loading, .tour-360-error {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #000;
    z-index: 25; /* Errors must stay above the library, below the close button. */
}

/* Sidebar Drawer */
.tour-360-sidebar {
    width: 250px;
    background-color: rgba(18, 18, 18, 0.9);
    backdrop-filter: blur(10px);
    border-left: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 10;
}

.tour-360-sidebar-header {
    padding: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tour-360-scene-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.scene-item {
    display: flex;
    flex-direction: column;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 10px;
    background: rgba(255,255,255,0.05);
    transition: all 0.2s;
    border: 1px solid transparent;
}

.scene-item:hover, .scene-item:focus {
    background: rgba(255,255,255,0.1);
    outline: none;
}

.scene-item.active {
    border-color: var(--secondary-color, #c5a97d);
    background: rgba(197, 169, 125, 0.1);
}

.scene-thumb {
    width: 100%;
    height: 100px;
    background-color: #333;
    background-size: cover;
    background-position: center;
    border-radius: 4px;
    margin-bottom: 8px;
}

.scene-title {
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    word-break: break-word;
}

/* Custom Tooltip */
.pnlm-tooltip span {
    visibility: hidden;
    position: absolute;
    border-radius: 3px;
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    text-align: center;
    padding: 8px 12px;
    cursor: default;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 12px;
    white-space: pre-line;
    font-size: 14px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    z-index: 10;
    min-width: 150px;
    max-width: 300px;
    word-wrap: break-word;
}
.pnlm-tooltip:hover span, .pnlm-tooltip:focus span {
    visibility: visible;
}
.pnlm-tooltip span::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.8) transparent transparent transparent;
}

/* Custom Scene Hotspot text */
.pnlm-scene-tooltip {
    background: rgba(197, 169, 125, 0.9);
    color: #000;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 13px;
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Lock body scroll */
body.tour-360-open {
    overflow: hidden !important;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .tour-360-header { padding: max(12px, env(safe-area-inset-top)) 12px 20px; gap: 10px; flex-wrap: wrap; background: linear-gradient(#111c, transparent); }
    .tour-360-brand { max-width: 100%; width: 100%; }
    .tour-360-brand h3 { max-width: 85vw; }
    .tour-360-header-actions { gap: 8px; width: 100%; }
    .tour-360-header-actions .btn-close-tour { margin-left: auto; flex-shrink: 0; }
    .tour-360-selector { width: auto; min-width: 0; max-width: 32vw; }
    .tour-360-tool { flex-shrink: 0; }
    .project-tour-360-modal .pnlm-controls-container { top: 155px; }
    .tour-360-gesture { bottom: 106px; font-size: 12px; }
    .tour-360-body {
        flex-direction: column;
    }
    
    .tour-360-sidebar {
        width: 100%;
        height: auto;
        max-height: 40vh;
        border-left: none;
        border-top: 1px solid rgba(255,255,255,0.1);
        position: absolute;
        bottom: 0;
        transform: translateY(100%);
    }
    
    .tour-360-sidebar.show {
        transform: translateY(0);
    }
    
    .tour-360-scene-list {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 10px;
    }
    
    .scene-item {
        width: 120px;
        flex-shrink: 0;
        margin-bottom: 0;
    }
    
    .scene-thumb {
        height: 70px;
    }

    .btn-show-360-library { padding-inline: 10px; font-size: 11px; letter-spacing: 0; }
    .tour-360-library { padding: 150px 16px 28px; }
    .tour-360-library__header { grid-template-columns: 1fr; gap: 8px; }
    .tour-360-room-count { padding: 0; }
    .tour-360-library-grid { grid-template-columns: 1fr; }
    .tour-360-library-card { height: 230px; }
    .tour-360-room-navigation { bottom: 16px; gap: 8px; }
    .tour-360-room-navigation > div { min-width: 128px; max-width: 42vw; padding-inline: 10px; }
    .tour-360-room-navigation button { width: 44px; height: 44px; }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .btn-close-tour,
    .scene-item,
    .tour-360-sidebar,
    .gallery-item,
    .gallery-overlay,
    .gallery-item img {
        transition: none !important;
        transform: none !important;
        animation: none !important;
    }
}
