/* ==========================================
   1. 基础重置与字体设置
   ========================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #f1f5f9;
    color: #1e293b;
    height: 100vh;
    height: 100dvh; /* 解决移动端/平板地址栏挤压问题 */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.font-mono {
    font-family: "Courier New", Courier, monospace;
}

/* ==========================================
   2. 手机警告弹窗 Modal 样式
   ========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    z-index: 9999; /* 保证浮在最上层 */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-card {
    background-color: #ffffff;
    border-radius: 16px;
    padding: 24px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    border: 1px solid #e2e8f0;
}

.modal-icon {
    font-size: 36px;
    margin-bottom: 12px;
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 8px;
}

.modal-text {
    font-size: 13px;
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 20px;
}

.modal-btn {
    width: 100%;
    background-color: #2563eb;
    color: #ffffff;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.modal-btn:hover {
    background-color: #1d4ed8;
}

/* ==========================================
   3. 顶部 Header 导航栏
   ========================================== */
.header {
    height: 56px;
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-title {
    font-weight: 700;
    font-size: 14px;
    color: #0f172a;
}

.logo-subtitle {
    font-size: 14px;
    color: #94a3b8;
}

.header-info {
    display: flex;
    gap: 24px;
    font-size: 12px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-label {
    color: #94a3b8;
    text-transform: uppercase;
    font-size: 10px;
    font-weight: 600;
}

.info-value {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 600;
}

.badge-green {
    background-color: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}

/* ==========================================
   4. 主工作区与侧边栏布局
   ========================================== */
.main-container {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.sidebar {
    width: 320px;
    background-color: #f8fafc;
    border-right: 1px solid #e2e8f0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

.card {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
}

.card-title {
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-subtext {
    font-size: 10px;
    color: #94a3b8;
}

.card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 12px;
    color: #64748b;
}

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

.text-blue { color: #2563eb; }

.badge-online {
    background-color: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
}

.fleet-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fleet-item {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s;
}

.fleet-item:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
}

.fleet-badge {
    font-family: monospace;
    font-weight: 700;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid;
}

.badge-normal { background-color: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.badge-warning { background-color: #fffbeb; color: #b45309; border-color: #fde68a; }
.badge-idle    { background-color: #f1f5f9; color: #64748b; border-color: #cbd5e1; }

.fleet-desc {
    font-size: 12px;
    color: #334155;
    font-weight: 500;
}

.route-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
}
.route-a { color: #2563eb; font-weight: 600; }
.route-b { color: #d97706; font-weight: 600; }
.route-desc { color: #94a3b8; font-size: 11px; }

.status-dot-blue { width: 10px; height: 10px; background-color: #2563eb; border-radius: 50%; display: inline-block; }
.status-dot-green { width: 8px; height: 8px; background-color: #10b981; border-radius: 50%; display: inline-block; }

/* ==========================================
   5. 右侧地图与 Leaflet 图层样式
   ========================================== */
.map-container {
    flex: 1;
    position: relative;
}

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

.map-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 900;
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgb(85, 227, 60);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    gap: 20px;
    font-size: 12px;
    color: #334155;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    backdrop-filter: blur(4px);
}

.legend-item { display: flex; align-items: center; gap: 8px; }
.truck-icon-dot { width: 10px; height: 10px; background-color: #2563eb; border-radius: 50%; border: 2px solid #fff; }
.line-route-a { width: 16px; height: 4px; background-color: #2563eb; border-radius: 2px; }
.line-route-b { width: 16px; height: 4px; background-color: #d97706; border-radius: 2px; }

.truck-hud-marker {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.truck-dot {
    width: 12px;
    height: 12px;
    background-color: #2563eb;
    border-radius: 50%;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.truck-label {
    font-family: monospace;
    font-size: 11px;
    font-weight: bold;
    color: #1e293b;
    background-color: #ffffff;
    padding: 2px 6px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.truck-dot.warning { background-color: #d97706; }
.truck-label.warning { color: #b45309; background-color: #fffbeb; border-color: #fde68a; }

.truck-dot.idle { background-color: #64748b; }
.truck-label.idle { color: #64748b; background-color: #f8fafc; border-color: #cbd5e1; }

.leaflet-popup-content-wrapper {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 0 !important;
    box-shadow: 0 10px 20px rgba(0,0,0,0.08) !important;
}

.leaflet-popup-content { margin: 0 !important; }

.popup-box {
    padding: 16px;
    width: 220px;
}

.popup-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
    margin-bottom: 10px;
}

.popup-title {
    font-weight: bold;
    font-size: 14px;
    font-family: monospace;
}

.popup-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
}

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

.popup-row span { color: #94a3b8; }
.popup-row strong { color: #334155; }

/* ==========================================
   6. 平板/移动端响应式兼容
   ========================================== */
@media (max-width: 1024px) {
    body {
        overflow-y: auto;
        height: auto;
        min-height: 100dvh;
    }

    .main-container {
        flex-direction: column-reverse;
        height: auto;
        overflow: visible;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-top: 1px solid #e2e8f0;
        overflow: visible;
    }

    .map-container {
        height: 55vh;
        min-height: 380px;
        position: relative;
    }

    .map-legend {
        bottom: 12px;
        left: 12px;
        padding: 8px 12px;
        font-size: 11px;
        gap: 12px;
        flex-wrap: wrap;
    }

    .header-info {
        display: none; /* 平板/手机上隐藏 Header 冗余字段 */
    }
}