/**
 *  Copyright (c) 2026 Aymeric - APLU
 *
 *  Permission is hereby granted, free of charge, to any person obtaining a copy
 *  of this software and associated documentation files (the "Software"), to deal
 *  in the Software without restriction, including without limitation the rights
 *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 *  copies of the Software, and to permit persons to whom the Software is
 *  furnished to do so, subject to the following conditions:
 *
 *  The above copyright notice and this permission notice shall be included in all
 *  copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 *  SOFTWARE.
 */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f5f6fa;
  color: #2c3e50;
  line-height: 1.6;
  padding: 1rem;
}

.container {
  margin: 0 auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  padding: 1.5rem;
}

@media (min-width: 1600px) {
  .container {
    padding: 2rem 4rem;
  }
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #1a1a2e;
}

.top-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.time-nav {
  display: flex;
  gap: 0.35rem;
  align-items: center;
  padding: 0.4rem 0.6rem;
  background: #f8f9fa;
  border-radius: 6px;
}

.time-nav-btn {
  padding: 0.25rem 0.55rem;
  font-size: 0.8rem;
  border: 1px solid #d0d5dd;
  border-radius: 4px;
  background: #fff;
  color: #2c3e50;
  cursor: pointer;
}

.time-nav-btn:hover {
  background: #eaf3fa;
  border-color: #3498db;
}

.time-range-label {
  margin-left: auto;
  font-size: 0.85rem;
  color: #2c3e50;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  user-select: none;
}

.share-btn {
  padding: 0.2rem 0.55rem;
  font-size: 0.78rem;
  border: 1px solid #d0d5dd;
  border-radius: 4px;
  background: #fff;
  color: #2c3e50;
  cursor: pointer;
  margin-left: 0.25rem;
}
.share-btn:hover {
  background: #eaf3fa;
  border-color: #3498db;
}

.time-range-label:hover {
  background: #eaf3fa;
}

.time-panel {
  margin-bottom: 0.75rem;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  background: #fff;
  padding: 0.75rem;
}

.time-presets {
  display: flex;
  gap: 1rem;
}

.time-presets .cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.preset-btn {
  padding: 0.3rem 0.5rem;
  font-size: 0.78rem;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: #2c3e50;
  cursor: pointer;
  text-align: left;
}

.preset-btn:hover {
  background: #eaf3fa;
  color: #1a73e8;
}

.time-manual {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #eef0f5;
}

.time-manual label {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.time-manual input {
  padding: 0.3rem 0.4rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
}

#manualApply {
  padding: 0.3rem 0.8rem;
  background: #3498db;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

#manualApply:hover {
  background: #2980b9;
}

.sensor-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  flex: 1;
  padding: 0.5rem 0.6rem;
  background: #f8f9fa;
  border-radius: 6px;
}

.sensor-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: center;
  border: none;
  padding: 0;
  font-size: 0.9rem;
}
.sensor-checkboxes label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

#downloadBtn {
  padding: 0.3rem 0.8rem;
  background: #27ae60;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}
#downloadBtn:hover {
  background: #219a52;
}

.data-status {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
}
.data-status.has-data {
  color: #27ae60;
  background: #eafaf1;
}
.data-status.no-data {
  color: #e74c3c;
  background: #fdedec;
}

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 500px;
  margin-bottom: 1.5rem;
}

.stats {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.stats th,
.stats td {
  padding: 0.6rem 0.8rem;
  text-align: center;
  border-bottom: 1px solid #eef0f5;
}

.stats th {
  background: #f8f9fa;
  font-weight: 600;
  color: #555;
}

.stats td:first-child {
  font-weight: 500;
  text-align: left;
}

.stats tr:hover td {
  background: #f0f4ff;
}

.footer {
  text-align: center;
  font-size: 0.85rem;
  color: #888;
  padding-top: 1rem;
  border-top: 1px solid #eef0f5;
}

.footer a {
  color: #3498db;
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

@media (max-width: 600px) {
  .container { padding: 1rem; }
  .top-bar { flex-direction: column; align-items: stretch; }
  .time-presets { flex-wrap: wrap; }
  .time-presets .cell { min-width: 45%; }
  .time-manual { flex-direction: column; align-items: stretch; }
  .time-manual label { flex-direction: column; }
  .sensor-bar { flex-direction: column; align-items: stretch; }
  .chart-wrapper { height: 350px; }
}