/* ─────────────────────────────────────────────────────────────────────────────
   Energy Dashboard – Design System v2 (matches plant_detail responsive.css)
   ───────────────────────────────────────────────────────────────────────────── */

/* ── Summary two-col (doughnut + manual meters) ─────────────────────────── */
.energy-summary-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}
@media (min-width: 768px)  { .energy-summary-grid { grid-template-columns: 1fr 1fr; gap: 1.5rem; } }
@media (min-width: 1280px) { .energy-summary-grid { gap: 2rem; } }

/* ── Manual readings two-col ─────────────────────────────────────────────── */
.energy-manual-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
@media (min-width: 640px)  { .energy-manual-grid { grid-template-columns: 1fr 1fr; gap: 1.25rem; } }
@media (min-width: 1280px) { .energy-manual-grid { gap: 1.5rem; } }

/* ── Meter mini-KPI row (4 tiles) ────────────────────────────────────────── */
.energy-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.625rem;
}
@media (min-width: 640px)  { .energy-metrics-grid { grid-template-columns: repeat(4, 1fr); gap: 0.875rem; } }
@media (min-width: 1280px) { .energy-metrics-grid { gap: 1.125rem; } }

.energy-metric-tile {
    border-radius: 0.875rem;
    padding: 0.875rem 1rem;
    border: 1px solid #f1f5f9;
}
@media (min-width: 768px)  { .energy-metric-tile { padding: 1rem 1.25rem; } }
@media (min-width: 1280px) { .energy-metric-tile { padding: 1.125rem 1.375rem; border-radius: 1rem; } }

.energy-metric-label {
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.375rem;
}
@media (min-width: 768px) { .energy-metric-label { font-size: 10px; } }

.energy-metric-value {
    font-size: 1rem;
    font-weight: 900;
    line-height: 1.2;
    letter-spacing: -0.02em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@media (min-width: 768px)  { .energy-metric-value { font-size: 1.125rem; } }
@media (min-width: 1280px) { .energy-metric-value { font-size: 1.25rem; } }

/* ── Tech details grid ───────────────────────────────────────────────────── */
.energy-tech-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-top: 0.875rem;
}
@media (min-width: 640px) { .energy-tech-grid { grid-template-columns: repeat(3, 1fr); } }

/* ── Charts row ──────────────────────────────────────────────────────────── */
.energy-charts-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin-top: 1.25rem;
}
@media (min-width: 900px)  { .energy-charts-row { grid-template-columns: 2fr 1fr; gap: 1.5rem; } }
@media (min-width: 1280px) { .energy-charts-row { gap: 2rem; margin-top: 1.5rem; } }

.energy-chart-box {
    position: relative;
    height: 200px;
    width: 100%;
}
@media (min-width: 768px)  { .energy-chart-box { height: 240px; } }
@media (min-width: 1280px) { .energy-chart-box { height: 280px; } }

/* ── Chart tabs ──────────────────────────────────────────────────────────── */
.energy-chart-tab-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: #f8fafc;
    padding: 3px;
    border-radius: 8px;
    border: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.energy-chart-tab {
    padding: 3px 10px;
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    background: transparent;
    transition: all 0.15s;
    white-space: nowrap;
}
.energy-chart-tab:hover { color: #475569; background: #fff; }
.energy-chart-tab.active {
    background: #fff;
    color: #4f46e5;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* ── Doughnut container ──────────────────────────────────────────────────── */
.energy-pie-container { height: 180px; }
@media (min-width: 640px)  { .energy-pie-container { height: 200px; } }
@media (min-width: 1280px) { .energy-pie-container { height: 220px; } }

/* ── Big total consumption number ────────────────────────────────────────── */
.consumption-summary-value {
    font-size: 1.75rem;
    font-weight: 900;
    letter-spacing: -0.04em;
    line-height: 1;
}
@media (min-width: 768px)  { .consumption-summary-value { font-size: 2.25rem; } }
@media (min-width: 1280px) { .consumption-summary-value { font-size: 2.75rem; } }

/* ── History modal ───────────────────────────────────────────────────────── */
.history-modal-card { max-width: 48rem; }
.energy-table-container { overflow-x: auto; max-height: 420px; overflow-y: auto; }

/* ── Voltage History Section ─────────────────────────────────────────────── */
.voltage-history-section {
    margin-top: 2rem;
    padding-top: 1.75rem;
    border-top: 2px solid #f1f5f9;
}
@media (min-width: 768px) { .voltage-history-section { margin-top: 2.5rem; padding-top: 2rem; } }

/* ── Section header ──────────────────────────────────────────────────────── */
.voltage-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 1.25rem;
}

.voltage-icon-box {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(14,165,233,0.35);
}

.voltage-section-title {
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #0f172a;
    line-height: 1.2;
}
.voltage-section-sub {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    margin-top: 1px;
}

/* ── Controls row: pills + date range side-by-side on desktop ────────────── */
.voltage-controls-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 1.25rem;
}
@media (min-width: 960px) {
    .voltage-controls-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

/* ── Pill group ──────────────────────────────────────────────────────────── */
.vpill-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* ── Pill buttons (toggle chips) ─────────────────────────────────────────── */
.vpill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 13px;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    border-radius: 7px;
    border: 1.5px solid #e2e8f0;
    cursor: pointer;
    color: #64748b;
    background: #f8fafc;
    transition: background 0.18s, border-color 0.18s, color 0.18s, box-shadow 0.18s;
    white-space: nowrap;
    user-select: none;
    line-height: 1;
}
.vpill:hover {
    border-color: #cbd5e1;
    color: #475569;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.vpill-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    opacity: 0.2;
    transition: opacity 0.18s, transform 0.18s;
}
.vpill-label { line-height: 1; }

/* Active state – dark chip with colored dot prominent */
.vpill--active {
    background: #0f172a;
    border-color: #0f172a;
    color: #f8fafc;
    box-shadow: 0 2px 8px rgba(15,23,42,0.22);
}
.vpill--active .vpill-dot {
    opacity: 1;
    transform: scale(1.15);
}
.vpill--active:hover {
    background: #1e293b;
    border-color: #1e293b;
    color: #fff;
}

/* ── Date-range control bar ──────────────────────────────────────────────── */
.voltage-date-ctrl {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1.5px solid #f1f5f9;
    border-radius: 10px;
    padding: 8px 12px;
    flex-wrap: nowrap;
}
/* Allow wrapping only on narrow screens */
@media (max-width: 639px) { .voltage-date-ctrl { flex-wrap: wrap; } }

.vdate-group {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.vdate-lbl {
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #94a3b8;
    white-space: nowrap;
}

.vdate-sep {
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
    padding: 0 2px;
}

.vdate-input {
    padding: 5px 9px;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    border: 1.5px solid #e2e8f0;
    border-radius: 7px;
    background: #fff;
    color: #334155;
    outline: none;
    width: 124px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.vdate-input:focus {
    border-color: #a5b4fc;
    box-shadow: 0 0 0 3px rgba(79,70,229,0.08);
}

.vtime-input {
    padding: 5px 7px;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    border: 1.5px solid #e2e8f0;
    border-radius: 7px;
    background: #fff;
    color: #64748b;
    outline: none;
    width: 74px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.vtime-input:focus {
    border-color: #a5b4fc;
    box-shadow: 0 0 0 3px rgba(79,70,229,0.08);
}

.vapply-btn {
    padding: 7px 16px;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-radius: 7px;
    border: none;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    box-shadow: 0 1px 4px rgba(79,70,229,0.35);
    transition: background 0.15s, box-shadow 0.15s, transform 0.12s;
    white-space: nowrap;
    flex-shrink: 0;
}
.vapply-btn:hover {
    background: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
    box-shadow: 0 3px 10px rgba(79,70,229,0.45);
    transform: translateY(-1px);
}
.vapply-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(79,70,229,0.25);
}

/* ── Voltage chart wrapper + loader ─────────────────────────────────────── */
.voltage-chart-wrap {
    position: relative;
    height: 280px;
    width: 100%;
    border-radius: 0.75rem;
    overflow: hidden;
    background: #fafbfc;
    border: 1px solid #f1f5f9;
}
@media (min-width: 768px)  { .voltage-chart-wrap { height: 320px; } }
@media (min-width: 1280px) { .voltage-chart-wrap { height: 370px; } }

/* Keep backward-compat alias used in JS error overlay */
.voltage-chart-box {
    position: relative;
    height: 280px;
    width: 100%;
}
@media (min-width: 768px)  { .voltage-chart-box { height: 320px; } }
@media (min-width: 1280px) { .voltage-chart-box { height: 370px; } }

/* Loader overlay */
.voltage-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(250,251,252,0.9);
    z-index: 5;
    border-radius: 0.75rem;
}
.voltage-loader.hidden { display: none; }

.voltage-loader-ring {
    width: 28px;
    height: 28px;
    border: 3px solid #e2e8f0;
    border-top-color: #0ea5e9;
    border-radius: 50%;
    animation: vloader-spin 0.75s linear infinite;
}
@keyframes vloader-spin { to { transform: rotate(360deg); } }

/* ── Error overlay ───────────────────────────────────────────────────────── */
.error-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255,255,255,0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #b91c1c;
    font-size: 12px;
    font-weight: 900;
    text-align: center;
    padding: 20px;
    z-index: 10;
    border-radius: 0.5rem;
}
