/* ═══════════════════════════════════════════════════════════════════════════
   SleepGuardian — Environment Sensor Styles
   Covers the dashboard environment card, insights, and analytics view.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Dashboard Environment Card ───────────────────────────────────────────── */

.env-metrics {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: var(--space-md);
}

.env-metric-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.env-metric-row:hover {
    background: rgba(255, 255, 255, 0.06);
}

.env-metric-icon {
    font-size: 1.3rem;
    width: 32px;
    text-align: center;
    flex-shrink: 0;
}

.env-metric-info {
    flex: 1;
    min-width: 0;
}

.env-metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.env-metric-value {
    font-size: 1.1rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

.env-metric-range {
    font-size: 0.7rem;
    color: var(--text-dim);
    margin-left: 6px;
}

/* Status badges */
.env-status {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 99px;
    letter-spacing: 0.03em;
    flex-shrink: 0;
}

.env-status-optimal {
    background: rgba(105, 240, 174, 0.15);
    color: var(--good);
}

.env-status-warning {
    background: rgba(255, 209, 102, 0.15);
    color: var(--fair);
}

.env-status-poor {
    background: rgba(239, 83, 80, 0.15);
    color: var(--poor);
}

.env-status-info {
    background: rgba(124, 77, 255, 0.12);
    color: var(--primary-light);
}

/* Environment score badge in card */
.env-score-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm) var(--space-md);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.env-score-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.1), rgba(105, 240, 174, 0.1));
}

.env-score-value {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.env-score-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ── Sleep Insights ───────────────────────────────────────────────────────── */

.sleep-insights {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.insight-card {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid;
    animation: slideUp 0.3s ease-out forwards;
    opacity: 0;
}

.insight-card:nth-child(1) { animation-delay: 100ms; }
.insight-card:nth-child(2) { animation-delay: 200ms; }
.insight-card:nth-child(3) { animation-delay: 300ms; }

.insight-tip { border-left-color: var(--good); }
.insight-warn { border-left-color: var(--fair); }
.insight-alert { border-left-color: var(--poor); }

.insight-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.insight-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.insight-text strong {
    color: var(--text-primary);
}

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

/* ── Environment Analytics View ───────────────────────────────────────────── */

.env-analytics {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.env-analytics .settings-header {
    margin-bottom: 0;
}

.env-comfort-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-md);
}

.env-comfort-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.env-comfort-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.env-comfort-icon {
    font-size: 1.5rem;
}

.env-comfort-pct {
    font-size: 1.6rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.env-comfort-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.env-comfort-value {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Trend chart container */
.env-trend-chart {
    position: relative;
    height: 300px;
}

.env-trend-chart canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Empty state */
.env-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 250px;
    gap: var(--space-sm);
    text-align: center;
    color: var(--text-muted);
}

.env-empty-icon {
    font-size: 3rem;
    opacity: 0.5;
}

/* ── Dashboard Grid Extension ─────────────────────────────────────────────── */

.dash-environment {
    grid-column: 1 / -1;
}

.dash-insights {
    grid-column: 1 / -1;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .env-comfort-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .env-trend-chart {
        height: 220px;
    }

    .env-metric-range {
        display: none;
    }
}

@media (max-width: 480px) {
    .env-comfort-grid {
        grid-template-columns: 1fr 1fr;
    }
}
