/* === DISEÑO MEJORADO PARA ENERGYSIM === */
:root {
  --primary: #2e7d32;
  --primary-light: #4caf50;
  --primary-dark: #1b5e20;
  --secondary: #ff9800;
  --accent: #2196f3;
  --text: #333333;
  --text-light: #666666;
  --background: #f5f9f6;
  --card-bg: #ffffff;
  --border: #e0e0e0;
  --success: #4caf50;
  --warning: #ff9800;
  --error: #f44336;
}

* {
  box-sizing: border-box;
  transition: all 0.2s ease;
}

body {
  font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  margin: 0;
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* HEADER MEJORADO */
header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: white;
  padding: 15px 5%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-container {
  height: 60px;
  display: flex;
  align-items: center;
}

.site-logo {
  height: 100%;
  width: auto;
  filter: brightness(1) invert(0);
}

.user-options {
  display: flex;
  gap: 12px;
}

.user-options button {
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 30px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  backdrop-filter: blur(5px);
}

.user-options button:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* CONTENEDOR PRINCIPAL */
.container {
  padding: 30px 5%;
  max-width: 1200px;
  margin: 0 auto;
}

/* NAVEGACIÓN PRINCIPAL */
.nav-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.nav-buttons button {
  padding: 14px 30px;
  background: var(--card-bg);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 50px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  transition: all 0.3s;
  flex: 1;
  min-width: 180px;
  max-width: 250px;
}

.nav-buttons button:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  border-color: var(--primary-light);
}

.nav-buttons button.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border-color: var(--primary);
  box-shadow: 0 5px 15px rgba(46, 125, 50, 0.3);
}

/* SECCIONES */
.section {
  background: var(--card-bg);
  padding: 30px;
  margin-bottom: 30px;
  border-radius: 16px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
  display: none;
  position: relative;
  border: 1px solid var(--border);
}

.section.active {
  display: block;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.section h2 {
  color: var(--primary-dark);
  margin-top: 0;
  margin-bottom: 25px;
  font-size: 1.8rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section h2:before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 25px;
  background: var(--primary);
  border-radius: 4px;
}

/* SUBNAVEGACIÓN */
.sub-nav-buttons {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 25px;
  flex-wrap: wrap;
}

.sub-nav-buttons button {
  padding: 12px 25px;
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.sub-nav-buttons button:hover {
  background: #f5f5f5;
  transform: translateY(-2px);
}

.sub-nav-buttons button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 3px 10px rgba(46, 125, 50, 0.2);
}

/* SUBSECCIONES */
.sub-section {
  display: none;
}

.sub-section.active {
  display: block;
  animation: slideIn 0.4s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}

.sub-section h3 {
  color: var(--primary);
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 1.4rem;
}

/* FORMULARIOS */
.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text);
}

input, select {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  transition: all 0.3s;
  background: white;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

button {
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  width: 100%;
  margin-top: 10px;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(46, 125, 50, 0.3);
}

button:active {
  transform: translateY(0);
}

/* FORMULARIO DE DISPOSITIVOS */
.device-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.device-form label {
  grid-column: 1 / -1;
}

.time-inputs {
  display: flex;
  gap: 15px;
  grid-column: 1 / -1;
}

.time-inputs input {
  flex: 1;
}

.guardar-btn {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--secondary), #ffb74d);
}

.guardar-btn:hover {
  box-shadow: 0 5px 15px rgba(255, 152, 0, 0.3);
}

/* GRÁFICA */
.grafica-container {
  background: white;
  padding: 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

canvas {
  width: 100%;
  height: 400px;
}

/* HISTORIAL */
.historial-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  overflow: hidden;
}

.historial-table th {
  background: var(--primary);
  color: white;
  padding: 15px;
  text-align: left;
  font-weight: 600;
}

.historial-table td {
  padding: 12px 15px;
  border-bottom: 1px solid var(--border);
}

.historial-table tr:nth-child(even) {
  background: #f9f9f9;
}

.historial-table tr:hover {
  background: #f0f7f0;
}

/* FORMULARIO RECIBO */
.meter-toggle {
  display: flex;
  gap: 10px;
  margin: 20px 0;
}

.meter-btn {
  flex: 1;
  padding: 12px;
  background: white;
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s;
}

.meter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.lecturas-group-uni, .lecturas-group-bi {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin: 20px 0;
}

.lecturas-group-bi {
  display: none;
}

.lecturas-group-bi.active {
  display: grid;
}

.verano-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0;
}

.verano-toggle input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

/* RESULTADOS */
.result {
  margin-top: 20px;
  padding: 20px;
  background: #e8f5e9;
  border: 1px solid #c8e6c9;
  border-radius: 8px;
  color: #2e7d32;
  font-weight: 600;
  line-height: 1.6;
}

.result ul {
  margin: 10px 0;
  padding-left: 20px;
}

.result li {
  margin-bottom: 5px;
}

/* ICONO DE AYUDA */
.help-icon-section {
  position: absolute;
  top: 30px;
  right: 30px;
  background: var(--accent);
  color: white;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: bold;
  font-size: 18px;
  box-shadow: 0 3px 10px rgba(33, 150, 243, 0.3);
  transition: all 0.3s;
}

.help-icon-section:hover {
  transform: scale(1.1);
  box-shadow: 0 5px 15px rgba(33, 150, 243, 0.4);
}

/* MODALES */
.modal-instrucciones {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-instrucciones > div {
  background: white;
  padding: 30px;
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  animation: modalAppear 0.3s ease;
}

@keyframes modalAppear {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.modal-instrucciones h2 {
  color: var(--primary);
  margin-top: 0;
  text-align: center;
}

.modal-instrucciones button {
  margin-top: 20px;
  background: var(--primary);
}

/* AUTENTICACIÓN */
.auth-section {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: none;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(5px);
}

.auth-section.active {
  display: flex;
}

.auth-form {
  background: white;
  padding: 30px;
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
  animation: authAppear 0.4s ease;
}

@keyframes authAppear {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-options {
  display: flex;
  margin-bottom: 20px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.auth-options button {
  flex: 1;
  margin: 0;
  border-radius: 0;
  background: #f5f5f5;
  color: var(--text);
}

.auth-options button.active {
  background: var(--primary);
  color: white;
}

.password-container {
  position: relative;
}

.toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  font-size: 14px;
  margin: 0;
  width: auto;
  padding: 0;
}

.social-buttons {
  margin-top: 20px;
}

.google {
  background: #db4437;
}

.google:hover {
  box-shadow: 0 5px 15px rgba(219, 68, 55, 0.3);
}

/* ESTADOS DE DATOS */
.no-data {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
  font-style: italic;
  background: #f9f9f9;
  border-radius: 8px;
  border: 1px dashed var(--border);
}

/* RESPONSIVIDAD */
@media (max-width: 768px) {
  header {
    padding: 15px 5%;
    flex-direction: column;
    gap: 15px;
  }
  
  .logo-container {
    height: 50px;
  }
  
  .container {
    padding: 20px 5%;
  }
  
  .nav-buttons {
    flex-direction: column;
    align-items: center;
  }
  
  .nav-buttons button {
    max-width: 100%;
  }
  
  .section {
    padding: 20px;
  }
  
  .device-form {
    grid-template-columns: 1fr;
  }
  
  .lecturas-group-uni, .lecturas-group-bi {
    grid-template-columns: 1fr;
  }
  
  .sub-nav-buttons {
    flex-direction: column;
  }
  
  .help-icon-section {
    top: 20px;
    right: 20px;
    width: 30px;
    height: 30px;
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .section {
    padding: 15px;
  }
  
  .auth-form {
    padding: 20px;
  }
  
  .historial-table {
    display: block;
    overflow-x: auto;
  }
}

/* Estilos adicionales para autenticación */
.close-auth {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.close-auth:hover {
    color: #333;
}

.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 10px;
    border-radius: 4px;
    margin: 10px 0;
    border: 1px solid #ffcdd2;
    font-size: 14px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(255,255,255,0.2);
    border-radius: 30px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid white;
}

.user-name {
    color: white;
    font-weight: bold;
}

.form-group {
    margin-bottom: 15px;
}

.google {
    background: white;
    color: #757575;
    border: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
}

.google:hover {
    background: #f5f5f5;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.auth-buttons {
    display: flex;
    gap: 10px;
}

/* Estilos para la sección de configuración */
.profile-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.avatar-container {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.danger-zone {
    border-left: 4px solid #f44336;
}

/* Asegurar que el logo se muestre correctamente */
.site-logo {
    height: 60px;
    width: auto;
    max-width: 200px;
}

/* Si el logo no carga, mostrar texto alternativo */
.logo-container:after {
    content: "Energysim";
    font-size: 24px;
    font-weight: bold;
    color: white;
    display: none;
}

.logo-container:has(.site-logo[style*="display: none"]):after {
    display: block;
}