/**
 * 统一样式文件 - 基于预测对比页面的设计风格
 */

/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2196F3;
    --success-color: #4CAF50;
    --warning-color: #FF9800;
    --danger-color: #F44336;
    --bg-color: #f9f9f9;
    --card-radius: 8px;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 18px rgba(33, 150, 243, 0.08);
}

body, html {
    margin: 0;
    padding: 0;
    background: var(--bg-color);
    font-family: 'Segoe UI', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 8px;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    text-decoration: underline;
    color: #0b7dda;
}

/* 页眉样式 */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 20px;
    border-radius: var(--card-radius) var(--card-radius) 0 0;
    margin-bottom: 20px;
}

header h1 {
    margin: 0;
    font-size: 1.8rem;
    color: white;
    border-bottom: none;
    padding-bottom: 0;
    letter-spacing: 0.5px;
}

nav {
    margin-top: 15px;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 20px;
    padding: 0;
}

nav a {
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

nav a:hover {
    background-color: rgba(255, 255, 255, 0.2);
    text-decoration: none;
}

nav a.active {
    background-color: rgba(255, 255, 255, 0.3);
    font-weight: bold;
}

/* 主内容区域 */
main {
    background-color: white;
    padding: 20px;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

section {
    margin-bottom: 30px;
}

/* 页脚样式 */
footer {
    margin-top: 20px;
    text-align: center;
    color: #666;
    font-size: 0.9rem;
    padding: 20px;
}

/* 模块样式 */
.module {
    background: white;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    padding: 24px 18px;
    margin-bottom: 28px;
    transition: box-shadow 0.2s;
}

.module:hover {
    box-shadow: var(--shadow-hover);
}

.module-title {
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.module-title h2 {
    margin: 0;
    color: #333;
    font-size: 1.5rem;
}

/* 标签切换 */
.module-switch {
    display: flex;
    margin: 20px 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.module-switch button {
    background: #f0f0f0;
    border: none;
    padding: 10px 20px;
    margin-right: 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.module-switch button.active {
    background: var(--success-color);
    color: white;
}

.module-switch button:hover:not(.active) {
    background: #e0e0e0;
}

.tab-content {
    display: none;
    padding: 20px 0;
}

.tab-content.active {
    display: block;
}

/* 按钮样式 */
button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    margin: 5px;
    transition: background-color 0.3s, box-shadow 0.2s;
    box-shadow: 0 1px 3px rgba(33, 150, 243, 0.08);
}

button:hover {
    background-color: #0b7dda;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.12);
}

button.active {
    background-color: var(--success-color);
    font-weight: bold;
}

button.secondary {
    background-color: #6c757d;
}

button.secondary:hover {
    background-color: #5a6268;
}

button.success {
    background-color: var(--success-color);
}

button.success:hover {
    background-color: #388e3c;
}

button.warning {
    background-color: var(--warning-color);
}

button.warning:hover {
    background-color: #e68a00;
}

button.danger {
    background-color: var(--danger-color);
}

button.danger:hover {
    background-color: #d32f2f;
}

.button-container {
    margin: 20px 0;
    display: flex;
    flex-wrap: wrap;
}

/* 图表容器 */
.chart-container {
    width: 100%;
    height: 400px;
    margin: 20px 0;
    position: relative;
    background-color: white;
    border-radius: var(--card-radius);
    padding: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* 信息容器 */
.info-container {
    margin: 20px 0;
    padding: 15px;
    background: #f9f9f9;
    border-radius: var(--card-radius);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* 表单样式 */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

input, select, .search-input, .date-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    transition: border 0.2s;
}

input:focus, select:focus, .search-input:focus, .date-input:focus {
    border: 1.5px solid var(--primary-color);
    outline: none;
}

.form-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

/* 统计卡片 */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.stat-card {
    background-color: white;
    border-radius: var(--card-radius);
    padding: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.stat-card h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 16px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-unit {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

.stat-card.prediction .stat-value {
    color: var(--success-color);
}

.stat-card.actual .stat-value {
    color: var(--danger-color);
}

.stat-card.error .stat-value {
    color: var(--warning-color);
}

/* 地图相关样式 */
.map-container {
    margin: 20px 0;
    position: relative;
    width: 100%;
    height: 400px;
}

#map {
    width: 100%;
    height: 400px;
    border-radius: var(--card-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

#map img,
#map canvas {
    max-width: none !important;
    max-height: none !important;
}

.weather-location-marker {
    position: relative;
    width: 24px;
    height: 34px;
    pointer-events: auto;
}

.weather-location-pin {
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 20px;
    height: 20px;
    border: 3px solid #fff;
    border-radius: 50% 50% 50% 0;
    background: #2196F3;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.28);
    transform: translateX(-50%) rotate(-45deg);
}

.weather-location-pin::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    transform: translate(-50%, -50%);
}

.weather-location-pin.is-default {
    background: #16a34a;
}

.weather-location-label {
    position: absolute;
    left: 50%;
    bottom: 34px;
    padding: 2px 8px;
    border: 1px solid #d9e2ec;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.14);
    color: #1f2937;
    font-size: 12px;
    font-weight: 700;
    line-height: 18px;
    white-space: nowrap;
    transform: translateX(-50%);
}

.weather-location-label::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -5px;
    width: 8px;
    height: 8px;
    border-right: 1px solid #d9e2ec;
    border-bottom: 1px solid #d9e2ec;
    background: #fff;
    transform: translateX(-50%) rotate(45deg);
}

.map-search-container {
    margin: 20px 0;
}

.search-box {
    display: flex;
    margin-bottom: 15px;
}

.search-result {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 10px;
    background: white;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
}

.search-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
}

.search-item:hover {
    background: #f5f5f5;
}

/* 位置管理相关样式 */
.location-form {
    margin: 20px 0;
    padding: 20px;
    background: white;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
}

.location-coordinates {
    margin: 15px 0;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 4px;
    border: 1px solid #eee;
}

.coordinates-display {
    display: flex;
    justify-content: space-between;
}

.saved-locations {
    margin: 20px 0;
}

.locations-list {
    margin-top: 15px;
    background: white;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.location-item {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 加载动画 */
.chart-loading, 
.chart-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    border-radius: var(--card-radius);
}

.chart-loading.hidden,
.chart-loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(33, 150, 243, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header {
        padding: 15px;
    }
    
    nav ul {
        flex-direction: column;
        gap: 10px;
    }
    
    .module-switch {
        flex-wrap: wrap;
    }
    
    .button-container {
        flex-direction: column;
    }
    
    .chart-container {
        height: 300px;
    }
    
    .stats-container {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
}

/* Toast消息样式 */
#toast-message {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(33, 150, 243, 0.95);
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 14px;
    z-index: 9999;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

/* 预警阈值样式 */
.threshold-info {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 9;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-left: 3px solid #2196F3;
} 

/* Mobile browser layout */
html,
body {
    width: 100%;
    overflow-x: hidden;
}

img,
canvas,
video {
    max-width: 100%;
}

@media (max-width: 768px) {
    body {
        font-size: 15px;
    }

    .container {
        width: 100%;
        max-width: none;
        padding: 0;
    }

    header {
        border-radius: 0;
        margin-bottom: 0;
        padding: 14px 12px;
    }

    header h1 {
        font-size: 1.35rem;
        line-height: 1.25;
    }

    nav ul {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    nav a {
        display: block;
        width: 100%;
        text-align: center;
        padding: 9px 8px;
        white-space: nowrap;
    }

    main {
        border-radius: 0;
        box-shadow: none;
        padding: 10px;
        margin-bottom: 0;
    }

    .tab-content {
        padding: 8px 0;
    }

    .module {
        padding: 14px 10px;
        margin-bottom: 14px;
        box-shadow: none;
        border: 1px solid #edf1f5;
    }

    .module-title {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-bottom: 12px;
    }

    .module-title h2 {
        font-size: 1.18rem;
        line-height: 1.3;
    }

    .location-selector {
        float: none !important;
        margin-top: 0 !important;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }

    .location-selector button,
    .button-container button,
    .form-actions button {
        width: 100%;
        min-height: 42px;
        margin: 0;
        padding: 10px 8px !important;
        font-size: 0.95rem;
    }

    .location-selector #select-location-btn {
        grid-column: 1 / -1;
    }

    .button-container {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin: 12px 0;
    }

    .chart-container {
        height: 320px;
        margin: 12px 0;
        padding: 8px;
        box-shadow: none;
        border: 1px solid #edf1f5;
    }

    #forecast-analysis-chart-container,
    #history-cumulative-chart-container {
        height: 280px;
    }

    .info-container {
        margin: 12px 0;
        padding: 12px;
        box-shadow: none;
    }

    .stats-grid,
    .stats-container {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }

    .stat-card {
        min-width: 0;
        padding: 10px 8px !important;
        text-align: center;
    }

    .stat-card strong {
        font-size: 1rem !important;
        word-break: break-word;
    }

    .stat-card span {
        font-size: 0.8rem;
    }

    .date-range-selector form,
    .form-actions,
    .coordinates-display {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .form-group {
        margin-right: 0;
        margin-bottom: 0;
    }

    input,
    select,
    .search-input,
    .date-input {
        min-height: 42px;
        font-size: 16px;
    }

    .map-container,
    #map {
        height: 360px !important;
    }

    .location-form {
        padding: 14px 10px;
        box-shadow: none;
        border: 1px solid #edf1f5;
    }

    .locations-list {
        box-shadow: none;
        border: 1px solid #edf1f5;
    }

    .location-item {
        flex-direction: column;
        align-items: stretch !important;
        gap: 10px;
    }

    .location-item > div:last-child {
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 8px !important;
    }

    footer {
        margin-top: 0;
        padding: 14px 10px;
        font-size: 0.8rem;
    }
}

@media (max-width: 420px) {
    .button-container,
    .stats-grid,
    .stats-container {
        grid-template-columns: 1fr !important;
    }

    .chart-container {
        height: 300px;
    }

    .map-container,
    #map {
        height: 320px !important;
    }
}
