/* ===== Minimal IoT Design System ===== */
:root {
    /* Colors */
    --bg-color: #ffffff;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --accent-blue: #2563eb;
    --status-green: #10b981;
    --status-red: #ef4444;
    --border-color: #e5e7eb;

    /* Shadows & Radius */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Typography */
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: #f9fafb;
    /* Extremely subtle grey for page bg to make white cards pop */
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Layout ===== */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 24px 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 32px;
    border: 1px solid var(--border-color);
}

.header-content h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.025em;
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.header-icon {
    width: 48px;
    height: 48px;
    background: #eff6ff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-blue);
    font-size: 20px;
}

/* ===== Dashboard Grid ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.card-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-icon {
    color: var(--text-tertiary);
    font-size: 18px;
}

.card-body {
    flex: 1;
}

.center-align {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Values & Data ===== */
.value-container {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.value-large {
    font-size: 48px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -0.03em;
}

.value-medium {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -0.025em;
}

.unit {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-tertiary);
}

/* ===== Specific Components ===== */

/* Progress Bar */
.progress-bar-container {
    width: 100%;
    height: 10px;
    background: #eff6ff;
    border-radius: 10px;
    margin-top: 16px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent-blue);
    border-radius: 10px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-footer {
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* Status Badges */
.status-badge {
    padding: 8px 24px;
    border-radius: 99px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.025em;
}

.status-on {
    background: #dcfce7;
    color: #15803d;
}

.status-off {
    background: #fee2e2;
    color: #b91c1c;
}

.status-safe {
    background: #dcfce7;
    color: #15803d;
}

.status-leak {
    background: #fee2e2;
    color: #b91c1c;
    animation: pulse-red 2s infinite;
}

/* Interactive Badge */
#motorStatus {
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

#motorStatus:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#motorStatus:active {
    transform: scale(0.95);
}

@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Time Display */
.time-display {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* ===== Footer ===== */
.app-footer {
    text-align: center;
    padding: 24px;
    color: var(--text-tertiary);
    font-size: 13px;
    font-weight: 500;
    margin-top: auto;
}

/* ===== Analytics Grid ===== */
.section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
    padding-left: 4px;
}

.analytics-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 32px;
}

.wide-card {
    /* Takes up more space */
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-filter {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 13px;
    font-family: var(--font-family);
    outline: none;
    cursor: pointer;
}

/* ===== Responsiveness ===== */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

@media (max-width: 640px) {
    .main-container {
        padding: 16px;
    }

    .app-header {
        flex-direction: column;
        text-align: center;
        padding: 20px;
        gap: 16px;
    }

    .header-icon {
        display: none;
    }

    .header-content h1 {
        font-size: 20px;
    }

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

    .value-large {
        font-size: 40px;
    }
}