/* === Dashboard Overview === */

.dashboard-view {
    height: 100%;
}

/* --- Dashboard Header + Summary --- */

.dashboard-header {
    margin-bottom: 24px;
}

.dashboard-title {
    font-size: 20px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 14px;
}

.dashboard-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.summary-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.75);
}

.summary-pill.usage-pill {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-muted);
}

.summary-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.summary-dot.total {
    background: rgba(255, 255, 255, 0.25);
}

.summary-dot.online {
    background: var(--success-color);
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.4);
}

.summary-dot.attemp {
    background: var(--warning-color);
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.35);
}

.summary-dot.fault {
    background: var(--danger-color);
    box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

/* --- Chart Section --- */

.dashboard-chart-container {
    margin-bottom: 28px;
}

.dashboard-section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.dashboard-chart {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    height: 260px;
    position: relative;
}

/* --- Empty State --- */

.dashboard-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    gap: 12px;
}

.dashboard-empty svg {
    opacity: 0.25;
    margin-bottom: 4px;
}

.dashboard-empty-hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.3);
}

/* --- Card Grid --- */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

/* --- Device Card --- */

.dash-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    max-width: 420px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.dash-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(22, 22, 27, 1);
}

.dash-card.offline {
    opacity: 0.7;
}

.dash-card.offline:hover {
    opacity: 0.85;
}

/* --- Card Header --- */

.dash-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.dash-card-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.dash-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dash-dot.online {
    background: var(--success-color);
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.4);
}

.dash-dot.offline {
    background: rgba(255, 255, 255, 0.15);
}

.dash-card-name {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Machine State Badge --- */

.dash-state {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 10px;
    border-radius: 4px;
    flex-shrink: 0;
    margin-left: 12px;
}

.dash-state.normal {
    background: rgba(34, 197, 94, 0.12);
    color: var(--success-color);
}

.dash-state.standby {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning-color);
}

.dash-state.cooling {
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
}

.dash-state.offline,
.dash-state.unknown {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

/* --- Fault Banner --- */

.dash-fault {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--danger-color);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* --- Heater Row --- */

.dash-heater-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.dash-heater {
    text-align: center;
}

.dash-heater-name {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.dash-heater-temp {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    font-weight: 500;
    color: #fff;
    line-height: 1.3;
}

.dash-heater-target {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    font-family: 'JetBrains Mono', monospace;
}

/* --- Heater Progress Bar --- */

.dash-heater-progress {
    height: 3px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 2px;
    margin: 4px auto 2px;
    width: 80%;
    overflow: hidden;
}

.dash-heater-progress-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.4s ease;
}

.dash-heater-progress-fill.temp-off       { background: rgba(255, 255, 255, 0.08); }
.dash-heater-progress-fill.temp-heating    { background: var(--warning-color); }
.dash-heater-progress-fill.temp-at-target  { background: var(--success-color); }
.dash-heater-progress-fill.temp-fault      { background: var(--danger-color); }
.dash-heater-progress-fill.temp-cooling    { background: #38bdf8; }

/* Temperature state colors */

.temp-off      { color: var(--text-muted); }
.temp-heating  { color: var(--warning-color); }
.temp-at-target { color: var(--success-color); }
.temp-fault    { color: var(--danger-color); }
.temp-cooling  { color: #38bdf8; }

/* --- Offline / Waiting Placeholder --- */

.dash-placeholder {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 24px 0 16px;
}

/* --- Card Footer --- */

.dash-card-footer {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    margin-top: 4px;
}

.dash-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.dash-soak-badge {
    font-size: 11px;
    font-weight: 600;
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 4px 10px;
    border-radius: 4px;
}

.dash-soak-badge.inactive {
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.25);
}

.dash-soak-badge.heating {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning-color);
}

.dash-soak-badge.ready {
    background: rgba(34, 197, 94, 0.12);
    color: var(--success-color);
}

.dash-usage-today {
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-muted);
    white-space: nowrap;
}

.dash-uptime,
.dash-last-used {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
    white-space: nowrap;
}

.dash-card-footer-offline {
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
}

.dash-offline-detail {
    font-size: 12px;
    color: var(--text-muted);
}

/* --- Sparkline (7-day mini bars) --- */

.dash-sparkline {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 32px;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.spark-bar-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
    gap: 2px;
}

.spark-bar {
    width: 100%;
    max-width: 24px;
    min-height: 2px;
    background: var(--primary-color);
    border-radius: 2px 2px 0 0;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.dash-card:hover .spark-bar {
    opacity: 0.85;
}

.spark-label {
    font-size: 8px;
    color: rgba(255, 255, 255, 0.25);
    font-family: 'JetBrains Mono', monospace;
    text-transform: uppercase;
}

/* --- Sidebar Dashboard Button --- */

.btn-dashboard {
    display: block;
    width: calc(100% - 16px);
    margin: 8px auto 4px;
    padding: 8px 12px;
    background: rgba(167, 78, 158, 0.08);
    border: 1px solid rgba(167, 78, 158, 0.2);
    color: var(--primary-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    text-align: left;
    transition: background 0.2s, border-color 0.2s;
}

.btn-dashboard:hover {
    background: rgba(167, 78, 158, 0.15);
    border-color: rgba(167, 78, 158, 0.35);
}

/* --- Responsive --- */

@media (max-width: 768px), (orientation: landscape) and (max-height: 500px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .dash-card {
        padding: 16px;
        max-width: none;
    }

    .dash-heater-temp {
        font-size: 14px;
    }

    .dashboard-summary {
        flex-direction: column;
        align-items: stretch;
    }

    .summary-pill {
        justify-content: center;
    }

    .dashboard-chart {
        height: 280px;
    }
}

/* --- Portrait phone: heaters in 2x2 for readability --- */

@media (max-width: 768px) and (orientation: portrait) {
    .dash-heater-row {
        grid-template-columns: 1fr 1fr;
        row-gap: 12px;
    }
}

/* --- Landscape phone: short viewport, compact cards --- */

@media (orientation: landscape) and (max-height: 500px) {
    .dash-card {
        padding: 12px 14px;
    }

    .dashboard-chart {
        height: 220px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* --- Very small phones: drop sparkline labels, bars only --- */

@media (max-width: 374px) {
    .spark-label {
        display: none;
    }

    .dash-sparkline {
        height: 24px;
    }
}
