/* ====== Estilo base ====== */
body {
  background:#121212;
  color:#fff;
  font-family:system-ui,Arial,sans-serif;
  margin:0;
}

/* ====== Header ====== */
header {
  background:#1f1f1f;
  padding:0.8rem 1rem;
  display:flex;
  justify-content:space-between;
  align-items:center;
  box-shadow:0 2px 4px rgba(0,0,0,0.6);
}
header h1 {
  margin:0;
  font-size:1.2rem;
}

/* ====== Navegación ====== */
nav {
  background:#222;
  display:flex;
  flex-wrap:wrap;
}
nav a {
  color:#fff;
  text-decoration:none;
  padding:0.8rem 1rem;
  display:block;
}
nav a:hover {
  background:#333;
}

/* ====== Submenús ====== */
/* ====== Submenús (como botones) ====== */
.submenu{
  display:none;
  background:#171717;
  padding:.6rem .8rem;
  border-top:1px solid #2a2a2a;
  display:none;
  gap:.6rem;
}

.submenu a{
  display:inline-flex;
  align-items:center;
  gap:.45rem;
  padding:.55rem .9rem;
  background:#2a2a2a;
  color:#fff;
  text-decoration:none;
  border:1px solid #3a3a3a;
  border-radius:10px;
  box-shadow:0 1px 0 rgba(255,255,255,0.05) inset, 0 2px 8px rgba(0,0,0,0.25);
  transition:transform .06s ease, background .15s ease, border-color .15s ease, opacity .15s;
  font-size:.97rem;
}

.submenu a:hover{
  background:#343434;
  border-color:#4a4a4a;
}

.submenu a:active{
  transform:translateY(1px);
  opacity:.9;
}

/* opcional: separa el submenú de lo demás */
.submenu + .card{
  margin-top:1rem;
}


/* ====== Tarjetas ====== */
.card {
  background: #1b1b1b;
  border-radius: 10px;
  padding: 1rem;
  width: 95%;              /* ocupa casi todo el contenedor */
  max-width: 1800px;       /* 🔧 el doble de ancho real */
  margin: 0 auto;
  box-sizing: border-box;  /* que padding no expanda el ancho */
}


#graficas-section.card {
  max-width: 1000px; /* ajusta este número para afinar el ancho */
  width: 90%;
  margin: 0 auto;
}


/* ====== Botones ====== */
button {
  border:0;
  border-radius:10px;
  padding:1rem;
  cursor:pointer;
  font-size:1rem;
  flex:1;
  margin:0.3rem;
}
.btn-green { background:#2e7d32; color:#fff; }
.btn-blue { background:#1976d2; color:#fff; }
.btn-red { background:#d32f2f; color:#fff; }
button:hover { opacity:0.85; }

.action-btn {
  font-size: 1.2rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: .4rem;
  margin: 0 .2rem;
  border-radius: 50%;
  transition: background .2s;
}
.action-btn:hover {
  background: rgba(255,255,255,0.15);
}

.action-cell { position: relative; text-align:center; }
.kebab-btn{
  font-size: 1.1rem; background:none; border:1px solid #2a2a2a; color:#fff;
  padding:.35rem .55rem; border-radius:8px; cursor:pointer;
}
.kebab-btn:hover{ background:#2a2a2a; }

.actions-menu{
  position:absolute; right:50%; transform:translateX(50%);
  top: 110%; background:#1f1f1f; border:1px solid #2a2a2a; border-radius:10px;
  min-width:130px; z-index:50; display:none; box-shadow:0 6px 18px rgba(0,0,0,.5);
}
.actions-menu.show{ display:block; }
.actions-menu button{
  width:100%; background:none; border:0; color:#fff; text-align:left;
  padding:.6rem .8rem; cursor:pointer; font-size:.95rem;
}
.actions-menu button:hover{ background:#2a2a2a; }
.actions-menu .danger{ color:#ff8a80; }


/* ===== Notificaciones ===== */
.notify {
  position: relative;
  margin-left: auto;
}
.notify-btn {
  display:inline-flex; align-items:center; gap:.5rem;
  background:#2a2a2a; color:#fff; border:1px solid #3a3a3a;
  padding:.45rem .7rem; border-radius:10px; cursor:pointer;
}
.notify-btn:hover { background:#343434; border-color:#4a4a4a; }
.notify-badge {
  background:#d32f2f; color:#fff; font-weight:700; font-size:.8rem;
  line-height:1; padding:.2rem .38rem; border-radius:999px;
}
.notify-panel {
  position:absolute; right:0; top:115%;
  background:#1e1e1e; border:1px solid #2a2a2a; border-radius:12px;
  box-shadow:0 8px 24px rgba(0,0,0,.5); min-width:290px; max-width:360px; z-index:70; display:none;
}
.notify-panel.show { display:block; }
.notify-panel header { padding:.7rem .9rem; border-bottom:1px solid #2a2a2a; font-weight:600; }
.notify-panel .item {
  display:flex; gap:.6rem; align-items:flex-start; padding:.65rem .9rem; border-bottom:1px solid #242424;
}
.notify-panel .item:last-child { border-bottom:0; }
.badge {
  font-size:.72rem; padding:.15rem .4rem; border-radius:999px; border:1px solid #444; opacity:.9;
}
.badge.fumigar { background:#263238; }
.badge.fertilizar { background:#1b5e20; }
.small { opacity:.85; font-size:.9rem; }

.history { position: relative; margin-left: .5rem; display:inline-block; }

/* ====== Login compacto ====== */
.login-wrap{
  max-width:340px;           /* más angosto que las cards normales */
  margin:10vh auto;
  padding:1rem;
}
.login-wrap h1{
  margin:.2rem 0 1rem;
  font-size:1.6rem;
}
.login-wrap label{
  font-size:.9rem;
  opacity:.9;
}
.login-wrap input{
  width:100%;
  padding:.5rem .7rem;       /* más bajo que el default */
  border-radius:8px;         /* menos redondeo */
  border:1px solid #2a2a2a;
  background:#121212;        /* oscuro, acorde al tema */
  color:#fff;
  margin:.35rem 0;
  font-size:.95rem;          /* más pequeño */
}
.login-wrap button{
  width:100%;
  padding:.6rem .8rem;       /* más bajo que el default (button global tiene 1rem) */
  font-size:.95rem;
  border-radius:8px;
  margin-top:.6rem;
}
.login-wrap .err{
  background:#3b1a1a;
  border:1px solid #5a2a2a;
  padding:.6rem;
  border-radius:8px;
  margin-bottom:.6rem;
}
/* === Ajustes compactos para login === */
.login-wrap{
  max-width:320px;       /* más angosto */
}

.login-wrap input{
  padding:.35rem .5rem;  /* menos alto */
  font-size:.9rem;       /* texto un poco más chico */
  height:32px;           /* altura fija */
}

.login-wrap button{
  padding:.5rem;         /* menos alto que el global */
  font-size:.9rem;
  height:36px;
}
/* === Inputs de login más centrados === */
.login-wrap input,
.login-wrap button{
  width: 90%;        /* que no ocupen todo el ancho */
  max-width: 260px;  /* límite máximo */
  margin: .4rem auto;/* centrados */
  display: block;    /* asegura el centrado */
}
/* === Centrar labels del login === */
.login-wrap label{
  display:block;
  text-align:center;
  margin-top:.5rem;
  font-size:.9rem;
}
/* === Centrar título y labels en login === */
.login-wrap h1{
  text-align:center;
}

.login-wrap label{
  display:block;
  text-align:center;
  margin-top:.5rem;
  font-size:.9rem;
}
/* === Inputs de login siempre blancos === */
.login-wrap input{
  background:#fff !important;   /* siempre blanco */
  color:#000 !important;        /* texto negro */
  border:1px solid #ccc;
}

/* placeholder gris */
.login-wrap input::placeholder{
  color:#888;
}

/* cuando está enfocado (clic o escribiendo), mantener blanco */
.login-wrap input:focus{
  background:#fff !important;
  color:#000 !important;
  outline:2px solid #1976d2;   /* opcional: resalta azul al enfocar */
}
/* Historial: botones compactos y sin salto de línea */
#histTabla td:last-child { white-space: nowrap; }

#histTabla .btn-sm {
  padding: 4px 8px;    /* más delgado */
  line-height: 1;      /* baja la altura */
  font-size: 12px;     /* texto compacto */
  border-radius: 6px;
}

/* Asegura altura auto aunque las clases base tengan min-height */
#histTabla .btn-blue.btn-sm,
#histTabla .btn-green.btn-sm {
  height: auto;
  min-height: 0;
}

/* --- Tablas anchas dentro de cards --- */
.table-scroll{ padding:0; overflow-x:auto; }
.table-scroll table{ min-width: 1100px; }   /* sube/baja este valor si hace falta */

/* Card más ancho solo donde lo pidamos */
.card--xl{ max-width: 1200px; }             /* 1200px o lo que te guste */

/* Botones compactos para celdas de acciones del Programa */
#progInvTabla td:last-child{ white-space: nowrap; }
#progInvTabla .btn-sm{
  padding: 4px 8px; line-height:1; font-size:12px; border-radius:6px;
  height:auto; min-height:0;
}


/* --- Compactar pero legible --- */
#pm_table table {
  border-collapse: collapse;
  font-size: 0.95rem;           /* texto un poco más grande */
}
#pm_table table td,
#pm_table table th {
  padding: 5px 7px !important;  /* un poco más de aire */
  line-height: 1.3em !important;
  vertical-align: middle !important;
}

/* Asegura que las acciones no estiren la fila */
#pm_table table td[style*="display:flex"],
#pm_table table td:last-child {
  display: table-cell !important;
  text-align: center !important;
  white-space: nowrap;
}

/* Botones un poco más cómodos */
#pm_table .btn-sm,
#pm_table .notify-btn {
  padding: 3px 8px !important;
  font-size: 0.8rem !important;
  line-height: 1.2em !important;
  border-radius: 5px !important;
}

/* --- Riego nodos --- */
.status {
  display:flex; align-items:center; gap:.5rem; font-weight:600;
}
.status-dot {
  width:.6rem; height:.6rem; border-radius:50%; display:inline-block;
}
.status-dot.online { background:#27d17f; box-shadow:0 0 0 2px #1c7e53 inset; }
.status-dot.offline{ background:#d12727; box-shadow:0 0 0 2px #7e1c1c inset; }
.muted { opacity:.75; }
.btn-row{ display:flex; gap:.5rem; flex-wrap:wrap; }
.notify-btn[disabled]{ opacity:.5; cursor:not-allowed; }
.card.node { background:#111; border:1px solid #2a2a2a; }

/* ==== Menú de Riego con color vivo ==== */
.tabs-riego{
  display:flex; gap:.6rem; flex-wrap:wrap;
  justify-content:center;
  background:linear-gradient(180deg,#141414,#0e0e0e);
  border:1px solid #252525; border-radius:16px;
  padding:.55rem .7rem; margin:1rem auto; max-width:820px;
  box-shadow:0 8px 22px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.05);
}
.tabs-riego .tab-btn{
  --r:12px;
  display:inline-flex; align-items:center; gap:.55rem;
  padding:.6rem 1rem;
  background:linear-gradient(180deg,#1e1e1e,#181818);
  color:#d4f8e8; text-decoration:none; font-weight:600;
  border:1px solid #2a2a2a; border-radius:var(--r);
  box-shadow:0 1px 0 rgba(255,255,255,.05) inset, 0 2px 8px rgba(0,0,0,.3);
  transition:
    transform .08s ease,
    background .2s ease,
    border-color .2s ease,
    box-shadow .2s ease,
    color .2s ease;
}
.tabs-riego .tab-btn:hover{
  background:linear-gradient(180deg,#232323,#1b1b1b);
  border-color:#3a3a3a;
  color:#aef8d6;
  box-shadow:0 0 10px rgba(39,209,127,.25);
}
.tabs-riego .tab-btn:active{ transform:translateY(1px); opacity:.95; }

.tabs-riego .tab-btn.active{
  background:linear-gradient(180deg,#17352a,#10261d);
  border-color:#27d17f;
  color:#ffffff;
  box-shadow:0 0 0 2px rgba(39,209,127,.35), 0 8px 20px rgba(39,209,127,.25);
}
.tabs-riego .tab-btn .dot{
  width:.5rem; height:.5rem; border-radius:50%;
  background:#27d17f;
  box-shadow:0 0 6px rgba(39,209,127,.8);
}
@media (max-width:600px){
  .tabs-riego{padding:.4rem;}
  .tabs-riego .tab-btn{padding:.5rem .8rem; font-size:.95rem;}
}
.nodes-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

.card.node {
  background: #1e1e1e;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 1rem;
  text-align: left;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.card.node h3 {
  margin: 0.2rem 0;
  font-size: 1.1rem;
  color: #fff;
}

.card.node .detalles {
  font-size: 0.9rem;
  color: #aaa;
  margin: 0.5rem 0;
}

.card.node .btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.card.node .btn-row .notify-btn {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  border-radius: 8px;
}

.card.node .status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.card.node.online {
  border-left: 4px solid #27d17f;
}

.card.node.offline {
  border-left: 4px solid #d12727;
}

@media (max-width: 600px) {
  .nodes-container {
    grid-template-columns: 1fr;
  }
}
.filter-container {
  margin-bottom: 1rem;
  text-align: center;
  width: 100%;
}

.filter-container label,
.filter-container select {
  display: inline-block;
  vertical-align: middle;
}

.filter-container select {
  margin-left: 0.5rem;
  padding: 0.3rem;
}
.program-card {
  background: #1e1e1e;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 600px;
  margin: 0 auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.program-card h3 {
  color: #fff;
  margin-bottom: 1rem;
  text-align: center;
}

.program-card label {
  display: block;
  margin-bottom: 0.8rem;
  color: #aaa;
}

.program-card input[type="time"],
.program-card input[type="number"],
.program-card select {
  width: 100%;
  padding: 0.5rem;
  background: #2a2a2a;
  border: 1px solid #333;
  border-radius: 4px;
  color: #fff;
}

.program-card select[multiple] {
  height: 100px;
}

.program-card .notify-btn {
  background: #007bff;
  color: white;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  width: auto;
  display: inline-block;
  margin: 0 auto;
}

.program-card .notify-btn:hover {
  background: #0056b3;
}

.programs-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.programs-table th,
.programs-table td {
  padding: 0.5rem;
  border: 1px solid #2a2a2a;
  color: #fff;
  text-align: left;
}

.programs-table th {
  background: #2a2a2a;
}

.programs-table .delete-btn {
  background: #b32020;
  padding: 0.2rem 0.5rem;
  border: none;
  border-radius: 4px;
  color: white;
  cursor: pointer;
}

.programs-table .delete-btn:hover {
  background: #8b0000;
}

/* overlay modal (por defecto oculto) */
.modal {
  display: none;              /* oculto por defecto */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.98); /* muy opaco */
  z-index: 10000;             /* bien arriba */
  align-items: center;        /* centrar vertical */
  justify-content: center;    /* centrar horizontal */
  padding: 1rem;              /* espacio alrededor en pantallas pequeñas */
  box-sizing: border-box;
}

/* cuando tenga la clase .open se muestra como flex (centra contenido) */
.modal.open {
  display: flex;
}

/* ventana interna del modal */
.modal-content {
  background: #181818;       /* opaco, sin transparencia */
  border: 1px solid #3a3a3a;
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 500px;
  width: 100%;
  position: relative;
  box-shadow: 0 2px 12px rgba(0,0,0,0.6);
  z-index: 10001;            /* por encima del overlay (por si acaso) */
}

.modal-content label {
  color: #ccc; /* Texto más claro para mejor contraste */
  margin-bottom: 0.8rem;
  display: block;
}

.modal-content input[type="time"],
.modal-content input[type="number"],
.modal-content select {
  width: 100%;
  padding: 0.5rem;
  background: #3d3d3d; /* Fondo más claro para inputs */
  border: 1px solid #555;
  border-radius: 4px;
  color: #fff;
  margin-bottom: 0.8rem;
}

.modal-content select[multiple] {
  height: 100px;
}

.modal-content .notify-btn {
  background: #007bff;
  color: white;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
  margin-right: 0.5rem;
}

.modal-content .notify-btn:hover {
  background: #0056b3;
}

.close-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: #b32020;
  border: none;
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
}

.close-btn:hover {
  background: #8b0000;
}

/* Estilos para la sección de gráficas */
#graficas-section {
  padding: 1rem;
  max-width: 700px; /* Ajustar al tamaño del canvas */
  margin: 1.5rem auto;
}

/* Estilos para el formulario de filtros */
.filter-container {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.filter-container label {
  display: flex;
  gap: 0.3rem;
  align-items: center;
  color: #ccc;
  font-size: 0.95rem;
}

.filter-container select,
.filter-container input[type="date"] {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  color: #fff;
  padding: 0.4rem;
  font-size: 0.9rem;
}

.filter-container button {
  background: #007bff;
  color: white;
  border: none;
  padding: 0.4rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}

.filter-container button:hover {
  background: #0056b3;
}

/* Ajustar canvas para que no se desborde */
#humidity-chart {
  max-width: 100%;
  height: auto;
}

button {
  background: #1976d2;
  color: #fff;
  border: 0;
  padding: .6rem 1.4rem;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.2s;
}
button:hover {
  background: #1e88e5;
}

.notify-btn {
  text-decoration: none;        /* 🔹 quita el subrayado */
  background: #222;
  border: 1px solid #555;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  padding: 0.4rem 0.8rem;
  transition: background 0.2s, transform 0.2s;
}

.notify-btn:hover {
  background: #1e88e5;
  text-decoration: none;        /* 🔹 asegura que no aparezca en hover */
  transform: translateY(-1px);
}
#humidity-chart {
  width: 100%;
  height: 100%;
}
.grafica-container {
  position: relative;
  height: 420px;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

/* --- Forzar alineación de todas las secciones dentro del viewport --- */
#seccion, #graficas-section, #historial-section {
  overflow-x: hidden;
  width: 100%;
  max-width: 1800px;   /* antes 1100px → ahora casi el doble */
  margin: 0 auto;
  box-sizing: border-box;
  padding: 0 10px;
}


/* Asegura que las tablas no rompan el flujo */
#histRows {
  overflow-x: auto;
  display: block;
  max-width: 100%;
  box-sizing: border-box;
}

#histRows table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

/* Previene el scroll lateral global */
html, body {
  overflow-x: hidden !important;
}
