/* =============================================================================
   BMS Detail Page — JK Battery Management System
   ============================================================================= */

.bms-page {
    max-width: 1300px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.bms-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 12px;
}

.bms-header-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bms-header h1 {
    font-size: 1.6rem;
    margin: 0;
}

.back-link {
    color: #4ecdc4;
    text-decoration: none;
    font-size: 0.9rem;
}

.back-link:hover {
    text-decoration: underline;
}

.bms-connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.bms-connection-status .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #666;
}

.bms-connection-status.connected .dot {
    background: var(--accent-green);
}

.bms-connection-status.disconnected .dot {
    background: var(--accent);
}

/* Two-pack layout */
.bms-packs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 900px) {
    .bms-packs-grid {
        grid-template-columns: 1fr;
    }
}

/* Pack card */
.bms-pack-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 20px;
    border: 1px solid var(--border-color);
}

.bms-pack-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.bms-pack-title h2 {
    font-size: 1.1rem;
    margin: 0;
}

.bms-pack-badge {
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 20px;
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.bms-pack-badge.has-data {
    background: rgba(0, 210, 106, 0.15);
    color: var(--accent-green);
}

/* Stats grid */
.bms-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.bms-stat {
    background: var(--bg-hover);
    border-radius: 8px;
    padding: 10px 12px;
    text-align: center;
}

.bms-stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #4ecdc4;
    line-height: 1.2;
}

.bms-stat-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* SOC gets special colour */
.bms-stat.soc .bms-stat-value { color: #66bb6a; }
.bms-stat.power .bms-stat-value { color: #f0a830; }
.bms-stat.current .bms-stat-value { color: #4ecdc4; }
.bms-stat.voltage .bms-stat-value { color: #7986cb; }
.bms-stat.temp .bms-stat-value { color: #ff8a65; }
.bms-stat.cycles .bms-stat-value { color: #a0a0a0; }

/* Cell voltage section */
.bms-cells-section {
    margin-bottom: 16px;
}

.bms-cells-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.bms-spread-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.bms-spread-badge.warn {
    background: rgba(255, 193, 7, 0.2);
    color: var(--accent-yellow);
}

.bms-spread-badge.danger {
    background: rgba(233, 69, 96, 0.2);
    color: var(--accent);
}

.bms-chart-container {
    position: relative;
    height: 160px;
}

/* Cell table (no-JS fallback + small screens) */
.bms-cell-table-wrapper {
    overflow-x: auto;
    margin-top: 10px;
}

.bms-cell-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.bms-cell-table th,
.bms-cell-table td {
    padding: 4px 8px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.bms-cell-table th {
    color: var(--text-secondary);
    font-weight: 500;
}

.bms-cell-table td.low { color: var(--accent); }
.bms-cell-table td.high { color: var(--accent-yellow); }
.bms-cell-table td.ok { color: var(--accent-green); }

/* Balancing / status section */
.bms-status-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.bms-status-pill {
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.bms-status-pill.active {
    background: rgba(0, 210, 106, 0.15);
    color: var(--accent-green);
    border-color: rgba(0, 210, 106, 0.3);
}

.bms-status-pill.warn {
    background: rgba(255, 193, 7, 0.15);
    color: var(--accent-yellow);
    border-color: rgba(255, 193, 7, 0.3);
}

.bms-status-pill.error {
    background: rgba(233, 69, 96, 0.15);
    color: var(--accent);
    border-color: rgba(233, 69, 96, 0.3);
}

/* Waiting for data */
.bms-no-data {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.bms-no-data .bms-no-data-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

/* Light theme overrides */
[data-theme="light"] .bms-pack-card {
    background: var(--bg-card);
    box-shadow: var(--shadow);
}

[data-theme="light"] .bms-stat {
    background: var(--bg-hover);
}
