/* 无人机地图页面样式 */

/* 变量定义 */
:root {
    --primary-color: #38bdf8;
    --secondary-color: #2a3040;
    --background-color: #131722;
    --card-background: rgba(31, 41, 55, 0.6);
    --text-color: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --transition-speed: 0.3s;
}

/* 布局 */
.drone-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto auto;
    gap: 20px;
    margin-bottom: 20px;
    width: 100%;
}

.thermal-video-container {
    grid-column: 1;
    grid-row: 1;
}

.visible-video-container {
    grid-column: 2;
    grid-row: 1;
}

.fusion-video-container {
    grid-column: 3;
    grid-row: 1;
}

.drone-map {
    grid-column: 1;
    grid-row: 2;
}

.target-recognition {
    grid-column: 2 / 4;
    grid-row: 2;
}

/* 全宽地图 */
.drone-map.full-width {
    grid-column: 1 / -1;
    grid-row: 2;
}

/* 视频容器 */
.thermal-video-container,
.visible-video-container,
.fusion-video-container {
    width: 100%;
    height: 100%;
}

/* 统一视频卡片样式 */
.thermal-video-container .video-card,
.visible-video-container .video-card,
.fusion-video-container .video-card {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* 统一视频内容区域高度 */
.thermal-video-container .video-body,
.visible-video-container .video-body,
.fusion-video-container .video-body {
    height: 350px;
    /* 与交通监控页面的高度一致 */
    width: 100%;
    position: relative;
    flex: 1;
    overflow: hidden;
}

/* 统一视频播放器样式 */
.thermal-video-container .video-player,
.visible-video-container .video-player,
.fusion-video-container .video-player {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* 确保视频填充整个容器 */
    background-color: #000;
    border-radius: 0 0 8px 8px;
}

/* 视频容器 */
.video-card {
    background-color: var(--card-background);
    border-radius: 8px;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-speed) ease;
}

.video-card:hover {
    transform: translateY(-5px);
}

.video-header {
    padding: 15px;
    background: linear-gradient(90deg, rgba(125, 211, 252, 0.2), rgba(56, 189, 248, 0.4));
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.video-header h3 {
    margin: 0;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.video-controls {
    display: flex;
    gap: 8px;
}

.video-btn {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background-color var(--transition-speed) ease;
}

.video-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.video-body {
    flex: 1;
    position: relative;
    min-height: 200px;
    background-color: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-placeholder {
    text-align: center;
    color: var(--text-muted);
}

.video-placeholder i {
    font-size: 48px;
    margin-bottom: 10px;
    display: block;
}

/* 地图面板 */
.map-card {
    background-color: var(--card-background);
    border-radius: 8px;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-speed) ease;
}

.map-card:hover {
    transform: translateY(-5px);
}

.map-header {
    padding: 15px;
    background: linear-gradient(90deg, rgba(125, 211, 252, 0.2), rgba(56, 189, 248, 0.4));
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.map-header h3 {
    margin: 0;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.map-controls {
    display: flex;
    gap: 8px;
}

.map-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-speed) ease;
}

.map-btn:hover,
.map-btn.active {
    background-color: rgba(125, 211, 252), 0.1);
    border-color: var(--primary-color);
}

.map-body {
    position: relative;
    height: 100%;
}

#droneMap {
    width: 100%;
    height: 100%;
    min-height: 450px;
}

/* 目标识别样式 */
.recognition-container {
    position: relative;
    height: 100%;
    padding: 0;
    /* 移除内边距 */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.video-player {
    flex: 1;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 12px;
    min-height: 320px;
}

.upload-btn-wrapper {
    position: absolute;
    top: 15px;
    left: 15px;
}

.upload-btn {
    background-color: var(--primary-color);
    color: #000;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.upload-btn:before {
    content: '⬆️';
}

.video-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
}

.video-placeholder i {
    font-size: 48px;
    margin-bottom: 10px;
}

.video-controls-bar {
    position: absolute;
    bottom: 15px;
    right: 15px;
    display: flex;
    gap: 10px;
}

.video-controls-bar button {
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.video-controls-bar button:hover {
    background: var(--primary-color);
    color: black;
}

.detection-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
    display: none;
    /* 默认隐藏所有检测行 */
}

.detection-row.active {
    display: flex;
    /* 只显示激活的检测行 */
}

.vehicle-detection,
.person-detection,
.event-detection {
    flex-wrap: wrap;
    /* 允许卡片在空间不足时换行 */
}

.vehicle-detection .detection-card,
.person-detection .detection-card,
.event-detection .detection-card {
    min-width: 100px;
    /* 确保卡片不会太窄 */
    margin-bottom: 10px;
    /* 换行时的间距 */
}

.detection-card {
    flex: 1;
    background-color: rgba(31, 41, 55, 0.5);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    text-align: center;
}

.light-theme .detection-card {
    background-color: rgba(31, 41, 55, 0.05);
}

.detection-card i {
    font-size: 20px;
    color: var(--primary-color);
}

.detection-card span {
    color: var(--text-muted);
    font-size: 12px;
}

.detection-card .count {
    background-color: rgba(0, 255, 0, 0.2);
    color: #00ff00;
    border-radius: 15px;
    padding: 2px 10px;
    font-weight: 600;
    font-size: 16px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.detection-card .count span {
    font-size: 12px;
    color: inherit;
    margin-left: 2px;
}

/* 响应式布局 */
@media (max-width: 1200px) {
    .drone-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto auto auto;
    }

    .thermal-video-container {
        grid-column: 1;
        grid-row: 1;
    }

    .visible-video-container {
        grid-column: 2;
        grid-row: 1;
    }

    .fusion-video-container {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .drone-map {
        grid-column: 1;
        grid-row: 3;
    }

    .target-recognition {
        grid-column: 2;
        grid-row: 3;
    }

    .drone-map.full-width {
        grid-column: 1 / -1;
        grid-row: 3;
    }
}

@media (max-width: 768px) {
    .drone-grid {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(5, auto);
    }

    .thermal-video-container {
        grid-column: 1;
        grid-row: 1;
    }

    .visible-video-container {
        grid-column: 1;
        grid-row: 2;
    }

    .fusion-video-container {
        grid-column: 1;
        grid-row: 3;
    }

    .drone-map {
        grid-column: 1;
        grid-row: 4;
    }

    .target-recognition {
        grid-column: 1;
        grid-row: 5;
    }

    .drone-map.full-width {
        grid-column: 1;
        grid-row: 4;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.video-card,
.map-card {
    animation: fadeIn 0.5s ease forwards;
}

/* 地图下方绿色窗口 */
.bottom-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 20px;
    margin-bottom: 20px;
    width: 100%;
}

.green-card {
    background-color: transparent;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    height: 340px;
    /* 增加高度以适应图表 */
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.green-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.25);
}

.card-header {
    padding: 15px;
    background: linear-gradient(90deg, rgba(125, 211, 252, 0.2), rgba(56, 189, 248, 0.4));
    /* 紫色渐变背景 */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    margin: 0;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
}

.card-controls {
    display: flex;
    gap: 8px;
}

.card-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--text-color);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all var(--transition-speed) ease;
}

.card-btn:hover,
.card-btn.active {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.card-body {
    flex: 1;
    padding: 15px;
    height: 280px;
    /* 增加高度以适应图表 */
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    /* 确保padding包含在尺寸内 */
}

/* 图表容器样式 - 修复溢出问题 */
.card-body .chart-container {
    width: 100%;
    height: calc(100% - 0px);
    /* 去掉额外的减值 */
    overflow: hidden;
    position: relative;
}

.card-body .chart-container canvas {
    position: relative !important;
    /* 改为相对定位 */
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 250px !important;
    /* 限制最大高度避免溢出 */
}

/* 响应式调整 */
@media (max-width: 1200px) {
    .bottom-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .bottom-cards {
        grid-template-columns: 1fr;
    }
}

/* 视频加载指示器样式 */
.video-loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: white;
    background-color: rgba(0, 0, 0, 0.7);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    border-radius: 8px;
    text-align: center;
    padding: 20px;
}

/* 加载旋转动画 */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #38bdf8;
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 10px;
}

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

/* 视频播放覆盖层 */
.video-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    border-radius: 8px;
    color: white;
    font-size: 48px;
    transition: background-color 0.3s ease;
}

.video-play-overlay:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

.video-play-overlay i {
    text-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease, color 0.3s ease;
}

.video-play-overlay:hover i {
    transform: scale(1.1);
    color: #38bdf8;
}

/* 增强视频控制栏样式 */
.video-controls-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0));
    padding: 8px 15px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    border-radius: 0 0 8px 8px;
}

.video-controls-bar:hover {
    opacity: 1;
}

.video-controls-bar button {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 5px 10px;
    margin-right: 5px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.video-controls-bar button:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: #38bdf8;
}

/* 视频播放器样式增强 */
.video-player {
    flex: 1;
    position: relative;
    margin-bottom: 8px;
    /* 与检测卡片保持适当间距 */
}

/* 视频加载失败样式 */
.video-error-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: white;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 15px 25px;
    border-radius: 8px;
    z-index: 10;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.video-error-message i {
    font-size: 24px;
    margin-right: 10px;
    color: #e74c3c;
}

/* 重试按钮样式 */
#retry-btn {
    background-color: #7dd3fc;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    margin-top: 10px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#retry-btn:hover {
    background-color: #0ea5e9;
}