/* ============================================
   Ninh Phước 360 - Design System
   ============================================ */

:root {
    --primary: #d35656;
    --primary-hover: #d35656;
    --primary-glow: rgba(255, 0, 0, 0.2);
    --text-main: #cc3a3a;
    --text-muted: #666666;

    /* Glassmorphism White Theme */
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);

    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-pill: 30px;

    /* iOS Safe Area — fallback 0px for non-notch devices */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    background: #0a0f1e;
    color: var(--text-main);
}

/* ---- Loading Screen ---- */
#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(10, 15, 30, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease, visibility 0.8s ease;
    padding: 20px;
}

/* When intro is shown, reveal the panorama behind */
#loading-screen.show-intro {
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-content {
    text-align: center;
}

.loader-content h2 {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(90deg, #fff, var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 20px 0 8px;
}

.loader-content p {
    color: var(--text-muted);
    font-size: 14px;
}

.progress-bar-container {
    width: 250px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    margin: 0 auto 20px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), #ff7e7e);
    border-radius: 10px;
    transition: width 0.3s ease;
}

#loading-text-percent {
    font-weight: bold;
    color: var(--primary);
}

/* ---- Intro Card — White Theme ---- */
.intro-card {
    width: 100%;
    max-width: 680px;
    max-height: calc(100vh - 40px);
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 28px;
    text-align: center;
    animation: introSlideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    box-shadow:
        0 25px 80px rgba(0, 0, 0, 0.12),
        0 8px 32px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.intro-card.hidden {
    display: none;
}

@keyframes introSlideUp {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.94);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* --- Intro Header (Sticky top) --- */
.intro-header {
    padding: 36px 36px 0;
    flex-shrink: 0;
    animation: introFadeIn 0.6s ease 0.3s both;
}

@keyframes introFadeIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.intro-badge {
    display: inline-block;
    padding: 6px 18px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 2.5px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #e07650);
    border-radius: 20px;
    margin-bottom: 16px;
    box-shadow: 0 4px 14px rgba(211, 86, 86, 0.25);
}

.intro-title {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 40px;
    font-weight: 800;
    color: #1a1a2e;
    margin-bottom: 6px;
    line-height: 1.15;
    letter-spacing: -0.5px;
}

.intro-title span {
    background: linear-gradient(135deg, var(--primary), #e07650, #e8a040);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.intro-subtitle {
    font-size: 13px;
    color: #888;
    letter-spacing: 0.8px;
    font-weight: 500;
}

/* --- Intro Body (Scrollable middle) --- */
.intro-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 36px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
    animation: introFadeIn 0.6s ease 0.5s both;
}

.intro-body::-webkit-scrollbar {
    width: 4px;
}

.intro-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.intro-divider {
    width: 50px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), #e07650, #e8a040);
    border-radius: 3px;
    margin: 20px auto 22px;
}

.intro-desc {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 1.85;
    color: #555;
    margin-bottom: 16px;
    text-align: justify;
}

.intro-desc strong {
    color: #1a1a2e;
    font-weight: 700;
}


/* --- Eco Callout --- */
.intro-eco {
    position: relative;
    background: #f0f9f1;
    border: 1px solid #c8e6c9;
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 10px;
    text-align: left;
    color: #2e7d32;
    font-size: 13px;
    line-height: 1.7;
}

.intro-eco i {
    color: #43a047;
    margin-right: 6px;
    font-family: "Font Awesome 6 Free", "FontAwesome", sans-serif !important;
    font-weight: 900 !important;
}

.intro-eco strong {
    color: #1b5e20;
}

/* --- Intro Footer (Sticky bottom) --- */
.intro-footer {
    padding: 20px 36px 32px;
    flex-shrink: 0;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
    border-radius: 0 0 28px 28px;
    animation: introFadeIn 0.6s ease 0.7s both;
}

.intro-guide {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 22px;
}

.intro-guide-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 7px;
    flex: 1;
}

.intro-guide-item i {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #666;
    background: #f0f1f3;
    border: 1px solid #e0e2e6;
    border-radius: 12px;
    font-family: "Font Awesome 6 Free", "FontAwesome", sans-serif !important;
    font-weight: 900 !important;
    transition: all 0.3s ease;
}

.intro-guide-item:hover i {
    background: #fff;
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 18px rgba(211, 86, 86, 0.15);
}

.intro-guide-item span {
    font-size: 10.5px;
    color: #999;
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: 0.3px;
}

.btn-start-tour {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 15px 42px;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #ff6b6b, var(--primary), #c0392b);
    background-size: 200% 200%;
    border: none;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all 0.4s ease;
    box-shadow:
        0 6px 24px rgba(211, 86, 86, 0.3),
        0 0 0 0 rgba(211, 86, 86, 0.3);
    animation: btnPulse 2.5s ease-in-out infinite, btnGradient 4s ease infinite;
    letter-spacing: 0.5px;
}

@keyframes btnGradient {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

.btn-start-tour:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 10px 32px rgba(211, 86, 86, 0.4);
    animation: none;
}

.btn-start-tour:active {
    transform: scale(0.97);
}

.btn-start-tour i {
    font-size: 13px;
    font-family: "Font Awesome 6 Free", "FontAwesome", sans-serif !important;
    font-weight: 900 !important;
}

@keyframes btnPulse {

    0%,
    100% {
        box-shadow: 0 6px 24px rgba(211, 86, 86, 0.3), 0 0 0 0 rgba(211, 86, 86, 0.3);
    }

    50% {
        box-shadow: 0 6px 24px rgba(211, 86, 86, 0.3), 0 0 0 12px rgba(211, 86, 86, 0);
    }
}

/* Responsive: Intro Card on mobile */
@media (max-width: 520px) {
    .intro-card {
        border-radius: 20px;
        max-height: calc(100vh - 24px);
    }

    .intro-header {
        padding: 24px 20px 0;
    }

    .intro-title {
        font-size: 30px;
    }

    .intro-body {
        padding: 0 20px;
    }

    .intro-desc {
        font-size: 13px;
    }

    .intro-attractions {
        gap: 6px;
    }

    .attraction-chip {
        padding: 5px 10px;
        font-size: 11px;
    }

    .intro-footer {
        padding: 16px 20px 24px;
    }

    .intro-guide {
        gap: 16px;
    }

    .intro-guide-item i {
        width: 34px;
        height: 34px;
        font-size: 14px;
    }

    .intro-guide-item span {
        font-size: 9.5px;
    }

    .btn-start-tour {
        padding: 13px 32px;
        font-size: 15px;
    }
}

/* ---- KrPano Layer ---- */
#pano {
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* ---- UI Overlay ---- */
#ui-layer {
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
}

/* ---- Glass Panel Base ---- */
/*
   Performance note: backdrop-filter:blur() is extremely expensive
   when overlaid on KrPano 3D content (recalculated every frame).
   Using semi-transparent background instead for near-zero GPU cost.
*/
.glass-panel {
    pointer-events: auto;
    background: var(--glass-bg);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--glass-shadow);
}

/* ---- Logo (Top Right) ---- */
.logo-compact {
    position: absolute;
    top: calc(20px + var(--safe-top));
    right: calc(20px + var(--safe-right));
    padding: 10px 18px;
    display: inline-block;
    animation: fadeInDown 0.5s ease-out;
    text-align: right;
    pointer-events: none;
    /* Container doesn't block */
}

.logo-compact h1,
.logo-compact .subtitle,
.logo-compact .visitor-badge {
    pointer-events: auto;
    /* Text and badge remain interactive */
}

.logo-compact h1 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--primary);
    margin: 0;
}

.logo-compact .subtitle {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

/* ---- Desktop QR Code ---- */
#desktop-qr {
    position: absolute;
    bottom: 20px;
    left: 20px;
    padding: 10px;
    border-radius: 12px;
    display: none;
    text-align: center;
}

#desktop-qr img {
    width: 100px;
    height: 100px;
    border-radius: 8px;
}

#desktop-qr p {
    margin: 5px 0 0;
    font-size: 11px;
    color: var(--primary);
    font-weight: bold;
    font-family: Verdana, sans-serif;
}

/* ---- Map Overlay ---- */
#map-maximized-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1999;
}

/* ---- Unified Sidebar ---- */
.sidebar-wrapper {
    position: absolute;
    top: calc(20px + var(--safe-top));
    left: calc(20px + var(--safe-left));
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    z-index: 10;
    pointer-events: none;
    /* CRITICAL: Wrapper does NOT block the 360 scene */
}

.icon-btn-text {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-pill);
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    color: var(--primary);
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--glass-shadow);
    pointer-events: auto;
    /* Only button is interactive */
}

.icon-btn-text svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.icon-btn-text:hover,
.icon-btn-text.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 8px 20px var(--primary-glow);
}

.sidebar {
    width: 310px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: top left;
    background: var(--glass-bg);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    border: 1px solid var(--glass-border);
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
    pointer-events: auto;
    /* Content is interactive */
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: var(--primary);
    border-radius: 6px;
}

.sidebar.hidden {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
    pointer-events: none;
}

/* Accordion */
.tour-group {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 6px;
    margin-bottom: 6px;
}

.tour-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.tour-title {
    min-height: 42px;
    height: auto;
    border-radius: 14px;
    font-size: 13.5px;
    font-weight: 600;
    color: #1d1d1f;
    padding: 8px 10px 8px 38px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 4px;
    box-shadow: 0 0 20px rgba(0, 114, 255, 0.25);
}

.title-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0072ff;
    /* Icon color when inactive */
    font-size: 14px;
    transition: var(--transition);
}

.title-icon i {
    font-family: "Font Awesome 6 Free", "FontAwesome", sans-serif !important;
    font-weight: 900 !important;
}

.title-text {
    white-space: normal;
    word-break: break-word;
    line-height: 1.35;
    flex: 1;
}

/* Remove old arrow before adding new one if needed, but the ref has icons instead */
.tour-title::after {
    display: none;
    /* Hide default arrow to match clean Pano2VR look */
}

.tour-title:hover {
    background: linear-gradient(135deg, #00d2ff 0%, #00aaff 50%, #007fff 100%);
    color: #fff;
    transform: scale(1.02);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 114, 255, 0.3);
}

.tour-title:hover .title-icon {
    color: #fff;
}

/* Active State: More vibrant blue gradient */
.tour-group:not(.collapsed) .tour-title {
    background: linear-gradient(135deg, #00c6ff 0%, #0072ff 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 8px 20px rgba(0, 114, 255, 0.35);
}

.tour-group:not(.collapsed) .title-icon {
    color: #fff;
}

.tour-group:not(.collapsed) .tour-title:hover {
    background: linear-gradient(135deg, #00d2ff 0%, #00aaff 50%, #007fff 100%);
    transform: scale(1.02);
    box-shadow: 0 10px 25px rgba(0, 114, 255, 0.4);
}


.tour-scenes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    overflow: hidden;
    transition: max-height 0.3s ease;
    max-height: 1500px;
}

.tour-group.collapsed .tour-scenes {
    max-height: 0;
}

.sidebar-thumb {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    height: 70px;
    transition: var(--transition);
}

.sidebar-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s;
}

.sidebar-thumb:hover img {
    transform: scale(1.1);
}

.sidebar-thumb .thumb-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 16px 4px 4px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.sidebar-thumb.active {
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

/* ---- Icon Buttons ---- */
.icon-btn {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.8);
    color: var(--primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.icon-btn svg {
    fill: currentColor;
    width: 20px;
    height: 20px;
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 6px 15px var(--primary-glow);
}

.icon-btn.active {
    background: var(--primary);
    color: #fff;
}

/* ---- Nav Bar (Bottom Center - Always Visible & Exactly Centered) ---- */
.nav-bar {
    position: fixed;
    bottom: calc(20px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    margin: 0 auto;
    width: -moz-fit-content;
    width: fit-content;
    max-width: calc(100vw - 32px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    animation: navFadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
    z-index: 90;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
    pointer-events: auto;
}

@keyframes navFadeInUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.nav-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    opacity: 1;
    pointer-events: auto;
}

/* Fallback: Vô hiệu hóa class hidden nếu có gọi nhầm */
.nav-controls.hidden {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    max-width: none !important;
}

/* Responsive Navbar for Small Screens / Mobile */
@media (max-width: 600px) {
    .nav-bar {
        bottom: calc(12px + var(--safe-bottom));
        padding: 4px 8px;
    }

    .nav-controls {
        gap: 5px;
    }

    .nav-controls .icon-btn {
        width: 36px;
        height: 36px;
    }

    .nav-controls .icon-btn svg {
        width: 17px;
        height: 17px;
    }
}

.separator {
    width: 1px;
    height: 24px;
    background: rgba(0, 0, 0, 0.1);
    margin: 0 2px;
    flex-shrink: 0;
}

/* Old Thumbnails removed */

/* ---- Animations ---- */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    #ui-layer {
        padding: 12px;
    }

    /* Hide QR on all mobile orientations & small tablets */
    #desktop-qr {
        display: none !important;
    }

    /* Move logo to right */
    .logo-compact {
        top: calc(12px + var(--safe-top)) !important;
        right: calc(12px + var(--safe-right)) !important;
        left: auto !important;
        padding: 8px 14px;
        z-index: 5;
    }

    .logo-compact h1 {
        font-size: 13px;
    }

    .sidebar-wrapper {
        top: calc(12px + var(--safe-top)) !important;
        left: calc(12px + var(--safe-left)) !important;
    }

    .icon-btn-text {
        padding: 8px 12px;
        font-size: 13px;
    }

    /* Vertical Nav Bar (Bottom Right) */
    .nav-bar {
        bottom: calc(20px + var(--safe-bottom)) !important;
        right: calc(12px + var(--safe-right)) !important;
        left: auto !important;
        transform: none !important;
        flex-direction: column-reverse !important;
        padding: 8px 6px;
        gap: 6px;
        width: 46px !important;
        display: flex !important;
    }

    .nav-controls {
        flex-direction: column-reverse !important;
        max-width: none !important;
        max-height: 500px !important;
        gap: 6px;
        display: flex !important;
        transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    }

    .nav-controls.hidden {
        max-height: 0 !important;
        max-width: none !important;
        opacity: 0 !important;
    }

    /* Keep all buttons as requested */
    #btn-share,
    #btn-fullscreen {
        display: flex !important;
    }

    .icon-btn {
        width: 36px !important;
        height: 36px !important;
    }

    .separator {
        width: 20px;
        height: 1px;
        margin: 2px 0;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: calc(100vw - 24px);
        max-height: calc(100vh - 140px);
    }
}

/* ---- Info Modal ---- */
#info-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(10, 15, 30, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    pointer-events: auto;
}

#info-modal-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

#info-modal {
    position: relative;
    width: 100%;
    max-width: 750px;
    max-height: calc(100vh - 100px);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    transform: translateY(0) scale(1);
    opacity: 1;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    text-align: justify;
}

#info-modal-overlay.hidden #info-modal {
    transform: translateY(30px) scale(0.95);
    opacity: 0;
}

#btn-close-modal {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: #fff;
    border: 2px solid #fff;
    font-size: 24px;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

#btn-close-modal:hover {
    transform: scale(1.1) rotate(90deg);
    background: #e66666;
}

.modal-content-scroll {
    overflow-y: auto;
    padding-right: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.modal-content-scroll::-webkit-scrollbar {
    width: 6px;
}

.modal-content-scroll::-webkit-scrollbar-thumb {
    background-color: var(--primary);
    border-radius: 6px;
}

#modal-title {
    color: #1a1a1a;
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(211, 86, 86, 0.2);
}

#modal-body {
    color: #444;
    font-size: 15px;
    line-height: 1.6;
}

#modal-body h3 {
    color: var(--primary);
    font-size: 18px;
    margin: 20px 0 10px;
    font-weight: 700;
}

#modal-body p {
    margin-bottom: 12px;
}

#modal-body ul {
    margin-bottom: 15px;
    padding-left: 20px;
}

#modal-body li {
    margin-bottom: 8px;
}

#modal-body strong {
    color: #222;
}

/* ============================================================
   GOOGLE MAPS MINIMAP (White Glass & Red Accent Theme)
   ============================================================ */

/* 1. Màn che làm mờ khi phóng to bản đồ */
#map-maximized-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 30, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1050;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    opacity: 1;
    visibility: visible;
}

#map-maximized-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* 2. Khung Map Panel White Glassmorphism */
#map-panel {
    position: absolute;
    bottom: calc(20px + var(--safe-bottom));
    right: calc(20px + var(--safe-right));
    width: 290px;
    height: 250px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16), 0 2px 10px rgba(211, 86, 86, 0.1);
    transition: all 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
    pointer-events: auto;
}

/* Trạng thái thu gọn (Minimap Bar góc phải) */
#map-panel.collapsed {
    height: 48px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

#map-panel.collapsed #btn-toggle-map-panel {
    transform: rotate(180deg);
}

/* Trạng thái phóng to toàn màn hình */
#map-panel.maximized {
    position: fixed;
    width: min(85vw, 1050px);
    height: min(82vh, 780px);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    border-radius: 24px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.35);
}

/* Header */
#map-header {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
    cursor: pointer;
    user-select: none;
    gap: 8px;
    flex-shrink: 0;
    transition: var(--transition);
}

#map-header:hover {
    background: #ffffff;
}

.map-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 800;
    color: var(--primary);
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.map-header-icon {
    width: 18px;
    height: 18px;
    fill: var(--primary);
    flex-shrink: 0;
}

.map-header-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Switcher Lớp Bản Đồ */
.map-layer-switch {
    display: flex;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.04);
    border-radius: 8px;
    padding: 2px;
    gap: 2px;
    margin-right: 4px;
}

.map-layer-btn {
    background: transparent;
    border: none;
    color: #555555;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.map-layer-btn.active {
    background: var(--primary);
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(211, 86, 86, 0.35);
}

.map-action-btn {
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.05);
    color: #444444;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
}

.map-action-btn svg {
    width: 14px;
    height: 14px;
}

.map-action-btn:hover {
    color: var(--primary);
    background: rgba(211, 86, 86, 0.12);
    border-color: rgba(211, 86, 86, 0.25);
    transform: scale(1.05);
}

#map-container {
    flex: 1;
    width: 100%;
    height: 100%;
    background: #f1f5f9;
    z-index: 1;
}

/* 2. Điểm đánh dấu phát sáng Đỏ (Glowing Red Marker) */
.glowing-marker {
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    border: 2.5px solid #ffffff;
    position: relative;
    box-shadow: 0 0 12px rgba(211, 86, 86, 0.85);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.glowing-marker:hover {
    transform: scale(1.35);
}

.glowing-marker::before {
    content: '';
    position: absolute;
    inset: -10px;
    background: rgba(211, 86, 86, 0.45);
    border-radius: 50%;
    animation: pulse-marker 2s infinite ease-out;
    z-index: -1;
}

@keyframes pulse-marker {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }

    100% {
        transform: scale(2.6);
        opacity: 0;
    }
}

/* 3. Radar quét góc nhìn màu Đỏ Nho (Red Radar Cone) */
.map-radar {
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-top: 52px solid rgba(211, 86, 86, 0.42);
    /* Màu đỏ trong suốt */
    position: absolute;
    top: -52px;
    left: -20px;
    transform-origin: 50% 100%;
    pointer-events: none;
    z-index: 1000;
    filter: drop-shadow(0 0 6px rgba(211, 86, 86, 0.4));
}

.map-radar::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    width: 8px;
    height: 8px;
    background: #ffffff;
    border: 2px solid var(--primary);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* 4. Tooltip nhãn tên cảnh khi hover (White Glass) */
.custom-map-tooltip {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(211, 86, 86, 0.3) !important;
    border-radius: 8px !important;
    color: #1f2937 !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    padding: 5px 12px !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12) !important;
}

.custom-map-tooltip::before {
    border-top-color: rgba(255, 255, 255, 0.95) !important;
}

/* 5. Custom Popup Card (White Glass & Red) */
.leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.96) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255, 255, 255, 0.8) !important;
    border-radius: 14px !important;
    color: #1f2937 !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18), 0 2px 10px rgba(211, 86, 86, 0.1) !important;
    padding: 4px !important;
}

.leaflet-popup-tip {
    background: rgba(255, 255, 255, 0.96) !important;
}

.map-popup-card {
    padding: 6px 8px;
    text-align: center;
}

.map-popup-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
}

.map-popup-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 8px;
}

.btn-popup-teleport {
    background: var(--primary);
    color: #ffffff;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 4px 12px rgba(211, 86, 86, 0.3);
    transition: var(--transition);
}

.btn-popup-teleport:hover {
    background: #b73f3f;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(211, 86, 86, 0.4);
}

.btn-popup-directions {
    background: rgba(0, 0, 0, 0.05);
    color: #374151;
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: var(--transition);
}

.btn-popup-directions:hover {
    background: rgba(211, 86, 86, 0.1);
    color: var(--primary);
    border-color: rgba(211, 86, 86, 0.3);
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    #map-panel {
        width: 260px;
        height: 220px;
        bottom: calc(75px + var(--safe-bottom));
        right: calc(12px + var(--safe-right));
    }

    #map-panel.collapsed {
        height: 44px;
    }

    #map-panel.maximized {
        width: calc(100vw - 24px);
        height: calc(100vh - 120px);
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
}

/* ============================================
   Audio Control & Sound System Styles
   ============================================ */

/* --- Audio Button in Navbar --- */
.audio-btn-content {
    position: relative;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.audio-btn-content svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    transition: var(--transition);
}

.audio-btn-content svg.hidden {
    display: none;
}

/* Equalizer Bars on Audio Button */
.audio-eq-bars {
    position: absolute;
    bottom: -2px;
    right: -3px;
    display: flex;
    align-items: flex-end;
    gap: 1.5px;
    height: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.audio-eq-bars span {
    width: 2px;
    background: var(--primary);
    border-radius: 1px;
    height: 3px;
}

#btn-audio.playing .audio-eq-bars {
    opacity: 1;
}

#btn-audio.playing:hover .audio-eq-bars span {
    background: #fff;
}

#btn-audio.playing .audio-eq-bars span:nth-child(1) {
    animation: eqWave 0.8s ease-in-out infinite alternate;
}

#btn-audio.playing .audio-eq-bars span:nth-child(2) {
    animation: eqWave 1.1s ease-in-out 0.2s infinite alternate;
}

#btn-audio.playing .audio-eq-bars span:nth-child(3) {
    animation: eqWave 0.9s ease-in-out 0.4s infinite alternate;
}

@keyframes eqWave {
    0% { height: 2px; }
    50% { height: 9px; }
    100% { height: 4px; }
}

#btn-audio.muted {
    opacity: 0.75;
}

#btn-audio.muted .audio-eq-bars {
    display: none;
}

/* --- Audio Control Panel (Glassmorphism Popover) --- */
#audio-panel {
    position: fixed;
    bottom: calc(75px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(0);
    width: 340px;
    max-width: calc(100vw - 32px);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 20px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
    padding: 16px 18px;
    z-index: 100;
    transition: all 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
    color: #333;
}

#audio-panel.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(15px);
    pointer-events: none;
}

.audio-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.audio-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 700;
    color: #1a1a2e;
}

.audio-panel-title svg {
    color: var(--primary);
}

.audio-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    color: #888;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 50%;
    transition: var(--transition);
}

.audio-close-btn:hover {
    color: #000;
    background: rgba(0, 0, 0, 0.05);
}

.audio-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.audio-section-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.audio-label-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.audio-label {
    font-size: 13px;
    font-weight: 600;
    color: #222;
}

.audio-sublabel {
    font-size: 11px;
    color: #777;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

/* Modern iOS Style Switch */
.audio-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.audio-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.audio-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #d1d5db;
    transition: 0.3s;
    border-radius: 22px;
}

.audio-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.audio-switch input:checked + .audio-slider {
    background-color: var(--primary);
}

.audio-switch input:checked + .audio-slider:before {
    transform: translateX(18px);
}

/* Volume Slider Row */
.audio-volume-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.03);
    padding: 6px 10px;
    border-radius: 12px;
}

.vol-icon {
    width: 16px;
    height: 16px;
    fill: #666;
    flex-shrink: 0;
}

.audio-range {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: #e2e8f0;
    border-radius: 4px;
    outline: none;
}

.audio-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(211, 86, 86, 0.4);
    transition: transform 0.15s ease;
}

.audio-range::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.audio-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    border: none;
    cursor: pointer;
}

.vol-val {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    width: 28px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.audio-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.06);
    margin: 10px 0;
}

/* Voiceover Action Button */
.audio-voice-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.voice-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 12px;
    background: rgba(211, 86, 86, 0.08);
    border: 1px solid rgba(211, 86, 86, 0.2);
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}

.voice-action-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.voice-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.08);
    color: #888;
}

.voice-action-btn.playing {
    background: var(--primary);
    color: #fff;
}

/* ============================================
   Realtime Visitor Counter Badge & Popover
   ============================================ */

.visitor-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 6px;
    padding: 3px 11px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(211, 86, 86, 0.22);
    border-radius: 20px;
    font-size: 11px;
    color: #374151;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
    user-select: none;
    cursor: pointer;
}

.visitor-badge:hover {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(211, 86, 86, 0.45);
    box-shadow: 0 4px 14px rgba(211, 86, 86, 0.16);
    transform: translateY(-1px);
}

.visitor-badge:active {
    transform: translateY(0);
}

/* Green Live Indicator Pulse Animation */
.live-dot-wrapper {
    position: relative;
    width: 8px;
    height: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.live-dot {
    width: 6px;
    height: 6px;
    background-color: #10b981;
    border-radius: 50%;
    z-index: 2;
}

.live-pulse {
    position: absolute;
    width: 14px;
    height: 14px;
    background-color: rgba(16, 185, 129, 0.45);
    border-radius: 50%;
    animation: livePulseAnim 2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
    z-index: 1;
}

@keyframes livePulseAnim {
    0% { transform: scale(0.5); opacity: 0.95; }
    70% { transform: scale(2.2); opacity: 0; }
    100% { transform: scale(2.4); opacity: 0; }
}

.visitor-badge .stat-item {
    font-weight: 500;
    color: #4b5563;
    display: inline-flex;
    align-items: center;
    line-height: 1.2;
    white-space: nowrap;
}

.visitor-badge .stat-item strong {
    color: var(--primary);
    font-weight: 700;
    margin-right: 2px;
    font-variant-numeric: tabular-nums;
}

.visitor-badge .stat-icon {
    font-size: 10px;
    margin-right: 3px;
    opacity: 0.75;
    color: #4b5563;
}

.visitor-badge .stat-divider {
    color: #d1d5db;
    font-size: 10px;
    margin: 0 1px;
}

/* Visitor Detail Popover Card */
.visitor-popover {
    position: fixed;
    z-index: 9999;
    width: 250px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(211, 86, 86, 0.08);
    padding: 14px;
    color: #1f2937;
    animation: fadeInDown 0.25s ease-out;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.visitor-popover.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px);
}

.popover-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.popover-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #111827;
}

.popover-status {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
}

.status-live {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
}

.status-demo {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
}

.popover-body {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 10px;
}

.popover-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11.5px;
}

.row-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #4b5563;
}

.row-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.text-green {
    color: #10b981;
}

.text-primary {
    color: var(--primary);
}

.popover-footer {
    font-size: 10px;
    color: #9ca3af;
    text-align: center;
    padding-top: 8px;
    border-top: 1px dashed rgba(0, 0, 0, 0.08);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .visitor-badge {
        padding: 2px 8px;
        font-size: 10px;
        margin-top: 4px;
        gap: 5px;
    }

    .visitor-badge .stat-icon {
        font-size: 9px;
    }

    .visitor-popover {
        width: 230px;
        padding: 12px;
    }
}