/**
 * MBT 系统看板公共样式
 * 所有看板页面共享的基础样式和响应式布局
 */

/* ===== 全局重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

body {
    background: linear-gradient(135deg, #0c1b33 0%, #1a3a5f 100%);
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
    cursor: auto;
}

body.fullscreen-mode {
    cursor: none;
}

/* ===== 粒子画布 ===== */
#particles-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

/* ===== 主容器 ===== */
.dashboard-container {
    min-height: 100vh;
    width: 100%;
    padding: 12px 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
}

/* ===== 头部样式 ===== */
.header {
    background: rgba(26, 44, 92, 0.8);
    border-radius: 10px;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(77, 171, 247, 0.3);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    min-height: 60px;
}

.title-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.title-icon {
    font-size: 28px;
    color: #4dabf7;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 5px;
    border-radius: 6px;
}

.title-icon:hover {
    color: #a5d8ff;
    background: rgba(77, 171, 247, 0.15);
    transform: scale(1.1);
}

.title-icon:active {
    transform: scale(0.95);
}

.main-title {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(90deg, #4dabf7, #339af0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
}

.main-title-en {
    font-size: 12px;
    color: #a5d8ff;
    margin-top: 2px;
}

.header-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.time-display {
    text-align: right;
    font-size: 13px;
    color: #a5d8ff;
    line-height: 1.3;
}

/* ===== 按钮样式 ===== */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: rgba(77, 171, 247, 0.15);
    border: 1px solid rgba(77, 171, 247, 0.2);
    border-radius: 5px;
    cursor: pointer;
    color: #a5d8ff;
    font-size: 12px;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: none;
    padding: 0;
}

.btn:hover {
    background: rgba(77, 171, 247, 0.3);
    border-color: #4dabf7;
    color: #4dabf7;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(77, 171, 247, 0.2);
}

/* ===== KPI 卡片 ===== */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    flex-shrink: 0;
    min-height: 100px;
}

.kpi-card {
    background: rgba(26, 44, 92, 0.6);
    border-radius: 10px;
    padding: 15px 18px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(77, 171, 247, 0.2);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    border-color: rgba(77, 171, 247, 0.4);
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.kpi-title {
    font-size: 13px;
    color: #a5d8ff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.kpi-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.kpi-icon.blue { background: rgba(77, 171, 247, 0.2); color: #4dabf7; }
.kpi-icon.orange { background: rgba(255, 193, 7, 0.2); color: #ffc107; }
.kpi-icon.red { background: rgba(255, 107, 107, 0.2); color: #ff6b6b; }
.kpi-icon.green { background: rgba(81, 207, 102, 0.2); color: #51cf66; }

.kpi-value {
    font-size: 26px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 3px;
}

.kpi-desc {
    font-size: 11px;
    color: rgba(165, 216, 255, 0.7);
}

.progress-bar {
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin-top: 6px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.progress-fill.green { background: linear-gradient(90deg, #51cf66, #69db7c); }
.progress-fill.blue { background: linear-gradient(90deg, #339af0, #4dabf7); }
.progress-fill.orange { background: linear-gradient(90deg, #fcc419, #ffd43b); }

/* ===== 图表容器 ===== */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 10px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.chart-card {
    background: rgba(26, 44, 92, 0.6);
    border-radius: 10px;
    padding: 12px 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(77, 171, 247, 0.2);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.chart-title {
    font-size: 13px;
    color: #4dabf7;
    font-weight: 600;
}

.chart-wrapper {
    flex: 1;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

/* ===== 底部状态栏 ===== */
.footer {
    text-align: center;
    padding: 6px;
    color: #a5d8ff;
    font-size: 11px;
    background: rgba(26, 44, 92, 0.3);
    border-radius: 6px;
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    white-space: nowrap;
}

.refresh-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #51cf66;
    margin-right: 6px;
    animation: pulse-green 2s infinite;
}

.refresh-indicator.error {
    background: #ff6b6b;
    animation: pulse-red 1s infinite;
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 0 0 rgba(81, 207, 102, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(81, 207, 102, 0); }
}

@keyframes pulse-red {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(255, 107, 107, 0); }
}

.api-status-text {
    color: #51cf66;
}

.api-status-text.error {
    color: #ff6b6b;
    margin-right: 5px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.last-update {
    font-size: 11px;
    color: #a5d8ff;
    display: flex;
    align-items: center;
}

.legend-row {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 5px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #a5d8ff;
    cursor: pointer;
    transition: all 0.3s ease;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* ===== 响应式媒体查询 ===== */

/* Mode 1: 超小屏幕 (≤402px) - 单列KPI */
@media screen and (max-width: 402px) {
    html, body {
        overflow: auto;
    }
    
    body {
        height: auto;
        min-height: 100vh;
    }
    
    .dashboard-container {
        padding: 6px 8px;
        gap: 6px;
        height: auto;
        min-height: 100vh;
    }
    
    .main-title-en {
        display: none !important;
    }
    
    .header {
        padding: 8px 10px;
        min-height: 50px;
    }
    
    .title-icon {
        font-size: 18px;
    }
    
    .main-title {
        font-size: 14px;
    }
    
    .time-display {
        font-size: 9px;
    }
    
    .btn {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }
    
    .kpi-row {
        grid-template-columns: 1fr;
        gap: 6px;
        min-height: auto;
    }
    
    .kpi-card {
        padding: 10px;
    }
    
    .kpi-value {
        font-size: 18px;
    }
    
    .kpi-title {
        font-size: 10px;
    }
    
    .kpi-desc {
        font-size: 8px;
    }
    
    .kpi-icon {
        width: 22px;
        height: 22px;
        font-size: 11px;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .chart-wrapper {
        min-height: 250px;
    }
    
    .footer {
        font-size: 9px;
        padding: 6px;
    }
}

/* Mode 2: 小屏幕 (403-802px) - 双列KPI */
@media screen and (min-width: 403px) and (max-width: 802px) {
    .kpi-row {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        min-height: auto;
    }
    
    .kpi-card {
        padding: 12px;
    }
    
    .kpi-value {
        font-size: 20px;
    }
    
    .kpi-title {
        font-size: 11px;
    }
    
    .kpi-desc {
        font-size: 9px;
    }
    
    .kpi-icon {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .chart-wrapper {
        min-height: 280px;
    }
}

/* Mode 2横屏优化: 图表卡片并行布局 */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .charts-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    
    .chart-card {
        padding: 6px 8px;
        min-height: 0;
    }
    
    .chart-header {
        margin-bottom: 3px;
    }
    
    .chart-title {
        font-size: 10px;
    }
    
    .chart-wrapper {
        min-height: 180px;
        max-height: 220px;
    }
}

/* Mode 3: 中等屏幕 (803-980px) - 四列KPI */
@media screen and (min-width: 803px) and (max-width: 980px) {
    .kpi-row {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .charts-grid {
        grid-template-columns: 2fr 1fr;
    }
}

/* Mode 4: 中大屏幕 (981-1376px) - 默认布局 */
@media screen and (min-width: 981px) and (max-width: 1376px) {
    .dashboard-container {
        padding: 12px 15px;
        gap: 10px;
    }
    
    .main-title {
        font-size: 22px;
    }
    
    .kpi-value {
        font-size: 24px;
    }
    
    .chart-wrapper {
        min-height: 240px;
    }
}

/* Mode 5: 大屏幕 (1377-1646px) - 增强显示 */
@media screen and (min-width: 1377px) and (max-width: 1646px) {
    .dashboard-container {
        padding: 15px 20px;
        gap: 12px;
    }
    
    .main-title {
        font-size: 26px;
    }
    
    .kpi-value {
        font-size: 28px;
    }
    
    .chart-wrapper {
        min-height: 260px;
    }
}

/* Mode 6: 超大屏幕 (1647-1728px) - 专业显示 */
@media screen and (min-width: 1647px) and (max-width: 1728px) {
    .dashboard-container {
        padding: 18px 25px;
        gap: 15px;
    }
    
    .main-title {
        font-size: 28px;
    }
    
    .kpi-value {
        font-size: 30px;
    }
    
    .chart-wrapper {
        min-height: 280px;
    }
}

/* Mode 7: 超宽屏幕 (≥1729px) - 最大化显示 */
@media screen and (min-width: 1729px) {
    .dashboard-container {
        padding: 20px 30px;
        gap: 18px;
    }
    
    .main-title {
        font-size: 30px;
    }
    
    .kpi-value {
        font-size: 32px;
    }
    
    .chart-wrapper {
        min-height: 300px;
    }
}

/* Mode 3车载专用 (960x540) - 禁止滚动,固定视口 */
@media screen and (width: 960px) and (height: 540px),
       screen and (min-width: 900px) and (max-width: 1024px) and (min-height: 480px) and (max-height: 600px) {
    
    html, body {
        width: 100vw !important;
        height: 100vh !important;
        overflow: hidden !important;
        touch-action: none !important;
        -webkit-overflow-scrolling: auto !important;
    }

    .dashboard-container {
        width: 100vw !important;
        height: 100vh !important;
        max-height: 540px !important;
        padding: 6px 8px !important;
        gap: 6px !important;
        overflow: hidden !important;
    }

    .header {
        padding: 6px 10px !important;
        min-height: 36px !important;
        max-height: 36px !important;
    }

    .title-container {
        gap: 8px !important;
    }

    .main-title {
        font-size: 15px !important;
        line-height: 1.1 !important;
    }

    .main-title-en {
        display: none !important;
    }

    .title-icon {
        font-size: 18px !important;
    }

    .time-display {
        font-size: 9px !important;
        line-height: 1.2 !important;
    }

    #currentDate,
    #currentTime {
        white-space: nowrap !important;
    }

    .btn {
        width: 22px !important;
        height: 22px !important;
        font-size: 10px !important;
    }

    .kpi-row {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 5px !important;
        flex-shrink: 0 !important;
        min-height: 60px !important;
    }

    .kpi-card {
        padding: 6px 8px !important;
    }

    .kpi-header {
        margin-bottom: 3px !important;
    }

    .kpi-title {
        font-size: 8px !important;
    }

    .kpi-value {
        font-size: 14px !important;
    }

    .kpi-desc {
        font-size: 7px !important;
    }

    .kpi-icon {
        width: 18px !important;
        height: 18px !important;
        font-size: 9px !important;
    }

    .progress-bar {
        height: 3px !important;
        margin-top: 3px !important;
    }

    .charts-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: 1fr !important;
        gap: 5px !important;
        flex: 1 !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    .chart-card {
        padding: 6px 8px !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    .chart-header {
        margin-bottom: 4px !important;
        flex-shrink: 0 !important;
    }

    .chart-title {
        font-size: 9px !important;
    }

    .chart-wrapper {
        flex: 1 !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    canvas {
        max-height: 100% !important;
        display: block !important;
    }

    .legend-row {
        gap: 6px !important;
        margin-top: 3px !important;
        flex-shrink: 0 !important;
    }

    .legend-item {
        font-size: 7px !important;
    }

    .legend-dot {
        width: 6px !important;
        height: 6px !important;
    }

    html, body,
    .dashboard-container,
    .header,
    .kpi-row,
    .kpi-card,
    .charts-grid,
    .chart-card,
    .chart-wrapper,
    .legend-row {
        overflow: hidden !important;
        touch-action: none !important;
        -webkit-overflow-scrolling: auto !important;
        scrollbar-width: none !important;
    }

    ::-webkit-scrollbar {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
    }

    .footer {
        font-size: 8px !important;
        padding: 3px 6px !important;
        flex-shrink: 0 !important;
        min-height: 22px !important;
        max-height: 22px !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
    }

    .refresh-indicator {
        width: 5px !important;
        height: 5px !important;
        margin-right: 3px !important;
    }

    canvas {
        display: block !important;
    }
}
