﻿/* ===========================================================
   WebApp Device Sensors
   Dashboard
=========================================================== */

:root {
    --primary: #2563eb;
    --primary-light: #dbeafe;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-100: #f8fafc;
    --gray-200: #eef2f7;
    --gray-300: #d9e2ec;
    --gray-500: #64748b;
    --gray-700: #334155;
    --gray-900: #0f172a;
    --shadow: 0 10px 25px rgba(15,23,42,.06);
    --radius: 18px;
    --transition: .25s;
}

/* ---------------------------------------------------------- */

body {
    background: #f4f7fb;
    color: var(--gray-900);
    font-family: "Segoe UI", sans-serif;
}

/* ---------------------------------------------------------- */

.dashboard-page {
    max-width: 1600px;
    margin: auto;
    padding: 35px;
}

/* ---------------------------------------------------------- */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

    .topbar h1 {
        font-size: 34px;
        font-weight: 700;
        margin: 0;
    }

.subtitle {
    color: var(--gray-500);
    margin-top: 8px;
    font-size: 15px;
}

.customer {
    margin-left: 20px;
}

/* ---------------------------------------------------------- */

.header-buttons {
    display: flex;
    gap: 12px;
}

/* ---------------------------------------------------------- */

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 35px;
    flex-wrap: wrap;
}

/* ---------------------------------------------------------- */

.search {
    width: 420px;
    max-width: 100%;
    display: flex;
    align-items: center;
    background: white;
    border-radius: 50px;
    box-shadow: var(--shadow);
    padding: 14px 18px;
}

    .search i {
        color: var(--gray-500);
        font-size: 20px;
    }

    .search input {
        border: none;
        outline: none;
        width: 100%;
        margin-left: 12px;
        font-size: 16px;
        background: transparent;
    }

/* ---------------------------------------------------------- */

.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter {
    border: none;
    border-radius: 30px;
    padding: 10px 20px;
    background: white;
    transition: .25s;
    font-weight: 600;
    box-shadow: var(--shadow);
}

    .filter:hover {
        transform: translateY(-2px);
    }

    .filter.active {
        background: var(--primary);
        color: white;
    }

    .filter.success {
        color: var(--success);
    }

    .filter.warning {
        color: var(--warning);
    }

    .filter.danger {
        color: var(--danger);
    }

/* ---------------------------------------------------------- */

.master-card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    overflow: hidden;
    transition: .30s;
}

    .master-card:hover {
        transform: translateY(-3px);
    }

/* ---------------------------------------------------------- */

.master-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 1px solid var(--gray-200);
}

.master-title {
    font-size: 22px;
    font-weight: 700;
}

    .master-title i {
        color: var(--primary);
        margin-right: 10px;
    }

.master-id {
    color: var(--gray-500);
    margin-top: 6px;
    font-size: 14px;
}

/* ---------------------------------------------------------- */

.device-table {
    width: 100%;
    border-collapse: collapse;
}

    .device-table thead {
        background: #f8fafc;
    }

    .device-table th {
        padding: 18px;
        color: var(--gray-700);
        font-weight: 700;
        text-transform: uppercase;
        font-size: 13px;
    }

    .device-table td {
        padding: 18px;
        border-top: 1px solid var(--gray-200);
        vertical-align: middle;
    }

    .device-table tbody tr {
        transition: .25s;
    }

        .device-table tbody tr:hover {
            background: #f7fbff;
        }

/* ---------------------------------------------------------- */

.icon {
    width: 45px;
    text-align: center;
}

    .icon i {
        color: var(--primary);
        font-size: 20px;
    }

/* ---------------------------------------------------------- */

.device-name {
    font-weight: 600;
}

.device-id {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 3px;
}

/* ---------------------------------------------------------- */

.status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* ONLINE */

.status.online {
    color: var(--success);
}

    .status.online .pulse {
        background: var(--success);
        animation: pulseGreen 2s infinite;
    }

/* OFFLINE */

.status.offline {
    color: var(--warning);
}

    .status.offline .pulse {
        background: var(--warning);
    }

/* ALLARME */

.status.allarme {
    color: var(--danger);
}

    .status.allarme .pulse {
        background: var(--danger);
        animation: pulseRed 1.2s infinite;
    }

/* ---------------------------------------------------------- */

/* ==========================================================
   BATTERY RESPONSIVE
========================================================== */

.battery {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 150px;
}


.battery-progress {
    flex: 1;
    height: 10px;
    border-radius: 20px;
    overflow: hidden;
    background: #e5e7eb;
    min-width: 40px;
}


.battery-fill {
    height: 100%;
    border-radius: 20px;
    transition: width .5s ease;
}

.good {
    background: var(--success);
}

.medium {
    background: var(--warning);
}

.low {
    background: var(--danger);
}

/* ---------------------------------------------------------- */

.badge {
    padding: 8px 14px;
    border-radius: 30px;
    font-weight: 600;
}

/* ---------------------------------------------------------- */

@keyframes pulseGreen {

    0% {
        box-shadow: 0 0 0 0 rgba(16,185,129,.45);
    }

    70% {
        box-shadow: 0 0 0 8px rgba(16,185,129,0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16,185,129,0);
    }
}

@keyframes pulseRed {

    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.35);
    }

    100% {
        transform: scale(1);
    }
}

/* ---------------------------------------------------------- */

@media(max-width:992px) {

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search {
        width: 100%;
    }
}

/* ---------------------------------------------------------- */

@media(max-width:768px) {

    .dashboard-page {
        padding: 15px;
    }


    .master-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }


    .device-table {
        min-width: 0 !important;
        width: 100%;
    }
}
/* ===========================================================
   Logout Button
=========================================================== */

.logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    border: none;
    background: white;
    color: #ef4444;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(15,23,42,.08);
    transition: .25s;
}


    .logout-btn i {
        font-size: 18px;
    }


    .logout-btn:hover {
        background: #ef4444;
        color: white;
        transform: translateY(-2px);
        box-shadow: 0 12px 25px rgba(239,68,68,.25);
    }

.refresh-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: white;
    color: #2563eb;
    font-weight: 600;
    padding: 12px 18px;
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(15,23,42,.08);
    transition: .25s;
}


    .refresh-btn i {
        font-size: 18px;
    }


    .refresh-btn:hover {
        background: #2563eb;
        color: white;
        transform: translateY(-2px);
    }



    .refresh-btn.loading i {
        animation: rotateRefresh 1s linear infinite;
    }



@keyframes rotateRefresh {

    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================
   MOBILE DEVICE VIEW
========================================================== */

@media(max-width:768px) {

    .dashboard-page {
        padding: 16px;
    }

    /* HEADER */

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 18px;
    }

        .topbar h1 {
            font-size: 28px;
        }

    .subtitle {
        margin-top: 6px;
    }

    .customer {
        display: block;
        margin: 6px 0 0 0;
    }

    .header-buttons {
        width: 100%;
        display: flex;
        gap: 10px;
    }

    .refresh-btn,
    .logout-btn {
        flex: 1;
        justify-content: center;
    }

    /* TOOLBAR */

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .search {
        width: 100%;
    }

    .filters {
        justify-content: space-between;
    }

    .filter {
        flex: 1;
        text-align: center;
        padding: 10px;
        font-size: 14px;
    }

    /* MASTER */

    .master-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding: 22px;
    }

    .master-title {
        font-size: 18px;
    }

    .master-info {
        width: 100%;
    }

        .master-info .badge {
            width: 100%;
        }

    /* TABLE */

    .table-responsive {
        overflow: visible;
        padding: 0;
        background: transparent;
    }

    .device-table {
        width: 100%;
        min-width: 0 !important;
        background: transparent;
    }

        .device-table thead {
            display: none;
        }

        .device-table,
        .device-table tbody {
            display: flex;
            flex-direction: column;
            gap: 16px;
            padding: 12px;
            background: transparent;
        }
        .device-table tr,
        .device-table td {
            display: block;
            width: 100%;
        }

            .device-table tbody {
                display: flex;
                flex-direction: column;
                gap: 16px;
                padding: 16px;
                background: transparent;
            }
            .device-table tr {
                margin: 0 auto;
                width: calc(100% - 16px);
                box-sizing: border-box;
                background: #ffffff;
                border-radius: 18px;
                padding: 18px;
                box-shadow: 0 6px 18px rgba(15,23,42,.08);
                border: 1px solid #eef2f7;
            }

            .device-table td {
                border: none;
                padding: 8px 0;
            }

            .device-table .icon {
                display: none;
            }

    /* DEVICE */

    .device-name {
        font-size: 22px;
        font-weight: 700;
        margin-bottom: 2px;
    }

    .device-id {
        font-size: 13px;
        color: #94a3b8;
        margin-bottom: 14px;
    }

    /* STATUS */

    .status {
        font-size: 16px;
    }

    /* BATTERY */

    .battery {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
    }

    .battery-progress {
        width: 110px;
        flex: none;
        height: 10px;
    }

    .battery span {
        width: 48px;
        flex: none;
        font-weight: 700;
        text-align: left;
    }

    /* BADGE */

    .badge {
        font-size: 13px;
    }
}


/* telefoni molto piccoli */

@media(max-width:380px) {

    .device-name {
        font-size: 19px;
    }

    .battery-progress {
        width: 90px;
    }

    .battery span {
        width: 42px;
        font-size: 13px;
    }
}
@media(max-width:380px) {

    .battery-progress {
        width: 90px;
    }

    .battery span {
        width: 50px;
        font-size: 14px;
    }
}