/* ===== 全局 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #f0f2f5;
    height: 100vh;
    display: flex;
    overflow: hidden;
    color: #333;
}

/* ===== 侧边栏 ===== */
.sidebar {
    width: 200px;
    flex-shrink: 0;
    background: #1a1a2e;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    border-bottom: 1px solid #2a2a3e;
}

.logo-icon {
    font-size: 22px;
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 122, 255, 0.2);
    border-radius: 8px;
}

.logo-text { font-size: 16px; font-weight: 700; color: #fff; letter-spacing: 1px; }

.nav-menu { list-style: none; padding: 12px 8px; flex: 1; }

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 8px; cursor: pointer;
    font-size: 14px; color: #8888aa; margin-bottom: 4px; transition: all 0.2s;
}

.nav-item:hover { background: rgba(0, 122, 255, 0.1); color: #c0c0d0; }
.nav-item.active { background: rgba(0, 122, 255, 0.2); color: #58a6ff; }

.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid #2a2a3e; }

.conn-indicator { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #8888aa; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: #484f58; display: inline-block; }

.conn-indicator.connected .dot { background: #3fb950; box-shadow: 0 0 6px rgba(63, 185, 80, 0.5); }
.conn-indicator.connected { color: #3fb950; }

/* ===== 主区域 ===== */
.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100vh; }

/* ===== 顶栏 ===== */
.top-bar {
    display: flex; justify-content: space-between; align-items: center;
    height: 48px; padding: 0 20px; background: #1a1a2e; flex-shrink: 0; z-index: 100;
}

.top-bar-left { display: flex; align-items: center; gap: 16px; }
.top-bar-right { display: flex; align-items: center; gap: 8px; }

.page-title { font-size: 16px; font-weight: 600; color: #e6edf3; }

.status-item { font-size: 13px; color: #aaa; }
.status-item strong { color: #e0e0e0; }

.status-chip {
    padding: 4px 12px; border-radius: 12px; font-size: 12px; font-weight: 600;
    background: #2a2a3e; color: #8888aa;
}

/* ===== 标签 ===== */
.tag { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.tag-success { background: #f6ffed; color: #52c41a; }
.tag-danger  { background: #fff1f0; color: #ff4d4f; }
.tag-warning { background: #fffbe6; color: #faad14; }
.tag-info    { background: #e6f7ff; color: #007aff; }

/* ===== 页面容器 ===== */
.page-content { display: none; flex-direction: column; flex: 1; min-height: 0; }
.page-content.active { display: flex; }

.page-body { flex: 1; overflow-y: auto; padding: 20px; }

/* ===== 按钮 ===== */
.btn {
    padding: 8px 16px; border: none; border-radius: 6px; cursor: pointer;
    font-size: 13px; font-weight: 600; transition: opacity 0.2s;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn:not(:disabled):hover { opacity: 0.85; }
.btn-primary   { background: #007aff; color: #fff; }
.btn-success   { background: #52c41a; color: #fff; }
.btn-warning   { background: #faad14; color: #fff; }
.btn-danger    { background: #ff4d4f; color: #fff; }
.btn-secondary { background: #e0e0e0; color: #333; }
.btn.wide      { width: 100%; }
.btn-link { background: none; border: none; color: #999; cursor: pointer; font-size: 12px; }
.btn-link:hover { color: #007aff; }

/* ===== 统计卡片 ===== */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }

.stat-card {
    background: #fff; border-radius: 10px; padding: 16px 20px;
    border-left: 3px solid transparent; box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.stat-card.stat-pending { border-left-color: #faad14; }
.stat-card.stat-active  { border-left-color: #007aff; }
.stat-card.stat-done    { border-left-color: #52c41a; }
.stat-card.stat-drone   { border-left-color: #58a6ff; }

.stat-value { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.stat-card.stat-pending .stat-value { color: #faad14; }
.stat-card.stat-active  .stat-value { color: #007aff; }
.stat-card.stat-done    .stat-value { color: #52c41a; }
.stat-label { font-size: 13px; color: #999; }

.dashboard-body { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ===== 卡片 ===== */
.card { background: #fff; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

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

.card-title { font-size: 14px; font-weight: 600; color: #333; }

.card-badge { padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; background: rgba(250, 173, 20, 0.15); color: #faad14; }
.card-badge.active { background: rgba(0, 122, 255, 0.15); color: #007aff; }

/* ===== 任务列表 ===== */
.list-card { max-height: 400px; display: flex; flex-direction: column; }
.task-list { flex: 1; overflow-y: auto; padding: 8px; }

.task-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 8px; cursor: pointer;
    margin-bottom: 4px; transition: background 0.15s;
}
.task-item:hover { background: #f0f7ff; }

.task-priority { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.priority-urgent { background: rgba(255, 77, 79, 0.1); color: #ff4d4f; }
.priority-high   { background: rgba(250, 173, 20, 0.1); color: #faad14; }
.priority-normal  { background: rgba(0, 122, 255, 0.1); color: #007aff; }

.task-info { flex: 1; min-width: 0; }
.task-name { font-size: 13px; font-weight: 600; color: #333; margin-bottom: 2px; }
.task-desc { font-size: 11px; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-arrow { color: #ccc; font-size: 14px; flex-shrink: 0; }

.empty-hint { text-align: center; color: #bbb; font-size: 13px; padding: 20px 0; }

/* ===== 连接设置 ===== */
.conn-card { flex-shrink: 0; }

.conn-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.conn-url-row {
    display: flex;
    gap: 6px;
}

.conn-url-row input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 12px;
    outline: none;
    font-family: 'Consolas', 'Monaco', monospace;
}

.conn-url-row input:focus { border-color: #007aff; }

/* ===== 士兵标记 (地图) ===== */
.soldier-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
}
.soldier-marker-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #52c41a;
    border: 2px solid #fff;
    box-shadow: 0 0 6px rgba(82, 196, 26, 0.5);
}
.soldier-marker-name {
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: rgba(82, 196, 26, 0.85);
    padding: 1px 6px;
    border-radius: 3px;
    margin-top: 2px;
    white-space: nowrap;
}

/* ===== 危险区域标记 (地图) ===== */
.danger-zone-marker { pointer-events: auto; }
.danger-zone-icon {
    font-size: 20px;
    color: #ff4d4f;
    text-shadow: 0 0 4px rgba(255, 77, 79, 0.6);
    text-align: center;
    line-height: 24px;
}

/* ===== 士兵列表 ===== */
.soldier-card { flex-shrink: 0; }
.soldier-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 2px;
    transition: background 0.15s;
}
.soldier-item:hover { background: #f0fff0; }
.soldier-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #52c41a;
    flex-shrink: 0;
}
.soldier-info { flex: 1; min-width: 0; }
.soldier-name { font-size: 13px; font-weight: 600; color: #333; }
.soldier-coord { font-size: 11px; color: #999; }

/* ===== 危险区域列表 ===== */
.danger-card { flex-shrink: 0; }
.card-badge.danger { background: rgba(255, 77, 79, 0.15); color: #ff4d4f; }
.danger-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    margin-bottom: 2px;
    background: #fff1f0;
}
.danger-icon {
    font-size: 16px;
    color: #ff4d4f;
    flex-shrink: 0;
}
.danger-info { flex: 1; min-width: 0; }
.danger-desc { font-size: 13px; font-weight: 600; color: #ff4d4f; }
.danger-coord { font-size: 11px; color: #999; }

/* ===== 滚动列表容器 ===== */
.list-scroll-content {
    max-height: 150px;
    overflow-y: auto;
    padding: 8px;
}

/* ===== 监控页 ===== */
.monitor-body { flex: 1; display: flex; min-height: 0; }

.map-container { flex: 1; min-width: 0; z-index: 1; }

.monitor-panel {
    width: 320px; flex-shrink: 0; background: #fff; border-left: 1px solid #e8e8e8;
    display: flex; flex-direction: column; overflow-y: auto;
}

.drone-info-card { flex-shrink: 0; }

.drone-card-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 16px; border-bottom: 1px solid #f0f0f0;
}

.drone-name { font-size: 16px; font-weight: 700; color: #333; }

.drone-meta {
    padding: 10px 16px; font-size: 12px; color: #999;
    display: flex; gap: 20px; border-bottom: 1px solid #f0f0f0;
}
.drone-meta strong { color: #333; }

.monitor-data { padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.data-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

.data-item { background: #f8f9fa; border-radius: 6px; padding: 8px; text-align: center; }
.data-label { display: block; font-size: 11px; color: #999; margin-bottom: 2px; }
.data-value { font-size: 13px; font-weight: 600; color: #333; }

.control-card { flex-shrink: 0; }
.control-btns { padding: 12px; display: flex; flex-direction: column; gap: 8px; }

.log-card { flex: 1; display: flex; flex-direction: column; min-height: 150px; }
.log-content {
    flex: 1; overflow-y: auto; padding: 8px 12px;
    font-family: 'Consolas', 'Monaco', monospace; font-size: 11px; line-height: 1.6;
}

.log-entry { white-space: nowrap; }
.log-entry .time { color: #bbb; margin-right: 8px; }
.log-entry.success { color: #52c41a; }
.log-entry.error   { color: #ff4d4f; }
.log-entry.warning { color: #faad14; }
.log-entry.info    { color: #999; }

/* ===== 弹窗 ===== */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); display: flex; align-items: center;
    justify-content: center; z-index: 9999;
}

.modal {
    background: #fff; border-radius: 12px; width: 480px; max-height: 85vh;
    display: flex; flex-direction: column; box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px; border-bottom: 1px solid #f0f0f0;
}

.modal-title { font-size: 15px; font-weight: 700; color: #333; }

.modal-close { background: none; border: none; color: #999; font-size: 20px; cursor: pointer; }
.modal-close:hover { color: #ff4d4f; }

.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }

.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 12px 20px; border-top: 1px solid #f0f0f0;
}

.detail-row { display: flex; margin-bottom: 10px; font-size: 13px; }
.detail-label { width: 80px; color: #999; flex-shrink: 0; }
.detail-value { color: #333; flex: 1; }

.detail-section { margin-top: 14px; padding-top: 12px; border-top: 1px solid #f0f0f0; }
.detail-section-title { font-size: 13px; font-weight: 600; color: #007aff; margin-bottom: 10px; }

/* 坐标输入 */
.coord-group { margin-bottom: 12px; }
.coord-label { font-size: 12px; font-weight: 600; color: #333; margin-bottom: 6px; }
.coord-inputs { display: flex; gap: 10px; }
.coord-inputs label { font-size: 12px; color: #666; display: flex; align-items: center; gap: 4px; }
.coord-inputs input {
    width: 110px; padding: 5px 8px; border: 1px solid #ddd; border-radius: 4px;
    font-size: 12px; text-align: center; outline: none;
}
.coord-inputs input:focus { border-color: #007aff; }
.coord-hint { font-size: 11px; color: #bbb; margin-top: 4px; }

.dispatch-option {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border-radius: 8px; margin-bottom: 6px;
    cursor: pointer; border: 1px solid #e8e8e8; transition: all 0.2s;
}
.dispatch-option:hover { border-color: #007aff; }
.dispatch-option.selected { border-color: #007aff; background: #f0f7ff; }
.dispatch-option input[type="radio"] { accent-color: #007aff; }
.dispatch-option label { font-size: 13px; color: #333; cursor: pointer; }

/* ===== Leaflet ===== */
.drone-icon { width: 24px; height: 24px; position: relative; }
.drone-icon-inner {
    width: 0; height: 0;
    border-left: 10px solid transparent; border-right: 10px solid transparent;
    border-bottom: 20px solid #007aff;
    position: absolute; top: 2px; left: 2px; transform-origin: center 60%;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }

/* ===== 适配 ===== */
@media (max-width: 1100px) {
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
    .dashboard-body { grid-template-columns: 1fr; }
    .monitor-panel { width: 280px; }
}

/* ===== 闪光检测面板 ===== */
.flash-card { flex-shrink: 0; }
.flash-body { padding: 12px; }
.flash-data { margin: 10px 0; }
.flash-avoidance-btns { display: flex; gap: 8px; }
.flash-avoidance-btns .btn { flex: 1; }

.tag-secondary { background: #f0f0f0; color: #999; }
.hidden { display: none !important; }
