﻿html, body {
    height: 100%;
}

body {
    display: inline-block;
    align-items: center;
    justify-content: center;
    position: relative;
    background: linear-gradient(135deg, rgba(#242e4d, .9), rgba(#897e79, .9));
    font-family: DroidSans, Droid Sans, Verdana;
}

.dashboard-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh; /* Must be 100% of the viewport */
    width: 100vw;
    overflow: hidden;
}

input[type=text] {
    min-width: 500px;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-size:large;
}

select {
    padding: 5px;
    border-radius: 8px;
    border: 1px solid #ccc;    
    color:gray;
}

.scrollable-area {
    flex: 1 1 auto; /* Grow and shrink as needed */
    overflow-y: auto;
    min-height: 0; /* Critical fix for flexbox height issues */
}

.graph-section {
    /*flex: 0 0 300px;*/ /* Do not grow, do not shrink, stay exactly 300px */
    height: 300px;
    width: 100%;
    background: white;
    position: relative;
    resize: both;
    overflow: auto;
    border: 1px solid #ccc;
}

#usageChart {
    width: 100% !important;
    height: 300px !important; /* Explicitly set here as well */
}

.controls-section input[type=text], .controls-section select{
    font-family: DroidSans, Droid Sans, Verdana;
}

.deviceContainer {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    padding: 20px;
}

.device-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.2s;
}

    .device-card:hover {
        transform: translateY(-5px);
    }

    /* Color coding by Device Type */
    .device-card.electricity {
        border-top: 5px solid #FFC000;
    }

    .device-card.water {
        border-top: 5px solid #5B9BD5;
    }

    .device-card.gas {
        border-top: 5px solid #ED7D31;
    }

    .device-card.hotwater {
        border-top: 5px solid #70AD47;
    }

.card-header {
    padding: 0 10px;
    background: #f8f9fa;
}

.badge {
    font-size: 10px;
    text-transform: uppercase;
    background: #ddd;
    padding: 2px 6px;
    border-radius: 4px;
}

.main-stat {
    text-align: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

    .main-stat .value {
        font-size: 1.5rem;
        font-weight: bold;
        color: #333;
    }

.sub-detail {
    padding: 10px 0;
    font-size: x-small;
}

.stats-row {
    display: flex;
    justify-content: space-around;
    padding: 15px;
    background: #fafafa;
}

    .stats-row label {
        display: block;
        font-size: 11px;
        color: #666;
    }

.card-footer {
    padding: 10px 15px;
    background: #eee;
    font-size: 11px;
}

.status-indicator {
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
    text-transform: uppercase;
}

.dot {
    height: 8px;
    width: 8px;
    border-radius: 50%;
    display: inline-block;
    /* Optional: add a pulse effect for online devices */
}

    /* Optional: Make the Green dot pulse */
    .dot[style*="#28a745"] {
        box-shadow: 0 0 0 rgba(40, 167, 69, 0.4);
        animation: pulse 2s infinite;
    }

.btn {
    padding: 10px 20px;
    border: 2px solid cadetblue;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
    font-family: inherit;
}


@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 5px rgba(40, 167, 69, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}


/* Mobile Styles (Screen width < 768px) */
@media (max-width: 767px) {

    input[type=text] {
        margin-top: 5px;
        margin-bottom: 5px;
        font-size: 0.8em;
        padding: 5px;
        min-width: 240px;
    }

    select {
        font-size: 0.6em;
        padding: 5px;
        height: 30px;
    }

    .deviceContainer {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto; /* Horizontal scrolling for cards */
        padding: 10px;
        gap: 10px;
        -webkit-overflow-scrolling: touch;
    }

    .device-card {
        flex: 0 0 140px; /* Fixed width cards */
        padding: 8px;
        margin-bottom: 0;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        font-size: 0.85rem;
    }

    .device-card-disabled {
        background: #f9f9f9;
        filter: grayscale(1);
    }

    .color-indicator {
        width: 20px;
        height: 4px;
        border-radius: 2px;
        margin-bottom: 8px;
    }

    .device-name-sm {
        font-size: 0.9em;
        color: #888;
        text-transform: uppercase;
        display: block;
        margin-bottom: 5px;
    }

    .usage-value-sm {
        font-size: 1.0em;
        font-weight: 700;
        color: #333;
    }

    /* Container for horizontal scrolling on mobile */
    .device-row {
        display: flex;
        overflow-x: auto;
        gap: 12px;
        padding: 10px 5px;
        scrollbar-width: none; /* Hide scrollbar Firefox */
    }

        .device-row::-webkit-scrollbar {
            display: none;
        }
    /* Hide scrollbar Chrome/Safari */

    .card-header-top {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 5px;
        width: 100%;
    }

    .device-type {
        font-size: 9px;
        font-weight: 800;
        text-transform: uppercase;
        color: #95a5a6;
        letter-spacing: 0.5px;
    }

    .device-status {
        font-size: 9px;
        color: #7f8c8d;
        display: flex;
        align-items: center;
        gap: 4px;
        text-transform:uppercase;
    }

    .status-dot {
        height: 6px;
        width: 6px;
        border-radius: 50%;
        display: inline-block;
    }
}

