:root {
  --font-main: 'Courier New', Courier, monospace;

  /* Light Theme Colors */
  --light-bg: #F5F5F5;
  --light-fg: #333333;
  --light-primary: #367AF6;
  --light-secondary: #5A5A5A;
  --light-accent: #F2C464;
  --light-card-bg: #FFFFFF;
  --light-border: #DDDDDD;

  /* Dark Theme Colors */
  --dark-bg: #333333;
  --dark-fg: #FFFFFF;
  --dark-primary: #F2C464;
  --dark-secondary: #A9A9A9;
  --dark-accent: #367AF6;
  --dark-card-bg: #424242;
  --dark-border: #555555;
}

body {
  background-color: var(--bg-color);
  color: var(--fg-color);
  font-family: var(--font-main);
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden; /* evita el scroll */
}

.light-theme {
  --bg-color: var(--light-bg);
  --fg-color: var(--light-fg);
  --primary-color: var(--light-primary);
  --secondary-color: var(--light-secondary);
  --accent-color: var(--light-accent);
  --card-bg-color: var(--light-card-bg);
  --border-color: var(--light-border);
}

.dark-theme {
  --bg-color: var(--dark-bg);
  --fg-color: var(--dark-fg);
  --primary-color: var(--dark-primary);
  --secondary-color: var(--dark-secondary);
  --accent-color: var(--dark-accent);
  --card-bg-color: var(--dark-card-bg);
  --border-color: var(--dark-border);
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.app-header > div {
  flex: 1;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  padding-bottom: 0.3rem;
  display: flex;
  flex-direction: column;
}

.app-footer {
  padding: 0.3rem 1rem;
  padding-top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* SIEMPRE 2 columnas */
  gap: 0.8rem; /* Reducir el gap para acomodar más elementos */
}

.start-button-container {
  margin-top: 0.8rem;
  display: flex;
  justify-content: center;
  align-items: center;
}

.sensor-block {
  background-color: var(--card-bg-color);
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  text-align: center;
  transition: background 0.3s ease;
  padding: 0.8rem;
  min-height: 120px;
}

/* Estilos para los títulos en los bloques de sensores */
.sensor-block h2 {
    font-size: 1rem;
    font-weight: bold;
    color: var(--secondary-color);
    margin: 0 0 0.5rem 0;
}

.stat-main-value {
    font-size: 2.1rem;
    font-weight: 700;
    color: var(--fg-color);
    line-height: 1.1;
}

.stat-unit {
    font-size: 1rem;
    color: var(--primary-color);
    margin-left: 0.2rem;
}

 .stat-minmax-row {
  display: flex;
  justify-content: space-around;
  font-size: 0.9rem;
  color: var(--secondary-color);
  margin-top: 0.5rem;
}

.stat-min b, .stat-max b {
    color: var(--fg-color);
    font-weight: bold;
}

.session-time {
  background-color: var(--card-bg-color);
  border: 2px solid var(--primary-color);
  box-shadow: 0 0 10px var(--primary-color);
}

.value {
  font-size: 2rem;
  margin: 0.5rem 0;
  color: var(--primary-color);
  font-weight: bold;
}

.icon-button {
  background-color: var(--secondary-color);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  padding: 0.5rem;
  margin-top: 0.5rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease;
}

.icon-button:hover {
  background-color: var(--primary-color);
  color: var(--bg-color);
}

.icon-button img {
  width: 20px;
  height: 20px;
}

#startStopBtn {
  width: 100%;
  max-width: 400px;
  height: 50px;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  background-color: var(--primary-color);
  border: none;
  color: var(--bg-color);
  font-weight: bold;
  padding: 1rem;
  border-radius: 12px;
  position: relative;
  -webkit-user-select: none; /* Safari */
  -ms-user-select: none; /* IE 10+ */
  user-select: none; /* Standard */
}

#startStopBtn.recording {
    background-color: var(--primary-color);
    color: var(--bg-color);
}

#startStopBtn:hover {
  opacity: 0.9;
}

.hold-progress {
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(50%, -50%);
}

#session-history {
  margin-top: 2rem;
}

.version-section {
  display: flex;
  justify-content: flex-start;
}

.version-section a {
    color: var(--secondary-color);
    text-decoration: none;
}

#version-link {
  color: #888;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s;
}

#version-link:hover {
  color: #aaa;
}

/* Popup de versiones */
.version-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  backdrop-filter: blur(5px);
}

.version-popup.show {
  display: flex;
}

.version-popup-content {
  background-color: #111;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 90%;
  max-height: 80%;
  width: 400px;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.version-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #333;
}

.version-popup-title {
  font-size: 1.2rem;
  font-weight: bold;
  color: #36aa00;
}

.version-popup-close {
  background: none;
  border: none;
  color: #888;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.version-popup-close:hover {
  background-color: #333;
  color: #fff;
}

.version-popup-body {
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.version-popup-body::-webkit-scrollbar {
  width: 6px;
}

.version-popup-body::-webkit-scrollbar-track {
  background: #222;
  border-radius: 3px;
}

.version-popup-body::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 3px;
}

.version-popup-body::-webkit-scrollbar-thumb:hover {
  background: #777;
}

.version-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.version-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #222;
  color: #ccc;
  font-size: 0.9rem;
}

.version-list li:last-child {
  border-bottom: none;
}

.version-list li strong {
  color: #36aa00;
  font-weight: bold;
}

.recording {
  font-weight: bold;
  color: red;
  background-color: #222;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  box-shadow: 0 0 5px red;
}

/* Theme switcher styles - now centered */

.theme-toggle-label {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.theme-toggle-label input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 28px;
}

.theme-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="black"><path d="M12 9c1.65 0 3 1.35 3 3s-1.35 3-3 3-3-1.35-3-3 1.35-3 3-3m0-2c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zM2 13h2c.55 0 1-.45 1-1s-.45-1-1-1H2c-.55 0-1 .45-1 1s.45 1 1 1zm18 0h2c.55 0 1-.45 1-1s-.45-1-1-1h-2c-.55 0-1 .45-1 1s.45 1 1 1zM11 2v2c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1s-1 .45-1 1zm0 18v2c0 .55.45 1 1 1s1-.45 1-1v-2c0-.55-.45-1-1-1s-1 .45-1 1zM5.64 5.64c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.02 0 1.41zm12.72 12.72c.39.39 1.02.39 1.41 0 .39-.39.39-1.02 0-1.41-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.02 0 1.41zM18.36 5.64c.39-.39.39-1.02 0-1.41-.39-.39-1.02-.39-1.41 0-.39.39-.39 1.02 0 1.41.39.39 1.02.39 1.41 0zM6.05 19.47c-.39-.39-.39-1.02 0-1.41.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41-.39.39-1.02.39-1.41 0z"/></svg>');
}

input:checked + .theme-toggle-slider {
    background-color: var(--primary-color);
}

input:checked + .theme-toggle-slider:before {
    transform: translateX(22px);
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M9.37 5.51c.33-.24.78-.15 1.02.18.24.33.15.78-.18 1.02A7.5 7.5 0 005.5 12c0 4.14 3.36 7.5 7.5 7.5s7.5-3.36 7.5-7.5c0-2.08-.84-3.96-2.2-5.29-.33-.24-.42-.69-.18-1.02.24-.33.69-.42 1.02-.18C20.12 7.23 22 9.48 22 12c0 5.52-4.48 10-10 10S2 17.52 2 12c0-2.52 1.88-4.77 4.29-6.31z"/></svg>');
}

/* Modal Styles */
.modal {
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: var(--card-bg-color);
  color: var(--fg-color);
  margin: auto;
  padding: 20px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  width: 80%;
  max-width: 500px;
  position: relative;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.modal-close-btn {
  color: var(--secondary-color);
  position: absolute;
  top: 10px;
  right: 20px;
  font-size: 28px;
  font-weight: bold;
}

.modal-close-btn:hover,
.modal-close-btn:focus {
  color: var(--primary-color);
  text-decoration: none;
  cursor: pointer;
}

#changelog-list {
    list-style-type: none;
    padding-left: 0;
}
#changelog-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}
#changelog-list li:last-child {
    border-bottom: none;
}

/* Estilos para el modo sesión - mejor layout sin fullscreen completo */
body.session-mode {
  /* Ocultar elementos innecesarios durante la sesión */
}

body.session-mode .app-header {
  /* Hacer el header más compacto durante las sesiones */
  padding: 0.3rem 1rem;
  min-height: auto;
}

body.session-mode .main-content {
  /* Optimizar el espacio del contenido principal */
  padding: 0.5rem;
  padding-bottom: 0.3rem;
}

body.session-mode .app-footer {
  /* Hacer el footer más compacto */
  padding: 0.3rem 1rem;
  min-height: 60px;
}

body.session-mode .grid {
  /* Reducir el gap entre elementos en modo sesión */
  gap: 0.8rem;
}

body.session-mode .sensor-block {
  /* Hacer los bloques más compactos */
  padding: 0.8rem;
}

body.session-mode .value {
  /* Ajustar el tamaño de los valores */
  font-size: 1.8rem;
  margin: 0.3rem 0;
}

body.session-mode #startStopBtn {
  /* Hacer el botón principal más compacto */
  height: 45px;
  font-size: 1.3rem;
  padding: 0.8rem;
}

/* Optimizaciones específicas para móviles */
@media (max-width: 600px) {
  .grid {
    gap: 0.6rem;
  }
  
  .sensor-block {
    padding: 0.6rem;
    min-height: 100px;
  }
  
  .value {
    font-size: 1.6rem;
  }
  
  .start-button-container {
    margin-top: 0.6rem;
  }
  
  #startStopBtn {
    height: 40px;
    font-size: 1.2rem;
  }
}

/* Optimizaciones específicas para móviles en modo sesión */
@media (max-width: 600px) {
  body.session-mode .app-header {
    padding: 0.2rem 0.8rem;
  }
  
  body.session-mode .main-content {
    padding: 0.4rem;
    padding-bottom: 0.2rem;
  }
  
  body.session-mode .app-footer {
    padding: 0.2rem 0.8rem;
    min-height: 50px;
  }
  
  body.session-mode .grid {
    gap: 0.5rem;
  }
  
  body.session-mode .sensor-block {
    padding: 0.5rem;
    min-height: 85px;
  }
  
  body.session-mode .value {
    font-size: 1.4rem;
  }
  
  body.session-mode #startStopBtn {
    height: 35px;
    font-size: 1.1rem;
  }
}

/* Estilos para el contador de visitas */
.visit-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: var(--secondary-color);
  background-color: var(--card-bg-color);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 0.3rem 0.8rem;
  transition: all 0.3s ease;
  margin: 0 auto;
  max-width: 200px;
}

.visit-counter:hover {
  color: var(--primary-color);
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#visit-count-text {
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* Responsive para el contador de visitas */
@media (max-width: 600px) {
  .visit-counter {
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    max-width: 150px;
  }
}

.theme-switcher-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.hamburger-menu {
  display: flex;
  justify-content: flex-end;
}

/* Hamburger button styles */
.hamburger-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 32px;
  height: 32px;
  position: relative;
  transition: transform 0.2s ease;
}

.hamburger-btn:hover {
  transform: scale(1.05);
}

.hamburger-line {
  width: 24px;
  height: 2px;
  background-color: var(--fg-color);
  border-radius: 2px;
  position: absolute;
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  transform-origin: center;
}

.hamburger-line:nth-child(1) {
  top: 9px;
}

.hamburger-line:nth-child(2) {
  top: 15px;
}

.hamburger-line:nth-child(3) {
  top: 21px;
}

/* Animación cuando está activo */
.hamburger-btn.active .hamburger-line:nth-child(1) {
  top: 15px;
  transform: rotate(45deg);
}

.hamburger-btn.active .hamburger-line:nth-child(2) {
  transform: scaleX(0);
  opacity: 0;
}

.hamburger-btn.active .hamburger-line:nth-child(3) {
  top: 15px;
  transform: rotate(-45deg);
}

/* Side menu styles */
.side-menu {
  position: fixed;
  top: 0;
  right: -350px;
  width: 350px;
  height: 100vh;
  background-color: var(--card-bg-color);
  border-left: 1px solid var(--border-color);
  z-index: 1000;
  transition: right 0.3s ease;
  box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
}

.side-menu.active {
  right: 0;
}

.side-menu-content {
  padding: 1rem;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.side-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.side-menu-header h3 {
  margin: 0;
  color: var(--fg-color);
  font-size: 1.2rem;
}

.side-menu-close {
  background: none;
  border: none;
  font-size: 32px;
  cursor: pointer;
  color: var(--secondary-color);
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.side-menu-close:hover {
  background-color: var(--border-color);
  color: var(--fg-color);
}

.side-menu-body {
  flex: 1;
}

.menu-items {
  list-style: none;
  padding: 0;
  margin: 0;
}

.menu-items li {
  margin-bottom: 0.5rem;
}

.menu-items a {
  display: block;
  padding: 1rem;
  color: var(--fg-color);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.3s ease;
  font-size: 1rem;
}

.menu-items a:hover {
  background-color: var(--border-color);
  color: var(--primary-color);
  transform: translateX(5px);
}

/* Side menu overlay */
.side-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.side-menu-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Mobile responsive adjustments */
@media (max-width: 600px) {
  .side-menu {
    width: 280px;
    right: -280px;
  }
  
  .hamburger-btn {
    width: 30px;
    height: 30px;
    padding: 6px;
  }
  
  .hamburger-line {
    width: 20px;
    height: 2px;
  }
  
  .hamburger-line:nth-child(1) {
    top: 8px;
  }
  
  .hamburger-line:nth-child(2) {
    top: 14px;
  }
  
  .hamburger-line:nth-child(3) {
    top: 20px;
  }
  
  .hamburger-btn.active .hamburger-line:nth-child(1) {
    top: 14px;
  }
  
  .hamburger-btn.active .hamburger-line:nth-child(3) {
    top: 14px;
  }
  
  .side-menu-close {
    font-size: 28px;
    width: 32px;
    height: 32px;
  }
}

/* ==========================================
   ESTILOS PARA LOGIN
   ========================================== */

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
}

.login-card {
  background-color: var(--card-bg-color);
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: 90%;
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 1rem;
  background: var(--primary-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.login-title {
  font-size: 1.8rem;
  color: var(--primary-color);
  margin: 0 0 0.5rem 0;
  font-weight: bold;
}

.login-subtitle {
  color: var(--secondary-color);
  font-size: 1rem;
  margin: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-label {
  color: var(--fg-color);
  font-weight: 500;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.form-input {
  background-color: var(--bg-color);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 0.8rem 1rem;
  font-family: var(--font-main);
  font-size: 1rem;
  color: var(--fg-color);
  transition: all 0.3s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(54, 122, 246, 0.1);
}

.form-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-button {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: white;
  border: none;
  border-radius: 12px;
  padding: 1rem;
  font-family: var(--font-main);
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.login-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(54, 122, 246, 0.4);
}

.login-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.login-button.loading {
  color: transparent;
}

.login-button.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid transparent;
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.error-message {
  background-color: #ffe6e6;
  color: #d63384;
  border: 1px solid #f5c6cb;
  border-radius: 8px;
  padding: 0.8rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: none;
}

.error-message.show {
  display: block;
}

.back-link {
  text-align: center;
  margin-top: 1.5rem;
}

.back-link a {
  color: var(--secondary-color);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.3s;
}

.back-link a:hover {
  color: var(--primary-color);
}

@media (max-width: 600px) {
  .login-card {
    padding: 2rem;
    border-radius: 15px;
  }
  
  .login-title {
    font-size: 1.5rem;
  }
  
  .login-logo {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
  }
}
