@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', sans-serif;
    background: #0f172a;
    overflow: hidden;
}

.glass-panel {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.glow-text {
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

.map-container {
    position: relative;
    width: 100%;
    height: 100vh;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
}

.star-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image:
        radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255, 255, 255, 0.2), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255, 255, 255, 0.3), transparent),
        radial-gradient(2px 2px at 160px 120px, rgba(255, 255, 255, 0.2), transparent),
        radial-gradient(1px 1px at 230px 80px, rgba(255, 255, 255, 0.3), transparent);
    background-size: 250px 250px;
    animation: twinkle 5s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0f172a;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    transition: opacity 0.5s ease;
}

.loader {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.info-modal {
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -40%) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.screen-badge {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(147, 51, 234, 0.2));
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.status-dot {
    box-shadow: 0 0 8px currentColor;
}

.stat-card {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* ========== PC端样式（大于1024px） ========== */
@media (min-width: 1025px) {
    #sidebar {
        position: absolute;
        right: 24px;
        top: 96px;
        bottom: 96px;
        width: 320px;
        display: flex;
        flex-direction: column;
        opacity: 1;
        pointer-events: auto;
        transform: none;
        transition: transform 0.3s ease, opacity 0.3s ease;
        overflow: hidden;
        border-radius: 1rem;
        padding: 1.5rem;
    }

    #sidebar.sidebar-collapsed {
        transform: translateX(calc(100% + 24px));
        opacity: 0;
        pointer-events: none;
    }

    #toggle-btn-container {
        position: fixed;
        right: 24px;
        top: 60px;
        z-index: 50;
        transition: right 0.3s ease;
    }

    #toggle-btn-container.collapsed {
        right: 24px;
    }

    #bottom-bar {
        position: absolute;
        bottom: 24px;
        left: 24px;
        z-index: 10;
        transition: right 0.3s ease;
        width: auto;
        max-width: 300px;
        padding: 1rem;
    }

    #bottom-bar.sidebar-collapsed {
        right: 24px;
    }

    #bottom-bar:not(.sidebar-collapsed) {
        right: calc(320px + 48px);
    }
}

/* ========== 移动端样式（小于等于1024px） ========== */
@media (max-width: 1024px) {
    .map-container {
        height: 100vh;
        height: 100dvh;
    }
    
    .absolute.top-0.left-0.w-full.p-6 {
        padding: 1rem;
    }
    
    .absolute.top-0 h1 {
        font-size: 1.25rem;
        line-height: 1.4;
    }
    
    .absolute.top-0 p {
        font-size: 0.75rem;
    }
    
    /* 移动端侧边栏 - 增加高度以显示更多内容 */
    #sidebar {
        position: fixed;
        left: 0;
        right: 0;
        top: auto;
        bottom: 0;
        width: 100%;
        height: 65vh; /* 从45vh增加到65vh */
        max-height: 550px; /* 增加最大高度 */
        min-height: 400px; /* 增加最小高度 */
        border-radius: 1rem 1rem 0 0;
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
        z-index: 40;
        padding: 1.5rem 1rem 1rem;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
        display: flex;
        flex-direction: column;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-bottom: none;
        overflow: hidden;
    }
    
    #sidebar.sidebar-collapsed {
        transform: translateY(100%);
        opacity: 1;
        pointer-events: none;
    }
    
    /* 拖动指示条 */
    #sidebar::before {
        content: '';
        position: absolute;
        top: 0.5rem;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 2px;
    }
    
    /* 统计区域压缩一些空间 */
    #sidebar > div:first-child {
        flex-shrink: 0;
        margin-bottom: 1rem;
        padding-bottom: 0.75rem;
    }
    
    /* 标题区域 */
    #sidebar > div:nth-child(2) {
        flex-shrink: 0;
        margin-bottom: 0.75rem;
    }
    
    /* 列表区域 - 增大可用空间 */
    #location-list {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        min-height: 0;
        max-height: none;
        padding-right: 0.25rem;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 列表项样式 - 紧凑一点以显示更多 */
    #location-list > div {
        flex-shrink: 0;
        margin-bottom: 0.4rem;
        padding: 0.6rem 0.75rem;
    }
    
    #location-list > div:last-child {
        margin-bottom: 0;
    }
    
    /* 切换按钮 - 调整位置 */
    #toggle-btn-container {
        position: fixed;
        right: 1rem;
        top: auto;
        bottom: calc(65vh + 1rem); /* 跟随侧边栏高度 */
        z-index: 50;
        transition: bottom 0.3s ease;
    }
    
    #toggle-btn-container.collapsed {
        bottom: 1rem;
    }

    #toggle-btn {
        width: 40px;
        height: 40px;
        background: rgba(30, 41, 59, 0.9);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.3s ease;
        color: white;
    }

    #toggle-btn:hover {
        background: rgba(51, 65, 85, 0.9);
    }

    #toggle-icon {
        transition: transform 0.3s ease;
    }

    .sidebar-collapsed ~ #toggle-btn-container #toggle-icon,
    #toggle-btn-container.collapsed #toggle-icon {
        transform: rotate(180deg);
    }
    
    /* 底部状态栏 - 调整位置 */
    #bottom-bar {
        position: fixed;
        bottom: calc(65vh + 1rem); /* 跟随侧边栏高度 */
        left: 1rem;
        z-index: 10;
        transition: bottom 0.3s ease;
        padding: 0.75rem 1rem;
        width: auto;
        max-width: calc(100% - 6rem);
        display: block;
    }
    
    #bottom-bar.sidebar-collapsed {
        bottom: 1rem;
    }
    
    /* 弹窗调整 */
    #info-modal {
        width: 90vw;
        max-width: 400px;
        max-height: 70vh;
        padding: 1rem;
    }
    
    .info-modal {
        padding: 1.25rem;
    }
    
    #modal-mall-name {
        font-size: 1.125rem;
    }
    
    .grid.grid-cols-3 {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .stat-card {
        padding: 0.75rem 0.5rem;
    }
    
    .stat-card .text-lg {
        font-size: 1rem;
    }
}

/* ========== 小屏手机适配 ========== */
@media (max-width: 640px) {
    .absolute.top-0 h1 {
        font-size: 1.1rem;
    }
    
    #sidebar {
        height: 70vh; /* 小屏更高一些 */
        max-height: 500px;
        min-height: 350px;
    }
    
    #toggle-btn-container {
        bottom: calc(70vh + 0.75rem);
    }
    
    #bottom-bar {
        bottom: calc(70vh + 0.75rem);
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
        max-width: calc(100% - 5rem);
    }
    
    #location-list > div {
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.3rem;
    }
    
    #info-modal {
        width: 92vw;
        max-height: 75vh;
    }
    
    #modal-screen-locations {
        max-height: 150px;
    }
    
    .echarts-tooltip {
        font-size: 0.75rem !important;
    }
}

/* ========== 横屏模式 ========== */
@media (max-height: 500px) and (orientation: landscape) {
    #sidebar {
        height: 75vh;
        max-height: none;
    }
    
    #toggle-btn-container,
    #bottom-bar {
        bottom: calc(75vh + 0.5rem);
    }
}

/* ========== 触摸设备优化 ========== */
@media (pointer: coarse) {
    #toggle-btn {
        width: 44px;
        height: 44px;
    }
    
    #location-list > div {
        min-height: 50px;
    }
    
    .group:hover {
        background: transparent;
    }
    
    .group:active {
        background: rgba(51, 65, 85, 0.8);
    }
    
    button[onclick="closeModal()"] {
        padding: 0.5rem;
        top: 0.5rem;
        right: 0.5rem;
    }
}

/* ========== iOS优化 ========== */
@supports (-webkit-touch-callout: none) {
    body {
        position: fixed;
        width: 100%;
        height: 100%;
    }
    
    .map-container {
        height: 100%;
    }
}

/* ========== 滚动条美化 ========== */
#sidebar::-webkit-scrollbar {
    width: 4px;
}

#sidebar::-webkit-scrollbar-track {
    background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

#location-list::-webkit-scrollbar {
    width: 4px;
}

#location-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}