/**
 * Dashboard Main Stylesheet
 * 智能光伏电站运营大屏 - 深色主题
 */

/* ============================================================
   FONT FALLBACKS
   ============================================================ */
@font-face {
    font-family: 'Orbitron-Fallback';
    src: local('Consolas'), local('Monaco'), local('Courier New');
}
@font-face {
    font-family: 'Rajdhani-Fallback';
    src: local('Consolas'), local('Monaco'), local('Courier New');
}

/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
    --screen-bg: #020610;
    --panel-bg: rgba(7, 19, 40, 0.76);
    --panel-bg-gradient: linear-gradient(135deg, rgba(8, 22, 48, 0.88) 0%, rgba(5, 14, 32, 0.92) 100%);
    --border-glow: rgba(57, 165, 255, 0.18);
    --border-subtle: rgba(98, 155, 255, 0.10);
    --accent-blue: #39a5ff;
    --accent-cyan: #48e0ff;
    --accent-green: #47e39b;
    --accent-orange: #ffb548;
    --accent-red: #ff5e78;
    --accent-purple: #a78bfa;
    --text-primary: #ebf3ff;
    --text-secondary: #8ea7c9;
    --text-dim: #4d6a8e;
    --font-title: 'Orbitron', 'Orbitron-Fallback', 'Microsoft YaHei', sans-serif;
    --font-number: 'Rajdhani', 'Rajdhani-Fallback', 'Microsoft YaHei', sans-serif;
    --font-body: 'Microsoft YaHei', -apple-system, sans-serif;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--screen-bg);
    font-family: var(--font-body);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   ROOT CONTAINER
   ============================================================ */
.dashboard-root {
    width: 100%;
    height: 100%;
    background: var(--screen-bg);
    position: relative;
}

.dashboard-screen {
    width: 1920px;
    height: 1080px;
    position: absolute;
    display: flex;
    flex-direction: column;
    padding: 0 24px;
    background:
        radial-gradient(ellipse at 50% 0%, rgba(57, 165, 255, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 20% 80%, rgba(71, 227, 155, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(167, 139, 250, 0.03) 0%, transparent 50%),
        var(--screen-bg);
}

/* ============================================================
   HEADER
   ============================================================ */
.dashboard-header {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
    padding: 0 8px;
}

.header-brand {
    max-width: calc(100% - 360px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    min-width: 0;
}

.header-brand-logo {
    width: 76px;
    height: 76px;
    object-fit: contain;
    flex-shrink: 0;
    filter: drop-shadow(0 0 16px rgba(57, 165, 255, 0.3));
}

.header-brand-text {
    display: flex;
    align-items: center;
    min-width: 0;
}

.header-decoration {
    position: absolute;
    bottom: 0;
    left: 8%;
    right: 8%;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, rgba(57, 165, 255, 0.32) 16%, rgba(72, 224, 255, 0.8) 50%, rgba(57, 165, 255, 0.32) 84%, transparent 100%);
}

.header-decoration::before,
.header-decoration::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 72px;
    height: 10px;
    transform: translateY(-50%);
    background: radial-gradient(circle, rgba(72, 224, 255, 0.45) 0%, rgba(72, 224, 255, 0) 72%);
}

.header-decoration::before {
    left: 18%;
}

.header-decoration::after {
    right: 18%;
}

.screen-title {
    font-family: var(--font-title);
    font-size: 50px;
    line-height: 1;
    font-weight: 900;
    letter-spacing: 4px;
    white-space: nowrap;
    background: linear-gradient(135deg, #ffffff 0%, #7fd6ff 28%, #39a5ff 58%, #48e0ff 82%, #ffffff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 0 18px rgba(57, 165, 255, 0.28));
}

.header-clock {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: baseline;
    gap: 14px;
}

.header-clock .clock-date {
    font-family: var(--font-number);
    font-size: 22px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 1px;
    white-space: nowrap;
}

.header-clock .clock-time {
    font-family: var(--font-number);
    font-size: 34px;
    font-weight: 700;
    color: var(--accent-cyan);
    letter-spacing: 2px;
    white-space: nowrap;
}

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.dashboard-body {
    flex: 1;
    display: flex;
    gap: 14px;
    overflow: hidden;
    padding-top: 10px;
}

.col-left {
    width: 420px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.col-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.col-right {
    width: 500px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.col-right .panel {
    min-height: 0;
}

/* ============================================================
   PANEL (CARD) COMPONENT
   ============================================================ */
.panel {
    background: var(--panel-bg-gradient);
    border: 1px solid var(--border-glow);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    animation: panelGlow 5s ease-in-out infinite alternate;
}

.panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-blue), transparent);
    opacity: 0.6;
}

@keyframes panelGlow {
    from {
        box-shadow:
            inset 0 0 25px rgba(20, 60, 140, 0.06),
            0 0 0 transparent;
    }
    to {
        box-shadow:
            inset 0 0 35px rgba(30, 80, 180, 0.1),
            0 2px 20px rgba(20, 60, 140, 0.04);
    }
}

.panel-title {
    font-size: 21px;
    font-weight: 700;
    color: var(--text-primary);
    padding: 12px 16px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 1px;
}

.panel-title .title-dot {
    width: 4px;
    height: 16px;
    border-radius: 2px;
    background: var(--accent-blue);
    flex-shrink: 0;
}

.panel-content {
    padding: 6px 16px 12px;
}

/* ============================================================
   STATION OVERVIEW GRID
   ============================================================ */
.status-overview-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.status-item {
    text-align: center;
    padding: 9px 4px;
    border-radius: 6px;
    background: rgba(57, 165, 255, 0.04);
    border: 1px solid rgba(57, 165, 255, 0.06);
}

.status-item-value {
    font-family: var(--font-number);
    font-size: 40px;
    font-weight: 700;
    line-height: 1.15;
}

.status-item-label {
    font-size: 17px;
    color: var(--text-dim);
    margin-top: 4px;
}

.status-total .status-item-value { color: var(--accent-blue); }
.status-normal .status-item-value { color: var(--accent-green); }
.status-fault .status-item-value { color: var(--accent-red); }
.status-offline .status-item-value { color: var(--text-dim); }

/* ============================================================
   DATA TABLES
   ============================================================ */
.data-table-wrap {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.data-table thead th {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-dim);
    padding: 8px 6px;
    text-align: left;
    border-bottom: 1px solid rgba(57, 165, 255, 0.1);
    background: rgba(10, 25, 55, 0.95);
    white-space: nowrap;
}

.table-body-scroll {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.table-body-scroll .data-table tbody {
    transition: transform 0.6s ease;
}

.data-table tbody td {
    font-size: 18px;
    line-height: 1.25;
    color: var(--text-secondary);
    padding: 8px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 1px solid rgba(57, 165, 255, 0.04);
}

.data-table tbody tr:hover td {
    color: var(--text-primary);
    background: rgba(57, 165, 255, 0.04);
}

/* 可点击的电站行 */
.station-list-table tbody tr.row-clickable {
    cursor: pointer;
}

.station-list-table tbody tr.row-clickable:hover td {
    background: rgba(57, 165, 255, 0.1);
}

/* 电站列表：原生滚动 + 鼠标滚轮 + 自定义滚动条（覆盖 .table-body-scroll 的 overflow:hidden） */
#station-table-wrap {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(57, 165, 255, 0.45) transparent;
}

#station-table-wrap::-webkit-scrollbar {
    width: 6px;
}

#station-table-wrap::-webkit-scrollbar-track {
    background: transparent;
}

#station-table-wrap::-webkit-scrollbar-thumb {
    background: rgba(57, 165, 255, 0.35);
    border-radius: 3px;
}

#station-table-wrap::-webkit-scrollbar-thumb:hover {
    background: rgba(57, 165, 255, 0.6);
}

.station-list-table .cell-name {
    font-weight: 600;
    color: var(--text-primary);
}

.station-type-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 19px;
    padding: 0 5px;
    margin-right: 6px;
    border-radius: 3px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    vertical-align: 1px;
}

.station-type-pv {
    color: var(--accent-cyan);
    background: rgba(72, 224, 255, 0.12);
    border: 1px solid rgba(72, 224, 255, 0.22);
}

.station-type-storage {
    color: var(--accent-green);
    background: rgba(71, 227, 155, 0.13);
    border: 1px solid rgba(71, 227, 155, 0.24);
}

.station-name-text {
    vertical-align: middle;
}

.station-list-table .cell-vendor {
    color: var(--text-secondary);
    text-transform: none;
}

.station-list-table .cell-power {
    text-align: right;
    font-family: var(--font-number);
    color: #8fd4ff;
}

.station-list-table tbody td {
    letter-spacing: 0;
}

.station-list-table th:nth-child(1),
.station-list-table td:nth-child(1) {
    width: 44%;
}

.station-list-table th:nth-child(2),
.station-list-table td:nth-child(2) {
    width: 12%;
    text-align: center;
}

.station-list-table th:nth-child(3),
.station-list-table td:nth-child(3) {
    width: 14%;
    text-align: center;
}

.station-list-table th:nth-child(4),
.station-list-table td:nth-child(4) {
    width: 30%;
    text-align: right;
}

.alarm-list-table th:nth-child(1),
.alarm-list-table td:nth-child(1) {
    width: 14%;
}

.alarm-list-table th:nth-child(2),
.alarm-list-table td:nth-child(2) {
    width: 24%;
}

.alarm-list-table th:nth-child(3),
.alarm-list-table td:nth-child(3) {
    width: 28%;
}

.alarm-list-table th:nth-child(4),
.alarm-list-table td:nth-child(4) {
    width: 16%;
    text-align: center;
}

.alarm-list-table th:nth-child(5),
.alarm-list-table td:nth-child(5) {
    width: 18%;
    text-align: center;
}

/* ============================================================
   STATUS BADGE
   ============================================================ */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 3px;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.badge-normal, .badge-run, .badge-charging, .badge-resolved, .badge-completed {
    background: rgba(71, 227, 155, 0.12);
    color: var(--accent-green);
}
.badge-defect, .badge-fault, .badge-critical, .badge-overdue, .badge-returned {
    background: rgba(255, 94, 120, 0.12);
    color: var(--accent-red);
}
.badge-offline, .badge-shutdown {
    background: rgba(142, 167, 201, 0.1);
    color: var(--text-dim);
}
.badge-standby {
    background: rgba(142, 167, 201, 0.1);
    color: var(--text-secondary);
}
.badge-discharging, .badge-in_progress, .badge-processing {
    background: rgba(57, 165, 255, 0.12);
    color: var(--accent-blue);
}
.badge-major, .badge-pending {
    background: rgba(255, 181, 72, 0.12);
    color: var(--accent-orange);
}
.badge-minor, .badge-checking {
    background: rgba(167, 139, 250, 0.12);
    color: var(--accent-purple);
}
.badge-info {
    background: rgba(72, 224, 255, 0.12);
    color: var(--accent-cyan);
}

/* ============================================================
   SOC BAR
   ============================================================ */
.soc-bar-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.soc-bar {
    flex: 1;
    height: 7px;
    border-radius: 3px;
    background: rgba(98, 155, 255, 0.1);
    overflow: hidden;
}

.soc-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
    transition: width 1s ease;
}

.soc-text {
    font-family: var(--font-number);
    font-size: 17px;
    font-weight: 700;
    color: var(--accent-cyan);
    min-width: 36px;
    text-align: right;
}

/* ============================================================
   METRIC CARDS
   ============================================================ */
.metric-card-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.metric-card {
    background: var(--panel-bg-gradient);
    border: 1px solid var(--border-glow);
    border-radius: 8px;
    padding: 14px 16px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.3s ease;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--card-color, var(--accent-blue)), transparent);
}

.metric-card:hover {
    border-color: rgba(57, 165, 255, 0.35);
}

.metric-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: rgba(57, 165, 255, 0.08);
    margin-bottom: 8px;
}

.metric-icon svg {
    width: 17px;
    height: 17px;
}

.metric-label {
    font-size: 17px;
    color: var(--text-dim);
    margin-bottom: 5px;
}

.metric-value-row {
    display: flex;
    align-items: baseline;
    gap: 4px;
    min-width: 0;
    overflow: hidden;
}

.metric-value {
    font-family: var(--font-number);
    font-size: 40px;
    font-weight: 700;
    line-height: 1;
    min-width: 0;
    white-space: nowrap;
}

.metric-value.is-dense {
    font-size: 34px;
}

.metric-value.is-extra-dense {
    font-size: 30px;
}

.metric-unit {
    font-size: 17px;
    color: var(--text-dim);
    flex-shrink: 0;
}

/* ============================================================
   CHART CONTAINERS
   ============================================================ */
.chart-container {
    width: 100%;
    height: 100%;
}

/* ============================================================
   ALARM OVERVIEW
   ============================================================ */
.alarm-overview-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.alarm-chart-wrap {
    width: 130px;
    height: 130px;
    flex-shrink: 0;
}

.alarm-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alarm-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 17px;
    color: var(--text-secondary);
}

.alarm-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

.alarm-legend-count {
    margin-left: auto;
    font-family: var(--font-number);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 20px;
}

/* ============================================================
   TASK STATS
   ============================================================ */
.task-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.task-column h4 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(57, 165, 255, 0.1);
}

.stat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 17px;
}

.stat-label {
    color: var(--text-dim);
}

.stat-val {
    font-family: var(--font-number);
    font-weight: 700;
    font-size: 21px;
    color: var(--text-secondary);
}

.stat-val.is-warn { color: var(--accent-orange); }
.stat-val.is-danger { color: var(--accent-red); }
.stat-val.is-info { color: var(--accent-blue); }
.stat-val.is-success { color: var(--accent-green); }

/* ============================================================
   DEVICE & VENDOR
   ============================================================ */
.device-vendor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.device-stats-col {
    display: flex;
    flex-direction: column;
}

.vendor-chart-wrap {
    width: 100%;
    height: 100px;
}

.vendor-legend {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
}

.vendor-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 17px;
    color: var(--text-secondary);
}

.vendor-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

.vendor-legend-count {
    margin-left: auto;
    font-family: var(--font-number);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 20px;
}

/* ============================================================
   FOOTER
   ============================================================ */
.dashboard-footer {
    height: 198px;
    flex-shrink: 0;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
    padding: 8px 0 10px;
}

.footer-panel {
    display: flex;
    flex-direction: column;
}

.footer-panel .panel-content {
    flex: 1;
    padding: 4px 10px 8px;
}

.panel-alert-overview .panel-content,
.panel-task-status .panel-content,
.panel-device-vendor .panel-content {
    padding-top: 4px;
    padding-bottom: 10px;
}

.panel-alert-overview {
    height: 172px;
}

.panel-task-status,
.panel-device-vendor {
    height: 190px;
}

.panel-alert-overview .alarm-chart-wrap {
    width: 112px;
    height: 112px;
}

.panel-alert-overview #alarm-overview-chart {
    width: 112px !important;
    height: 112px !important;
}

.panel-alert-overview .alarm-legend {
    gap: 6px;
}

.panel-alert-overview .alarm-legend-item {
    font-size: 16px;
}

.panel-task-status .task-stats-grid {
    gap: 10px;
}

.panel-task-status .task-column h4 {
    font-size: 16px;
    margin-bottom: 8px;
    padding-bottom: 4px;
}

.panel-task-status .stat-row {
    padding: 2px 0;
    font-size: 16px;
}

.panel-task-status .stat-val {
    font-size: 19px;
}

.panel-device-vendor .device-vendor-grid {
    grid-template-columns: 0.95fr 1.05fr;
    gap: 10px;
}

.panel-device-vendor .vendor-chart-wrap {
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-device-vendor .vendor-legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 8px;
    row-gap: 0;
    margin-top: 0;
}

.panel-device-vendor .stat-row {
    padding: 1px 0;
    font-size: 16px;
}

.panel-device-vendor .stat-val {
    font-size: 19px;
}

.panel-device-vendor #device-type-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 12px;
    row-gap: 0;
    margin-top: 2px !important;
    padding-top: 2px !important;
}

.panel-device-vendor #device-type-stats .stat-row {
    min-width: 0;
}

.panel-device-vendor #device-type-stats .stat-label,
.panel-device-vendor .vendor-legend-item span:nth-child(2) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.panel-device-vendor .vendor-legend-item {
    min-width: 0;
    font-size: 16px;
    align-items: center;
}

.panel-device-vendor .vendor-legend-count {
    font-size: 19px;
}

.panel-device-vendor .device-stats-col:last-child {
    justify-content: flex-start;
    min-width: 0;
}

.panel-device-vendor #vendor-chart {
    width: 100% !important;
    height: 58px !important;
}

.panel-alarm-list {
    min-height: 300px;
}

.panel-alarm-list .panel-content {
    padding-top: 4px;
}

.panel-alarm-list .data-table thead th {
    font-size: 16px;
    padding-top: 7px;
    padding-bottom: 7px;
}

.panel-alarm-list .data-table tbody td {
    font-size: 17px;
    padding-top: 7px;
    padding-bottom: 7px;
}

.panel-alarm-list .table-body-scroll {
    min-height: 220px;
}

/* ============================================================
   ANIMATION ENHANCEMENTS
   ============================================================ */
.panel {
    animation: panelFadeIn 0.8s ease-out both,
               panelGlow 5s ease-in-out infinite alternate;
}

@keyframes panelFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.col-left .panel:nth-child(1) { animation-delay: 0.1s; }
.col-left .panel:nth-child(2) { animation-delay: 0.2s; }
.col-left .panel:nth-child(3) { animation-delay: 0.3s; }
.col-left .panel:nth-child(4) { animation-delay: 0.4s; }
.col-center .panel:nth-child(1) { animation-delay: 0.15s; }
.col-center .panel:nth-child(2) { animation-delay: 0.25s; }
.col-center .panel:nth-child(3) { animation-delay: 0.35s; }
.col-right .panel:nth-child(1) { animation-delay: 0.2s; }
.col-right .panel:nth-child(2) { animation-delay: 0.3s; }
.col-right .panel:nth-child(3) { animation-delay: 0.4s; }
.col-right .panel:nth-child(4) { animation-delay: 0.5s; }
.dashboard-footer .panel:nth-child(1) { animation-delay: 0.5s; }
.dashboard-footer .panel:nth-child(2) { animation-delay: 0.6s; }
.dashboard-footer .panel:nth-child(3) { animation-delay: 0.7s; }

/* ============================================================
   SCROLLBAR (HIDDEN for cleanliness)
   ============================================================ */
.table-body-scroll::-webkit-scrollbar {
    display: none;
}

.table-body-scroll {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .panel {
        animation: none;
    }
    .data-table tbody {
        transition: none;
    }
}
