/**
 * Map Drilldown Widget Styles
 * 地图下钻小部件样式
 *
 * @package Siwei_Custom_Widgets
 * @since 2.7.0
 */

/* ========================================
   基础布局
   ======================================== */

.siwei-map-drilldown-wrapper {
    width: 100%;
    background-color: #f4f7f9;
    border-radius: 8px;
    overflow: hidden;
}

.siwei-map-title {
    text-align: center;
    color: #333;
    margin: 20px 0;
    padding: 0 20px;
    font-size: 24px;
    font-weight: 600;
}

.siwei-map-layout {
    display: flex;
    width: 100%;
    height: 600px;  /* 固定高度 */
    background-color: #fff;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ========================================
   地图容器
   ======================================== */

.siwei-map-container {
    flex: 1;
    height: 100%;  /* 使用父容器的高度 */
    min-height: 400px;
    position: relative;
}

/* ========================================
   图例容器
   ======================================== */

.siwei-map-legend {
    width: 320px;
    height: 100%;  /* 使用父容器的高度 */
    overflow-y: auto;  /* 显示垂直滚动条 */
    border-left: 1px solid #e0e0e0;
    padding: 20px;
    box-sizing: border-box;
    background-color: #fff;
}

.siwei-map-legend::-webkit-scrollbar {
    width: 8px;
}

.siwei-map-legend::-webkit-scrollbar-track {
    background-color: #f5f5f5;
    border-radius: 4px;
}

.siwei-map-legend::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.siwei-map-legend::-webkit-scrollbar-thumb:hover {
    background-color: #999;
}

/* 图例标题 */
.legend-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #337ab7;
}

/* 图例项 */
.legend-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 6px;
    transition: all 0.3s ease;
    cursor: pointer;
    border-left: 3px solid transparent;
    background-color: #fafafa;
}

.legend-item:hover {
    background-color: #f0f8ff;
    border-left-color: #5470c6;
    transform: translateX(2px);
}

.legend-item.active {
    background-color: #e3f2fd;
    border-left-color: #5470c6;
}

/* 图例颜色标记 */
.legend-color-box {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-right: 12px;
    margin-top: 3px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.world-view .legend-color-box {
    border-radius: 4px;
}

/* 图例文字 */
.legend-text-wrapper {
    font-size: 14px;
    flex: 1;
}

.legend-text-wrapper strong {
    font-size: 16px;
    color: #333;
    display: block;
    margin-bottom: 4px;
}

.legend-text-wrapper small {
    color: #666;
    display: block;
    line-height: 1.6;
}

.legend-metrics {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #e0e0e0;
}

.legend-metric-item {
    color: #555;
    font-size: 13px;
    margin-top: 3px;
}

/* ========================================
   返回按钮（由 ECharts graphic 渲染，这里只是预留样式）
   ======================================== */

/* ========================================
   编辑器预览占位符
   ======================================== */

.legend-placeholder {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
    border: 2px dashed #ddd;
    border-radius: 6px;
}

/* ========================================
   响应式设计
   ======================================== */

/* 平板 */
@media (max-width: 1024px) {
    .siwei-map-legend {
        width: 280px;
        padding: 15px;
    }

    .siwei-map-title {
        font-size: 22px;
    }

    .legend-title {
        font-size: 16px;
    }

    .legend-item {
        padding: 10px;
    }
}

/* 手机 */
@media (max-width: 768px) {
    .siwei-map-layout {
        flex-direction: column;
    }

    .siwei-map-container {
        width: 100%;
        height: 400px;
        min-height: auto;
    }

    .siwei-map-legend {
        width: 100%;
        max-height: 300px;
        border-left: none;
        border-top: 1px solid #e0e0e0;
        padding: 15px;
    }

    .siwei-map-title {
        font-size: 20px;
        margin: 15px 0;
    }

    .legend-title {
        font-size: 16px;
        margin-bottom: 10px;
    }

    .legend-item {
        padding: 10px;
        margin-bottom: 10px;
    }

    .legend-text-wrapper {
        font-size: 13px;
    }

    .legend-text-wrapper strong {
        font-size: 15px;
    }

    .legend-color-box {
        width: 16px;
        height: 16px;
        margin-right: 10px;
    }
}

/* 小手机 */
@media (max-width: 480px) {
    .siwei-map-container {
        height: 300px;
    }

    .siwei-map-legend {
        max-height: 250px;
        padding: 12px;
    }

    .siwei-map-title {
        font-size: 18px;
        margin: 12px 0;
    }

    .legend-title {
        font-size: 15px;
    }

    .legend-item {
        padding: 8px;
        margin-bottom: 8px;
    }

    .legend-text-wrapper {
        font-size: 12px;
    }

    .legend-text-wrapper strong {
        font-size: 14px;
    }

    .legend-metric-item {
        font-size: 12px;
    }
}

/* ========================================
   无障碍支持
   ======================================== */

.legend-item:focus-visible {
    outline: 2px solid #337ab7;
    outline-offset: 2px;
}

/* ========================================
   打印样式
   ======================================== */

@media print {
    .siwei-map-drilldown-wrapper {
        background-color: #fff;
    }

    .siwei-map-layout {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .legend-item {
        page-break-inside: avoid;
    }
}

/* ========================================
   加载状态
   ======================================== */

.siwei-map-container.loading::before {
    content: '地图加载中...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    font-size: 16px;
    z-index: 10;
}

.siwei-map-container.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: 30px;
    margin-left: -20px;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top-color: #337ab7;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}
