:root {
  --secondary-solid: #00A65A;
  --background-color-footer: 13, 106, 173;
  --card-bg: rgba(255, 255, 255, 0.8);
  --text-color: #333;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
}

body {
  font-family: 'Poppins', Arial, sans-serif;
  /* Keep Poppins */
  background-color: azure;
  /* Original background */
  color: var(--text-color);
}

/* Header & Navbar - Keeping original colors */
header {
  background-color: var(--secondary-solid);
  padding: 0;
}

.navbar {
  padding: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
}

.navbar .logo2 {
  width: 60px;
}

.navbar .logo1 {
  width: 370px;
}

.contenedor {
  width: 50%;
  margin: 20px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  flex: 1;
}

/* --- CLIMA CARD --- */
/* Restore original dynamic gradients logic (handled in JS), but set base styles */
.clima-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
  padding: 20px 30px;
  border-radius: 12px;
  width: 100%;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  background: #5ac8fa;
  /* Default original blue */
  flex-wrap: wrap;
}

.clima-info {
  display: flex;
  flex-direction: column;
  padding: .4em;
  border-radius: 5px;
}

.estado {
  font-weight: bold;
  font-size: 1.1em;
  margin-bottom: 5px;
}

.temperatura {
  display: flex;
  flex-direction: column;
}

.temperatura .temp-num {
  font-size: 2.5em;
  font-weight: bold;
}

.temperatura .sensacion {
  font-size: 0.9em;
  margin-top: 5px;
}

.viento {
  font-size: 0.9em;
  margin-top: 10px;
}

.icono {
  font-size: 3em;
  /* Reduced from 5em as requested */
  margin-left: 20px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

/* Animations */
@keyframes float {
  0% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-5px);
    /* More subtle movement */
  }

  100% {
    transform: translateY(0px);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.floating {
  animation: float 4s ease-in-out infinite;
  /* Slower, more subtle */
}

.spinning {
  animation: spin 12s linear infinite;
  /* Slower spin */
}

.sensor-card {
  animation: fadeIn 0.8s ease-out forwards;
}

/* --- GRID DE SENSORES (New layout, original aesthetic) --- */
#fecha {
  text-align: center;
  color: #388e3c;
  /* Original color */
  font-weight: 600;
  margin-bottom: 10px;
}

.seccion-sensores {
  width: 100%;
}

.sensores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
  width: 100%;
}

/* Sensor Card Layout Update */
.sensor-card {
  background: #ffffff;
  border-radius: 8px;
  padding: 15px;
  display: grid;
  grid-template-columns: auto 1fr;
  /* Icon | Text */
  grid-template-rows: auto auto;
  /* Name | Value */
  align-items: center;
  text-align: left;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  border: 1px solid #e0e0e0;
  animation: fadeIn 0.6s ease-out forwards;
}

.sensor-nombre {
  grid-column: 2;
  grid-row: 1;
  font-weight: 600;
  color: #333;
  margin-bottom: 2px;
}

.sensor-valor {
  grid-column: 2;
  grid-row: 2;
  font-size: 1.2em;
  color: #00A65A;
  font-weight: bold;
}

.sensor-unidad {
  font-size: 0.8em;
  color: #666;
  font-weight: normal;
}

.sensor-icon-container {
  grid-row: 1 / span 2;
  /* Span both rows */
  margin-right: 15px;
  margin-bottom: 0;
  font-size: 2em;
  color: var(--secondary-solid);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Button style restore */
#btnDatosAvanzados,
.btn-action {
  display: block;
  padding: 10px 20px;
  background: #878787;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
  transition: background 0.3s;
}

#btnDatosAvanzados {
  margin: 15px auto;
}

.btn-action:hover {
  background: #666;
}

.btn-toggle {
  display: none;
  /* Deprecated */
}

/* --- HISTÓRICOS --- */
.historicos {
  background: #ffffffb3;
  border-radius: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  width: 100%;
}

.titulo {
  background: rgba(var(--background-color-footer), .7);
  padding: 12px 15px;
  display: flex;
  justify-content: center;
  color: white;
  border-radius: 8px 8px 0px 0px;
}

.titulo h3 {
  margin: 0;
  color: white;
}

.contenido {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contenido label {
  font-weight: 600;
  color: #333;
}

.fechas-row {
  display: flex;
  gap: 15px;
  align-items: flex-end;
  /* Align labels and inputs */
}

.fecha-item {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.contenido select,
.contenido input[type="date"] {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;
}

.contenido button {
  display: block;
  margin: 5px auto;
  padding: 10px 20px;
  background: #878787;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
}

/* Table styles */
/* New Historical Data Layout */
.historico-container {
  margin-top: 20px;
  max-height: 500px;
  overflow-y: auto;
  padding-right: 5px;
  /* Space for scrollbar */
}

.grupo-historico {
  background: #fff;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  border: 1px solid #e0e0e0;
}

.fecha-header {
  font-size: 1.1em;
  font-weight: bold;
  color: var(--secondary-solid);
  border-bottom: 2px solid #f0f0f0;
  padding-bottom: 10px;
  margin-bottom: 15px;
  text-transform: capitalize;
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
}

.item-dato {
  background: azure;
  padding: 8px;
  border-radius: 6px;
  text-align: center;
  border: 1px solid #cceeff;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.dato-hora {
  font-size: 0.85em;
  color: #666;
  margin-bottom: 3px;
}

.dato-valor {
  font-weight: bold;
  color: #333;
  font-size: 1.1em;
}

.dato-valor small {
  font-size: 0.7em;
  color: #888;
  font-weight: normal;
}

/* Scrollbar styles for container */
.historico-container::-webkit-scrollbar {
  width: 8px;
}

.historico-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.historico-container::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

.historico-container::-webkit-scrollbar-thumb:hover {
  background: #999;
}


/* --- FOOTER --- */
footer {
  width: 100%;
  padding: .3em;
  padding-right: 2em;
  color: #fff;
  /* Original white text */
  background-color: rgba(var(--background-color-footer), .7);
  /* Original bg */
  font-size: .7rem;
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .7em;
  border-top: 2px solid rgba(var(--background-color-footer), 1);
  margin-top: auto;
}

footer img.dimuch {
  height: 55px;
}

footer img.muni {
  height: 35px;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
  .contenedor {
    width: 95%;
    margin: 10px auto;
  }

  .navbar {
    gap: 10px;
    justify-content: space-between;
    padding: 0.5rem;
    flex-wrap: nowrap;
  }

  .navbar a {
    width: 15%;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .navbar .logo2 {
    width: 100%;
    height: auto;
  }

  .navbar .logo1 {
    width: 83%;
    height: auto;
  }

  .clima-card {
    padding: 15px;
    flex-wrap: nowrap;
    /* Prevent wrapping */
    justify-content: space-between;
    text-align: left;
    gap: 10px;
  }

  .clima-info {
    min-width: 0;
    /* Allow shrinking */
    flex: 1;
    padding: 0;
  }

  /* Stack dates on mobile to prevent overflow */
  .fechas-row {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }
}