/* ===============================
   RESET
================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', sans-serif;
}

body {
    background: #f5f6fa;
}

/* ===============================
   LAYOUT
================================ */
.app {
    display: flex;
    height: 100vh;
}

/* ===============================
   SIDEBAR
================================ */
.sidebar {
    width: 240px;
    background: #2f6fed;
    color: #fff;
    padding: 20px;
}

.logo {
    margin-bottom: 30px;
}

.sidebar ul {
    list-style: none;
}

.sidebar li {
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
}

.sidebar li.active,
.sidebar li:hover {
    background: rgba(255,255,255,0.2);
}

/* ===============================
   MAIN
================================ */
.main {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* ===============================
   TOPBAR
================================ */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #2ecc71;
}

/* ===============================
   SUMMARY
================================ */
.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-card {
    color: #fff;
    padding: 20px;
    border-radius: 14px;
}

.summary-card h2 {
    font-size: 32px;
}

.summary-card.green {
    background: linear-gradient(135deg, #3bb54a, #6edc82);
}

/* ===============================
   DEVICE GRID
================================ */
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

/* ===============================
   DEVICE CARD BASE
================================ */
.device-card {
    border-radius: 12px;
    padding: 15px;
    background: #ffffff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    transition: 0.3s;
    cursor: pointer;
}

.device-card h4 {
    margin-bottom: 6px;
    font-size: 15px;
}

.device-card small {
    font-size: 12px;
    color: #555;
}

/* ===============================
   CARD STATUS (FINAL)
================================ */
.device-card.online {
    background: #e8f8ee;
    border-left: 6px solid #2ecc71;
}

.device-card.offline {
    background: #eeeeee;
    border-left: 6px solid #9e9e9e;
    opacity: 0.85;
}

.device-card.critical {
    background: #fdecea;
    border-left: 6px solid #e53935;
    animation: pulse 1.2s infinite;
}

/* ===============================
   METRICS
================================ */
.metrics {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
}

.metric {
    text-align: center;
    font-size: 13px;
}

.metric span {
    display: block;
    font-size: 18px;
    font-weight: bold;
}

/* COLOR LEVEL */
.safe   { color: #2ecc71; }
.warn   { color: #f1c40f; }
.danger { color: #e74c3c; }

/* ===============================
   STATUS TEXT
================================ */
.status {
    margin-top: 10px;
    font-weight: bold;
    font-size: 13px;
}

.status.online  { color: #2ecc71; }
.status.offline { color: #9e9e9e; }

/* ===============================
   BADGE
================================ */
.badge-alert {
    background: #e53935;
    color: #fff;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 6px;
    margin-left: 6px;
}

/* ===============================
   MODAL
================================ */
.modal {
    display: none;
    position: fixed;
    z-index: 999;
    inset: 0;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    background: #fff;
    width: 500px;
    max-height: 80vh;
    margin: 5% auto;
    border-radius: 12px;
    padding: 20px;
    overflow-y: auto;
}

.close {
    float: right;
    font-size: 22px;
    cursor: pointer;
}

/* ===============================
   ANIMATION
================================ */
@keyframes pulse {
    0%   { box-shadow: 0 0 0 rgba(229,57,53,.4); }
    50%  { box-shadow: 0 0 14px rgba(229,57,53,.8); }
    100% { box-shadow: 0 0 0 rgba(229,57,53,.4); }
}


/* ===============================
   MOBILE RESPONSIVE
================================ */
@media (max-width: 768px) {

    .app {
        flex-direction: column;
    }

    /* SIDEBAR OFF-CANVAS */
    .sidebar {
        position: fixed;
        top: 0;
        left: -260px;
        height: 100%;
        width: 240px;
        z-index: 1000;
        transition: 0.3s;
    }

    .sidebar.show {
        left: 0;
    }

    /* MAIN FULL WIDTH */
    .main {
        padding: 15px;
    }

    /* TOPBAR */
    .topbar {
        gap: 10px;
    }

    /* HAMBURGER */
    .menu-btn {
        font-size: 22px;
        cursor: pointer;
        color: #2f6fed;
    }

    /* OVERLAY */
    .overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 999;
    }

    .overlay.show {
        display: block;
    }
}
