/* --- BASIS-DESIGN --- */
/* Grundeinstellungen für die gesamte Seite */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f7f6;
    margin: 0;
    padding: 0;
    color: #333;
}

h1, h2 {
    text-align: center;
    color: #2c3e50;
    margin-top: 20px;
}

/* --- NAVBAR --- */
/* Die Navigationsleiste oben */
.navbar {
    background-color: #2c3e50;
    padding: 0.8rem 2rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.navbar a {
    color: #ecf0f1;
    text-decoration: none;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 5px;
    transition: background 0.3s;
}

.navbar a:hover {
    background-color: #34495e;
}

.navbar a.active {
    background-color: #3498db;
    color: white;
}

/* --- KACHELN (CURRENT STATS) --- */
/* Container für die Boxen: Flexbox sorgt dafür, dass sie nebeneinander stehen */
.current-stats-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 20px;
    justify-content: center;
}

/* Das Aussehen einer einzelnen Kachel */
.current-box {
    background: white;
    padding: 25px;
    border-radius: 12px;
    min-width: 250px;
    flex: 1;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border-top: 6px solid #bdc3c7; /* Standardfarbe */
    transition: transform 0.2s;
}

.current-box:hover {
    transform: translateY(-5px);
}

/* Farbige Linien oben an den Kacheln zur Unterscheidung der Räume */
.current-box.main { border-top-color: #e74c3c; }    /* Rot: Wohnzimmer */
.current-box.outside { border-top-color: #3498db; } /* Blau: Draußen */
.current-box.office { border-top-color: #f39c12; }  /* Orange: Büro */

.current-box .label {
    display: block;
    font-size: 0.9em;
    text-transform: uppercase;
    color: #7f8c8d;
    margin-bottom: 10px;
}

.current-box .value {
    display: block;
    font-size: 2.5em;
    font-weight: bold;
}

.current-box .sub-value {
    color: #555;
    font-size: 1.1em;
}

/* Status-Zeilen (Batterie/Signal) */
.status-line {
    margin-top: 15px;
    font-size: 0.85em;
    color: #7f8c8d;
    border-top: 1px solid #eee;
    padding-top: 10px;
    display: flex;
    justify-content: center;
    gap: 15px;
}

.status-val { font-weight: bold; }
.warn { color: #e74c3c !important; } /* Rot bei Gefahr */
.ok { color: #27ae60 !important; }   /* Grün bei OK */

.update-time {
    margin-top: 15px;
    font-size: 0.75em;
    color: #95a5a6;
}

/* --- REKORD-BOXEN --- */
/* Container für Min/Max Werte */
.stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}

.stats .box {
    background: #fff;
    padding: 15px 30px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* --- CHARTS & CONTAINERS --- */
/* Weißer Hintergrund für die Diagramme */
.chart-box {
    background: white;
    margin: 20px auto;
    padding: 20px;
    border-radius: 12px;
    max-width: 1000px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* --- TABELLEN --- */
/* Container für die Tabellen unten */
.flex-tables {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.flex-tables .box {
    background: white;
    padding: 20px;
    border-radius: 12px;
    flex: 1;
    min-width: 300px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th {
    background-color: #f8f9fa;
    color: #7f8c8d;
    text-align: left;
    padding: 12px;
    border-bottom: 2px solid #eee;
}

td {
    padding: 12px;
    border-bottom: 1px solid #eee;
}

tr:hover { background-color: #fdfdfd; }

/* Archiv-Input Styling */
input[type="date"] {
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #ccc;
    font-size: 1em;
    margin-bottom: 20px;
}
.record-date {
    display: block; /* Erzeugt eine neue Zeile unter der Temperatur */
    font-size: 0.8em;
    color: #7f8c8d;
    margin-top: 5px;
}
/* Styling für das kleine "i" Icon und den Tooltip (Sprechblase) */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3498db; /* Blaues Rund */
    color: white !important;
    font-size: 12px;
    font-weight: bold;
    font-family: serif;
    cursor: pointer;
    margin-left: 8px;
    vertical-align: middle;
    border: 1px solid white; /* Weißer Rand macht es sichtbar */
    position: relative;
    z-index: 10;
}

.tooltip {
    display: none;
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    background: #2c3e50;
    color: white;
    padding: 10px;
    border-radius: 8px;
    width: 220px;
    font-size: 12px;
    line-height: 1.4;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    font-weight: normal;
    text-align: left;
}

.tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #2c3e50 transparent transparent transparent;
}

/* Spezielle Anpassung, wenn Diagramme nebeneinander stehen sollen */
.charts-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
}
.charts-container .chart-box {
    margin: 0;
    flex: 1;
    min-width: 350px;
}

/* --- HEATMAP STYLING --- */
.heatmap-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
    gap: 15px;
}

.heatmap-header h2 {
    margin: 0;
}

.heatmap-controls {
    display: flex;
    gap: 8px;
}

.heatmap-btn {
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    color: #7f8c8d;
    padding: 8px 16px;
    font-size: 0.9em;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.heatmap-btn:hover {
    background-color: #eee;
    color: #333;
}

/* Specific active border/colors for sensors */
.heatmap-btn.active[data-sensor="outside"] {
    background-color: #3498db;
    border-color: #3498db;
    color: white;
}
.heatmap-btn.active[data-sensor="main"] {
    background-color: #e74c3c;
    border-color: #e74c3c;
    color: white;
}
.heatmap-btn.active[data-sensor="office"] {
    background-color: #f39c12;
    border-color: #f39c12;
    color: white;
}

.heatmap-scroll-container {
    overflow-x: auto;
    width: 100%;
    margin-top: 10px;
    position: relative;
    /* Custom Scrollbar for premium look */
    scrollbar-width: thin;
    scrollbar-color: #bdc3c7 #f4f7f6;
}

.heatmap-scroll-container::-webkit-scrollbar {
    height: 6px;
}
.heatmap-scroll-container::-webkit-scrollbar-track {
    background: #f4f7f6;
}
.heatmap-scroll-container::-webkit-scrollbar-thumb {
    background-color: #bdc3c7;
    border-radius: 3px;
}

.heatmap-grid {
    display: grid;
    /* 1 Column for Date (80px), 24 Columns for hours (min 20px, max 1fr) */
    grid-template-columns: 80px repeat(24, minmax(20px, 1fr));
    gap: 3px;
    min-width: 600px; /* Ensures it looks like a grid even on tiny screens (via scroll) */
}

.heatmap-label {
    font-size: 0.75em;
    color: #7f8c8d;
    display: flex;
    align-items: center;
    font-weight: 600;
}

.heatmap-label.date-label {
    justify-content: flex-end;
    padding-right: 8px;
    white-space: nowrap;
}

.heatmap-label.hour-label {
    justify-content: center;
    padding-bottom: 4px;
    border-bottom: 1px solid #eee;
}

.heatmap-cell {
    aspect-ratio: 1.2;
    background-color: #eaeded; /* Default empty color */
    border-radius: 3px;
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.2s ease;
    position: relative;
}

.heatmap-cell:hover {
    transform: scale(1.2);
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.heatmap-footer {
    display: flex;
    justify-content: center;
    margin-top: 15px;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8em;
    color: #7f8c8d;
}

.legend-bar {
    width: 200px;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(to right, #3498db, #1abc9c, #2ecc71, #f39c12, #e74c3c);
    border: 1px solid #e2e8f0;
}

.heatmap-tooltip {
    position: absolute;
    background: rgba(44, 62, 80, 0.95);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8em;
    font-weight: 500;
    pointer-events: none;
    display: none;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    white-space: nowrap;
    border: 1px solid rgba(255,255,255,0.1);
    transform: translate(-50%, -100%);
    margin-top: -12px;
    transition: opacity 0.15s ease;
}

/* --- INTERNETVERBINDUNG PAGE STYLES --- */
.current-box.net-status { border-top-color: #2ecc71; }
.current-box.net-status.offline { border-top-color: #e74c3c; }
.current-box.net-uptime { border-top-color: #3498db; }
.current-box.net-latency { border-top-color: #9b59b6; }
.current-box.net-info { border-top-color: #f39c12; }

/* Status Dot with pulsating animation */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
}

.status-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    position: relative;
}

.status-dot.online {
    background-color: #2ecc71;
    box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7);
    animation: pulse-green 2s infinite;
}

.status-dot.offline {
    background-color: #e74c3c;
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
    animation: pulse-red 2s infinite;
}

@keyframes pulse-green {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(46, 204, 113, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0);
    }
}

@keyframes pulse-red {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(231, 76, 60, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
    }
}

/* Status Badges for table */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
}

.badge-online {
    background-color: #e8f8f0;
    color: #27ae60;
    border: 1px solid #a3e4d7;
}

.badge-offline {
    background-color: #fdebd0;
    color: #c0392b;
    border: 1px solid #f5b7b1;
}

/* Action button */
.btn-check {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border: none;
    padding: 10px 18px;
    font-size: 0.95em;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 6px rgba(52, 152, 219, 0.3);
    margin-top: 10px;
}

.btn-check:hover {
    background: linear-gradient(135deg, #2980b9, #1f618d);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.4);
}

.btn-check:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.spin-icon {
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

/* Uptime Bar */
.uptime-bar-bg {
    width: 100%;
    height: 8px;
    background-color: #ecf0f1;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}

.uptime-bar-fill {
    height: 100%;
    background: linear-gradient(to right, #2ecc71, #27ae60);
    border-radius: 4px;
    transition: width 0.6s ease;
}

.uptime-bar-fill.warn {
    background: linear-gradient(to right, #f39c12, #e74c3c);
}