﻿:root {
    --primary: #6366f1;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --border: #f1f5f9;
    --danger: #ef4444;
    --header-height: 108px;
    --bottom-nav-height: 65px;
    /* Definiamo la scala come variabili per coerenza */
    --font-size-base: 1rem; /* 16px */
    --font-size-sm: 0.875rem; /* 14px */
    --font-size-xs: 0.75rem; /* 12px */
    --font-size-lg: 1.25rem; /* 20px */
    --font-size-xl: 1.5rem; /* 24px */
    --font-size-xxl: 2rem; /* 32px */
    /* Interlinea fondamentale per il mobile */
    --line-height-body: 1.5;
    --line-height-heading: 1.2;
}

[data-theme="dark"] {
    --bg: #0b0f1a;
    --card: #161b2c;
    --text: #f8fafc;
    --border: #2d3748;
}

* {
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    transition: background 0.2s;
}

body {
    margin: 0;
    background-color: var(--bg);
    color: var(--text);
    height: 100dvh;
    overflow: hidden;
    touch-action: pan-y;
    font-size: var(--font-size-base);
    line-height: var(--line-height-body);
    -webkit-text-size-adjust: 100%; /* Impedisce variazioni strane su orientamento mobile */
}

h1 {
    font-size: var(--font-size-xxl);
    line-height: var(--line-height-heading);
}

h2 {
    font-size: var(--font-size-xl);
}

small {
    font-size: var(--font-size-sm);
}

/* Fondamentale per evitare lo zoom automatico su iOS */
input, textarea, select {
    font-size: var(--font-size-base);
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100dvh; /* Full viewport dynamic height */
    padding-bottom: env(safe-area-inset-bottom);
}

.header {
    padding: 1rem 1.5rem;
    background: var(--card);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    box-shadow: inset 0 0 10px #ddd;
    height: var(--header-height);
}

.logo-img, .logo-svg {
    transform: translateY(2vh);   
    position: relative;
    z-index: 100;
    height: 109px; /* Blocca l'altezza */
    width: auto; /* Mantiene le proporzioni */
    display: block;
}

.padlock {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;

    > svg {
        color: #ef4444;
    }
}

    .padlock.open > svg {
        color: #10b981;
    }

    /* Landing page */
#landing-page {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-height: calc(100dvh - (var(--header-height) + var(--bottom-nav-height)));
    padding-bottom: 70px;
    transition: opacity 0.5s ease-in-out;
    background: #ffffff;
    overflow-y: auto;
}

@media (max-width: 768px) {
    /* Hide scrollbar for IE, Edge and Firefox */
    #landing-page {
        -ms-overflow-style: none; /* IE and Edge */
        scrollbar-width: none; /* Firefox */
        /* Hide scrollbar for Chrome, Safari and Opera */
        &::-webkit-scrollbar {
            display: none;
        }
    }
}

.disclaimer-banner {
    background-color: #ffcc00; /* Construction Yellow */
    color: #000;
    text-align: center;
    padding: 15px;
    font-family: sans-serif;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 9999;
    border-bottom: 2px solid #333;
}

.separator1 {
    background: linear-gradient(to bottom, #ddd, #ffffff);
    box-shadow: inset 0 10px 10px -10px rgba(0,0,0,0.1);    
    min-height: 40px;
}

.alert-strip {
    background-color: #ff9800;
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Ensures content stays on one line */
    white-space: nowrap;    
    /* box-shadow: inset [horizontal] [vertical] [blur] [spread] [color] */
    box-shadow: inset 0 0 10px rgb(183, 171, 171);
}

.alert-content {
    margin: 20px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: var(--font-size-base);
    font-weight: 700;
}

.alert-content > svg {    
    width: 48px; /* Sets the width */
    height: 48px; /* Sets the height */
    stroke-width: 2.5px; /* Optional: Changes the thickness of the lines */
}

.separator2 {
    min-height: 30px;
}

    .weather-strip {        
        background-color: #eef2f5;
        display: flex;
        justify-content: space-evenly;
        align-items: center;
        margin: 0 10px;
    }

.weather-cell {
    padding: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    color: #4a5568;
    width: 25%;
    height: 100%;
    border: groove 1px;
    border-radius: 5px;
    box-shadow: 0 0 2px rgb(183, 171, 171);
}

    .weather-cell i {
        font-size: var(--font-size-xxl);
        color: #2b6cb0;
        height: 65%;
    }

    .weather-cell span {
        font-weight: 600;
        text-align: center;
        height: 35%;
    }

    .message-strip {        
        background: linear-gradient(135deg, #0072ff 0%, #00c6ff 100%);
        color: #ffffff;
        display: flex;
        justify-content: center;
        align-items: center;
        text-align: center;
        padding: 0 20px;
        box-shadow: inset 0 4px 10px rgba(0,0,0,0.1);
    }

        .message-strip p {
            padding: 10px;
            font-weight: 500;
            line-height: 1.5;
        }

.celle-sicura-div {
    background-color: #eef2f5;    
    display: flex;
    border: groove 1px;
    border-radius: 5px;
    box-shadow: 0 0 2px rgb(183, 171, 171);
    margin: 0 10px;    
}

    .celle-sicura-div p {
        padding: 15px;
        font-size: var(--font-size-lg);
        margin: auto;
    }
    
    .celle-sicura-div p > strong {
        font-weight: 800;
    }

.sticky-bottom {
    position: fixed; /* Lo ancora allo schermo, non alla pagina */
    bottom: 0; /* Distanza zero dal fondo */
    left: 0; /* Allinea a sinistra */
    right: 0; /* Allinea a destra per coprire tutta la larghezza */
    width: 100%;
    z-index: 100; /* Lo tiene sopra agli altri elementi */
    background: #f1f5f9;
    display: flex;
    box-shadow: inset 0 2px #ddd;
}

.info-comm-btn {
    margin: 10px;
    background: linear-gradient(135deg, #0072ff 0%, #00c6ff 100%);
    color: #ffffff;
    border: 1px solid #cbd5e0;
    border-radius: 5px;
    padding: 5px 10px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    white-space: nowrap;    
    font-size: var(--font-size-base);
    gap: 10px;
    font-weight: 700;
    transition: all 0.3s ease;
}


    .info-comm-btn:active {
        transform: scale(0.96);
        box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05);
    }

.shield-question-mark {
    color: #ffffff;
    width: 38px; /* Sets the width */
    height: 38px; /* Sets the height */
    stroke-width: 2.5px; /* Optional: Changes the thickness of the lines */
}

    /* Auth Screen */
#auth-screen {
    height: 100dvh;
    max-height: calc(100dvh - var(--header-height));
    display: none;
    z-index: 90;
    background: var(--bg);
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 5vh;
    padding: 2rem;
    transition: opacity 0.5s ease-in-out;
    overflow-y: auto;
}

@media (max-width: 768px) {
    /* Hide scrollbar for IE, Edge and Firefox */
    #auth-screen {
        -ms-overflow-style: none; /* IE and Edge */
        scrollbar-width: none; /* Firefox */
        /* Hide scrollbar for Chrome, Safari and Opera */
        &::-webkit-scrollbar {
            display: none;
        }
    }
}

.auth-back-btn {
    background: none;
    font-size: 5rem;
    color: var(--primary);
    margin: 1rem;
    border: 0;
    padding: 0;
    display: flex;
}

.auth-back-btn svg {
    width: 30px; /* Sets the width */
    height: 30px; /* Sets the height */
    stroke-width: 2.5px;
}

.auth-card {
    background-color: #eef2f5;
    padding: 2.5rem;
    border-radius: 2rem;
    width: 100%;
    max-width: 350px;
    text-align: center;
    border: 1px solid var(--border);
    position: relative;    
    box-shadow: 0 0 2px rgb(183, 171, 171);
}
    /* Not Authorized Error */
    #auth-error {
        color: var(--danger);
        font-weight: 800;
        font-size: 0.75rem;
        margin-top: 10px;
        text-transform: uppercase;
        letter-spacing: 1px;
    }    

    input {
        width: 100%;
        padding: 0.9rem;
        margin: 0.6rem 0;
        border: 1.5px solid var(--border);
        border-radius: 1rem;
        background: var(--card);
        color: var(--text);
        font-size: 16px;
        outline: none;
    }

    .btn-main {
        background: var(--primary);
        color: white;
        border: none;
        width: 100%;
        padding: 1.1rem;
        border-radius: 1rem;
        font-weight: 800;
        cursor: pointer;
        margin-top: 1rem;
    }

        .btn-main:active {
            transform: scale(0.96);
            box-shadow: 0 1px 0 #1f5f8b;
        }

        .btn-main:hover {
            filter: brightness(1.1);
        }

        .btn-main:disabled {
            background-color: #ccc;
            cursor: not-allowed;
            opacity: 0.6;
            transform: scale(0.98); /* Slight shrink when locked */
        }
    /* App Layout */
#main-app {
    display: none;
    flex-direction: column;
    height: 100dvh;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    padding-bottom: var(--bottom-nav-height);
}
    /* Node Status Indicator */
    .status-pill {
        background: #10b98120;
        color: #10b981;
        padding: 4px 10px;
        border-radius: 20px;
        font-size: 0.65rem;
        font-weight: 900;
        display: flex;
        align-items: center;
        gap: 5px;
    }

    .dot {
        width: 6px;
        height: 6px;
        background: #10b981;
        border-radius: 50%;
        animation: pulse 1.5s infinite;
    }

    @keyframes pulse {
        0% {
            opacity: 1;
        }

        50% {
            opacity: 0.3;
        }

        100% {
            opacity: 1;
        }
    }
    /* Navigation & Viewport */
    .viewport {
        flex: 1;        
        overflow: hidden;
    }

    .tab-striper {
        display: flex;
        height: 100%;
        width: 400%;
        transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    }

.view {
    width: 25%;
    height: 100%;
    max-height: calc(100dvh - (var(--header-height) + var(--bottom-nav-height)));
    overflow-y: auto;
    padding: 1.5rem;
}

@media (max-width: 768px) {
    /* Hide scrollbar for IE, Edge and Firefox */
    .view {
        -ms-overflow-style: none; /* IE and Edge */
        scrollbar-width: none; /* Firefox */
        /* Hide scrollbar for Chrome, Safari and Opera */
        &::-webkit-scrollbar {
            display: none;
        }
    }
}

    .glass-card {
        background: var(--card);
        border-radius: 1.5rem;
        padding: 1.5rem;
        margin-bottom: 1rem;
        border: 1px solid var(--border);
    }

    .weather-hero {
        background: linear-gradient(135deg, #4f46e5, #0ea5e9);
        color: white;
        border: none;
    }

.map-container {
    width:100%;
    height:100%;
    border-radius:1.5rem;
    /* pan-x pan-y allows the user to move the map in all directions */
    /* but prevents the browser from using those swipes for 'Back/Forward' */
    touch-action: pan-x pan-y;
    /* Specifically prevents the 'pull-to-refresh' or 'swipe-to-navigate' behavior */
    overscroll-behavior: contain;
}

.mqttlogtable {
    table-layout: fixed; /* Forces the browser to respect your percentages */
    width: 100%; /* Required for fixed layout */
    border-collapse: collapse;
    font-size: 0.75rem;
}

    .mqttlogtable td:nth-child(1),
    .mqttlogtable th:nth-child(1) {
        width: 30%;
        max-width: 30vw;
    }

    .mqttlogtable td:nth-child(2),
    .mqttlogtable th:nth-child(2) {
        width: 30%;
        max-width: 30vw;
    }

    .mqttlogtable td:nth-child(3),
    .mqttlogtable th:nth-child(3) {
        width: 40%;
    }

    .mqttlogtable th, td {
        padding: 0.8rem;
        vertical-align: middle;        
    }

.cell-content {
    overflow-x: auto;
    white-space: nowrap;
    width: 100%;
    box-sizing: border-box;
    display: block;
    /* Hide scrollbar */
    -ms-overflow-style: none; /* IE and Edge */
    scrollbar-width: none; /* Firefox */
}

    /* Hide scrollbar */
    .cell-content::-webkit-scrollbar {
        display: none;
    }

/* Show scrollbar on bigger screens */
@media (min-width: 1024px) {
    .cell-content {
        scrollbar-width: thin; /* Firefox: Thin bar */
        scrollbar-color: #888 #eee; /* Firefox: Thumb and Track color */
    }

        .cell-content::-webkit-scrollbar {
            display: block; /* Show it on desktop */
            height: 5px; /* Horizontal scrollbar height */
        }

        .cell-content::-webkit-scrollbar-track {
            background: transparent; /* Keep the track invisible for a cleaner look */
        }

        .cell-content::-webkit-scrollbar-thumb {
            background-color: #bbbbbb; /* The actual "bar" color */
            border-radius: 10px; /* Makes it rounded */
        }

            .cell-content::-webkit-scrollbar-thumb:hover {
                background-color: #888888; /* Darken on hover */
            }
}

        .bottom-nav {
            position: fixed;
            bottom: 0;
            width: 100%;
            height: var(--bottom-nav-height);
            background: #f1f5f9;
            display: flex;
            padding: 1px 0 1px;
            z-index: 100;
            display: flex;
        }

        .nav-item {
            flex: 1;
            border: 1px solid #4a5568;
            background: none;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: #94a3b8;
            font-size: 0.7rem;
            cursor: pointer;
            font-weight: 600;
            gap: 4px;
        }

            .nav-item.active {
                color: var(--primary);
            }
       
