html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f4f7f6;
  overflow: hidden;
}
#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}
#map-container {
  flex: 1;
  height: 100%;
  position: relative;
  /* PASO CLAVE: Forzar al mapa a estirarse de forma animada */
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

#sidebar {
  background: white;
  box-shadow: -2px 0 10px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  height: 100%;
  /* Sincroniza el desplazamiento físico y la desaparición de la anchura */
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
#map {
  width: 100%;
  height: 100%;
  background: #e5e3df;
}

.header {
  background-color: #2c3e50;
  color: white;
  padding: 20px;
  margin: 0;
  text-align: center;
}
.content {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
/* Panel de herramientas de Backup */
    .backup-tools {
      display: flex;
      gap: 10px;
      margin-bottom: 20px;
      background: #f8fafc;
      padding: 10px;
      border-radius: 6px;
      border: 1px dashed #cbd5e1;
    }
    .btn-backup {
      flex: 1;
      padding: 8px;
      border: 1px solid #cbd5e1;
      border-radius: 4px;
      background: white;
      cursor: pointer;
      font-weight: bold;
      font-size: 12px;
      color: #475569;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 5px;
      transition: all 0.2s;
    }
    .btn-backup:hover {
      background: #f1f5f9;
      border-color: #94a3b8;
      color: #1e293b;
    }
.card {
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
}
.surface-badge {
  background-color: #e8f8f5;
  border: 1px solid #a3e4d7;
  color: #117a65;
  padding: 10px;
  border-radius: 6px;
  font-weight: bold;
  margin-bottom: 15px;
  font-size: 15px;
  display: flex;
  justify-content: space-between;
}
.form-group {
  margin-bottom: 12px;
}
.form-group label {
  display: block;
  font-weight: bold;
  margin-bottom: 5px;
  font-size: 14px;
  color: #34495e;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-sizing: border-box;
}
.history-section {
  margin-top: 20px;
  border-top: 2px solid #ecf0f1;
  padding-top: 15px;
}
.history-title {
  font-size: 16px;
  color: #2c3e50;
  margin-bottom: 10px;
}
.inline-form {
  display: flex;
  flex-wrap: wrap; /* ← CLAVE: Permite que los inputs bajen si no caben en la fila */
  gap: 8px;        /* Espaciado uniforme de 8px entre todos los elementos */
  margin-bottom: 12px;
}

.inline-form input, 
.inline-form select {
  flex: 1 1 calc(50% - 4px); /* Por defecto, los inputs intentarán ocupar el 50% del ancho (2 por fila) */
  min-width: 140px;          /* Evita que se encojan demasiado */
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  box-sizing: border-box;
}

/* Forzar que el botón de añadir ocupe todo el ancho inferior para un diseño más limpio */
.inline-form .btn-sm {
  flex: 1 1 100%;            /* Ocupa el 100% de la fila inferior */
  height: 34px;
  margin-top: 4px;
}
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 15px;
  background: white;
}
.history-table th, .history-table td {
  border: 1px solid #ddd;
  padding: 6px;
  text-align: left;
}
.history-table th {
  background-color: #f2f2f2;
  color: #333;
}
.action-cell {
  text-align: center;
  width: 30px;
}
.btn-del-item {
  background: none;
  border: none;
  color: #e74c3c;
  cursor: pointer;
  font-weight: bold;
  font-size: 16px;
}
.btn-del-item:hover {
  color: #c0392b;
}
.btn {
  background-color: #27ae60;
  color: white;
  border: none;
  padding: 10px 15px;
  border-radius: 4px;
  cursor: pointer;
  width: 100%;
  font-weight: bold;
}
.btn:hover {
  background-color: #219653;
}
.btn-danger {
  background-color: #e74c3c;
  margin-top: 25px;
}
.btn-danger:hover {
  background-color: #c0392b;
}
.empty-state {
  text-align: center;
  color: #7f8c8d;
  margin-top: 40px;
}
/* Estilos para el Listado Maestro de Parcelas */
.parcelas-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.parcela-item {
  background: #fdfefe;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.parcela-item:hover {
  border-color: #27ae60;
  background-color: #f4fbf7;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}
.parcela-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.parcela-item-header strong {
  color: #2c3e50;
  font-size: 14px;
}
.badge-estado {
  background-color: #ebf5fb;
  color: #2980b9;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: bold;
}
.parcela-item-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #566573;
}

 /* CSS complementario para centrar y estilizar el icono dentro del botón de Leaflet */
  .pozo-draw-btn i {
    color: #2980b9;
    font-size: 14px;
    line-height: 26px; /* Centrado vertical perfecto dentro del botón estándar de 26x26px */
    display: block;
    text-align: center;
  }
  .pozo-draw-btn:hover i {
    color: #1a5276;
  }

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

#map-container {
  flex: 1; /* Esto hace que el mapa se estire automáticamente al 100% cuando el sidebar no ocupe espacio */
  height: 100%;
  position: relative;
}

#sidebar {
  width: 480px;
  min-width: 480px;
  background: white;
  box-shadow: -2px 0 10px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  height: 100%;
  
  /* Transición suave para el desplazamiento físico */
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), 
              margin-left 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.container {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Barra lateral con transición suave */
.sidebar {
    width: 300px;
    height: 100%;
    background: #f8f9fa;
    transition: margin-left 0.3s ease; /* Efecto de deslizamiento */
}

/* Clase que aplicará JavaScript para ocultarla */
.sidebar.hidden {
    margin-left: -300px; /* Se esconde hacia la izquierda */
}

/* El mapa ocupará todo el espacio disponible */
#map {
    flex-grow: 1;
    height: 100%;
}

/* BOTÓN FLOTANTE ANCLADO A LA IZQUIERDA DE FORMA FIJA */
.toggle-sidebar-btn {
  position: absolute;
  top: 20px;
left: -53px;
  z-index: 1100; /* Se mantiene por encima de las capas cartográficas */
  background-color: #ffffff;
  border: 1px solid #ccc;
  border-radius: 4px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease;
}

.toggle-sidebar-btn:hover {
  background-color: #f4f4f4;
}

/* --- MAXIMIZACIÓN EXCLUSIVA DE HISTORIAL DE RIEGOS --- */
.btn-expand-riegos {
  background: white;
  border: 1px solid #ccc;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.btn-expand-riegos:hover {
  background-color: #ebf5fb;
  border-color: #3498db;
}
.btn-expand-riegos i {
  color: #566573;
  font-size: 12px;
}

/* Telón de fondo oscuro */
.modal-overlay-riegos {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1500;
}

/* Estado maximizado flotante de la caja de riegos */
.history-section.fullscreen-section-riegos {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 85vw;
  max-width: 1000px;
  height: 75vh;
  background: white;
  z-index: 2000;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  padding: 25px;
  display: flex;
  flex-direction: column;
  margin-top: 0;
  border-top: none;
  box-sizing: border-box;
}

/* Ajustes del formulario cuando está a pantalla completa */
.fullscreen-section-riegos .inline-form {
  flex-direction: row !important;
  flex-wrap: wrap;
  align-items: flex-end;
  background: #f8fafc;
  padding: 15px;
  border-radius: 6px;
  border: 1px dashed #cbd5e1;
  gap: 10px;
}
.fullscreen-section-riegos .inline-form > div,
.fullscreen-section-riegos .inline-form > input {
  flex: 1;
  min-width: 150px;
}
.fullscreen-section-riegos .inline-form .btn-sm {
  width: auto !important;
  padding: 0 20px;
  height: 36px;
}
.fullscreen-section-riegos .history-table {
  font-size: 14px; /* Aumenta el tamaño de la tabla para lectura cómoda */
}

/* Estilos para el aviso de nueva campaña */
.prompt-anio {
  background: #f8fafc;
  border-left: 4px solid #27ae60;
  padding: 10px;
  margin-bottom: 15px;
  border-radius: 0 4px 4px 0;
  font-size: 12px;
  color: #334155;
}

