/* 基础重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-blue: #0070C0;
    --primary-blue-light: #40a9ff;
    --primary-blue-dark: #005a9e;
    --accent-gold: #FFC000;
    --accent-gold-light: #FFD54F;
    --bg-white: #FFFFFF;
    --bg-gray: #F5F7FA;
    --text-dark: #1a1a1a;
    --text-gray: #666666;
    --text-light: #999999;
    --border-color: #E8E8E8;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.1);
}

html, body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

body {
    font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
    background-color: var(--bg-gray);
    color: var(--text-dark);
    display: flex;
    flex-direction: column;
}

/* 顶部标题栏 */
.header-bar {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-blue-dark) 100%);
    color: white;
    padding: 1vh 1vw;
    text-align: center;
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.header-bar h1 {
    font-size: clamp(14px, 1.8vh, 20px);
    font-weight: 600;
    margin-bottom: 0.3vh;
}

.header-bar .subtitle {
    font-size: clamp(9px, 1.1vh, 12px);
    opacity: 0.9;
}

/* 主容器 */
.main-container {
    display: flex;
    flex: 1;
    min-height: 0;
    width: 100%;
    padding: 0.8vh 0.8vw;
    gap: 0.8vw;
}

/* 左右两个区域共用卡片样式 */
.map-section,
.charts-section {
    background: var(--bg-white);
    border-radius: 0.8vh;
    box-shadow: var(--shadow);
    padding: 1vh 0.8vw;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.map-section {
    width: 50%;
    flex-shrink: 0;
}

.charts-section {
    flex: 1;
    min-width: 0;
}

/* ========== 左侧地图区域 ========== */

.map-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8vh;
    padding-bottom: 0.5vh;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 0.5vw;
    flex-shrink: 0;
}

.back-btn {
    display: none;
    padding: 0.5vh 0.6vw;
    background: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 0.4vh;
    cursor: pointer;
    font-size: clamp(10px, 1.2vh, 12px);
    transition: all 0.3s;
}

.back-btn:hover {
    background: var(--primary-blue-light);
}

.back-btn.visible {
    display: inline-block;
}

.map-toolbar-left {
    display: flex;
    gap: 0.5vw;
    align-items: center;
}

.map-chart-title {
    flex: 1;
    text-align: center;
    font-size: clamp(12px, 1.5vh, 15px);
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 0.5vw;
}

.map-carousel-toggle {
    display: flex;
    align-items: center;
    gap: 0.3vw;
    padding: 0.5vh 0.6vw;
    border: 1px solid var(--accent-gold);
    background: white;
    color: var(--accent-gold);
    font-size: clamp(10px, 1.2vh, 12px);
    cursor: pointer;
    border-radius: 0.4vh;
    transition: all 0.2s;
    font-weight: 500;
    flex-shrink: 0;
}

.map-carousel-toggle:hover {
    background: var(--accent-gold);
    color: white;
}

.map-carousel-toggle.active {
    background: var(--accent-gold);
    color: white;
}

.map-carousel-progress {
    display: none;
    text-align: center;
    font-size: clamp(10px, 1.2vh, 12px);
    color: var(--text-gray);
    padding: 0.5vh 0;
    margin-bottom: 0.5vh;
    background: var(--bg-gray);
    border-radius: 0.4vh;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.map-carousel-progress.visible {
    display: block;
}

.map-controls {
    display: flex;
    gap: 0.8vw;
    align-items: center;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.3vw;
}

.control-group label {
    font-size: clamp(10px, 1.2vh, 12px);
    color: var(--text-gray);
    font-weight: 500;
}

.control-group select {
    padding: 0.4vh 0.4vw;
    border: 1px solid var(--border-color);
    border-radius: 0.4vh;
    font-size: clamp(10px, 1.2vh, 12px);
    background: white;
    cursor: pointer;
    color: var(--text-dark);
}

.metric-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-gray);
    padding: 2px;
    border-radius: 0.4vh;
}

.metric-tab {
    padding: 0.4vh 0.5vw;
    border: none;
    background: transparent;
    color: var(--text-gray);
    font-size: clamp(10px, 1.2vh, 12px);
    cursor: pointer;
    border-radius: 0.3vh;
    transition: all 0.2s;
    font-weight: 500;
}

.metric-tab:hover {
    color: var(--primary-blue);
}

.metric-tab.active {
    background: var(--primary-blue);
    color: white;
}

/* 地图包装器 */
.map-wrapper {
    position: relative;
    flex: 2;
    min-height: 0;
    border-radius: 0.6vh;
    overflow: hidden;
    background: #FAFBFC;
    border: 1px solid var(--border-color);
}

#map-container {
    width: 100%;
    height: 100%;
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    font-size: clamp(12px, 1.5vh, 15px);
    color: var(--text-light);
    flex-direction: column;
    gap: 1vh;
}

.loading::after {
    content: '';
    width: 3vh;
    height: 3vh;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 统计面板 */
.stats-panel {
    position: absolute;
    right: 0.6vw;
    top: 1vh;
    background: rgba(255, 255, 255, 0.96);
    padding: 1vh 0.8vw;
    border-radius: 0.6vh;
    box-shadow: var(--shadow);
    min-width: 8vw;
    backdrop-filter: blur(4px);
    border: 1px solid var(--border-color);
    z-index: 10;
}

.stats-panel h3 {
    font-size: clamp(10px, 1.2vh, 12px);
    color: var(--text-dark);
    margin-bottom: 0.6vh;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.4vh;
}

.stats-item {
    display: flex;
    justify-content: space-between;
    padding: 0.4vh 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: clamp(9px, 1.1vh, 11px);
}

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

.stats-label {
    color: var(--text-gray);
}

.stats-value {
    color: var(--text-dark);
    font-weight: 500;
}

.stats-value.highlight {
    color: var(--primary-blue);
    font-weight: 600;
}

/* 地图图例覆盖层 */
.map-legend-overlay {
    position: absolute;
    right: 0.6vw;
    bottom: 1vh;
    background: rgba(255, 255, 255, 0.96);
    padding: 1vh 0.8vw;
    border-radius: 0.6vh;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    z-index: 10;
    max-width: 14vw;
}

.map-legend-overlay .legend-title {
    font-size: clamp(9px, 1.1vh, 11px);
    color: var(--text-dark);
    margin-bottom: 0.3vh;
    font-weight: 600;
}

.map-legend-overlay .legend-items {
    display: flex;
    gap: 0.6vw;
    align-items: center;
    flex-wrap: wrap;
}

.map-legend-overlay .legend-item {
    display: flex;
    align-items: center;
    gap: 0.3vw;
    font-size: clamp(8px, 1vh, 10px);
    color: var(--text-gray);
}

.legend-gradient {
    width: 4vw;
    height: 1vh;
    background: linear-gradient(to right, #0d47a1, #1976d2, #64b5f6, #bbdefb);
    border-radius: 0.2vh;
}

.legend-color.no-data {
    width: 1vh;
    height: 1vh;
    background: #d9d9d9;
    border-radius: 0.2vh;
}

/* 左侧下方 3 卡 */
.left-bottom-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6vw;
    margin-top: 0.8vh;
}

/* ========== 右侧图表区域 ========== */

.charts-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8vh;
    padding-bottom: 0.6vh;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.charts-toolbar-title {
    font-size: clamp(13px, 1.6vh, 16px);
    font-weight: 600;
    color: var(--text-dark);
}

.carousel-toggle {
    display: flex;
    align-items: center;
    gap: 0.3vw;
    padding: 0.6vh 0.8vw;
    border: 1px solid var(--accent-gold);
    background: white;
    color: var(--accent-gold);
    font-size: clamp(11px, 1.3vh, 13px);
    cursor: pointer;
    border-radius: 0.4vh;
    transition: all 0.2s;
    font-weight: 500;
    flex-shrink: 0;
}

.carousel-toggle:hover {
    background: var(--accent-gold);
    color: white;
}

.carousel-toggle.active {
    background: var(--accent-gold);
    color: white;
}

/* 右侧 4 卡 2×2 */
.charts-grid {
    display: grid;
    gap: 0.8vw;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.charts-grid.right-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
}

/* 维度卡片通用 */
.dimension-card {
    display: flex;
    flex-direction: column;
    padding: 1vh 0.6vw;
    border: 1px solid var(--border-color);
    border-radius: 0.6vh;
    background: #fafbfc;
    overflow: hidden;
    min-height: 0;
}

.dimension-card.small {
    padding: 0.6vh 0.4vw;
}

.dimension-card.small .card-header {
    margin-bottom: 0.3vh;
    padding-bottom: 0.3vh;
}

.dimension-card.small .card-title {
    font-size: clamp(10px, 1.3vh, 12px);
}

.dimension-card.small .card-chart-title {
    font-size: clamp(8px, 1.1vh, 10px);
}

.dimension-card.small .card-page {
    font-size: clamp(8px, 1.1vh, 10px);
    padding: 0.2vh 0.4vw;
}

.dimension-card.small .card-arrow {
    width: 2.2vh;
    height: 2.2vh;
    font-size: clamp(11px, 1.4vh, 13px);
}

.dimension-card.small .card-dots {
    margin-top: 0.3vh;
    gap: 0.3vw;
}

.dimension-card.small .card-dot {
    width: 0.6vh;
    height: 0.6vh;
}

.card-dot.active {
    width: 1.2vh;
    border-radius: 0.3vh;
}

.dimension-card.small .card-note {
    font-size: clamp(7px, 1vh, 9px);
    padding: 0.2vh 0.3vw;
    margin-top: 0.2vh;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.6vh;
    padding-bottom: 0.4vh;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    gap: 0.5vw;
}

.card-titles {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2vh;
}

.card-title {
    font-size: clamp(11px, 1.4vh, 13px);
    color: var(--text-dark);
    font-weight: 600;
    line-height: 1.3;
}

.card-chart-title {
    font-size: clamp(9px, 1.2vh, 11px);
    color: var(--text-gray);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-page {
    font-size: clamp(9px, 1.2vh, 11px);
    color: var(--text-gray);
    font-weight: 500;
    background: white;
    padding: 0.3vh 0.5vw;
    border-radius: 0.8vh;
    border: 1px solid var(--border-color);
    white-space: nowrap;
}

.card-gallery {
    flex: 1;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.card-arrow {
    position: absolute;
    top: 0.3vh;
    width: 2.5vh;
    height: 2.5vh;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-gray);
    font-size: clamp(12px, 1.5vh, 14px);
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 5;
}

.card-arrow-left {
    left: 0.3vh;
    bottom: 0.3vh;
    top: auto;
}

.card-arrow-right {
    right: 0.3vh;
    bottom: 0.3vh;
    top: auto;
}

.card-arrow:hover {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: white;
}

.card-chart-wrapper {
    position: absolute;
    inset: 0;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.card-chart-container {
    width: 100%;
    height: 100%;
}

.card-dots {
    display: flex;
    justify-content: center;
    gap: 0.4vw;
    margin-top: 0.5vh;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.card-dot {
    width: 0.7vh;
    height: 0.7vh;
    border-radius: 50%;
    background: #d1d5db;
    cursor: pointer;
    transition: all 0.2s;
}

.card-dot:hover {
    background: #9ca3af;
    transform: scale(1.2);
}

.card-dot.active {
    background: var(--primary-blue);
    width: 1.4vh;
    border-radius: 0.3vh;
}

.card-note {
    margin-top: 0.3vh;
    font-size: clamp(8px, 1.1vh, 10px);
    color: var(--text-light);
    line-height: 1.3;
    padding: 0.3vh 0.4vw;
    background: white;
    border-radius: 0.3vh;
    border-left: 2px solid var(--accent-gold);
    flex-shrink: 0;
    display: none;
}

.card-note.visible {
    display: block;
}

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

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

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ========== 响应式适配 ========== */
@media (max-width: 1400px) {
    .main-container {
        flex-direction: column;
    }
    
    .map-section {
        width: 100%;
        height: 55%;
    }
    
    .charts-section {
        height: 45%;
    }
    
    .charts-grid.right-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .map-section {
        height: 60%;
    }
    
    .charts-section {
        height: 40%;
    }
    
    .left-bottom-grid {
        grid-template-columns: 1fr;
    }
    
    .charts-grid.right-grid {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(4, 1fr);
    }
}
