/* ===================== MÓVIL ===================== */
.mobile-cards {
  display: none;
}

#bottom-bar {
  display: none;
}

@media (max-width: 768px) {

  body {
    font-size: 13px;
  }

  h1 { 
    font-size: 26px;
    margin-top: 1px; 
    margin-bottom: 12px; 
    color: #030349; 
  }

  body.sidebar-open #main-content,
  .sidebar-open #main-content {margin-left: 0;}

  /* ==== Sidebar OFF ==== */
  #sidebar,
  #sidebar-toggle {
    display: none;
  }

  #toggleColumns {
    display: none;
  }

  /* ===================== BARRA INFERIOR ===================== */
  #bottom-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: #0c0245;
    border-top: 1px solid rgba(255,255,255,0.1);
    justify-content: space-around;
    align-items: center;
    z-index: 1200;
  }

  #bottom-bar a {
    color: #cbd5e1;
    text-decoration: none;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: background 0.2s ease, transform 0.15s ease;
    border-radius: 30px;
    padding: 6px 8px;
  }

  #bottom-bar a:hover {
    background: rgba(255, 255, 255, 0.12);
  }

  #bottom-bar a img { width: 22px; height: 22px; }

  #bottom-bar a.active { 
    color: white; 
    font-weight: 600;       
    color: white; 
    font-weight: 600; 
    border-radius: 30px; 
    background: #fff; 
    padding: 8px 8px; 
  }

  #bottom-bar a.active:hover {
    background: #fff;
  }

  /* Enlaces de la barra inferior con texto junto al ícono (ej. Recargar mapa) */
  #bottom-bar a.bottom-bar-text {
    flex-direction: row;
    gap: 6px;
  }

  /* Botón de la barra inferior deshabilitado (ej. "ver GPS" sin piscina elegida) */
  #bottom-bar a.bottom-bar-gps-disabled {
    opacity: 0.4;
    pointer-events: none;
  }

  /* Grupo de filtros (pond + búsqueda UID) dentro de la barra inferior */
  .bottom-bar-filtros {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
  }

  #bottom-bar.bottom-bar-con-filtros {
    justify-content: center;
    gap: 30px;
    padding: 0 1px;
  }

  #bottom-bar.bottom-bar-con-filtros .bottom-bar-filtros {
    flex: 0 0 50%;
    max-width: 50%;
  }

  .bottom-bar-pond,
  .bottom-bar-search {
    flex: 1;
    min-width: 0;
  }

  .bottom-bar-pond select,
  .bottom-bar-search input {
    width: 100%;
    height: 35px;
    box-sizing: border-box;
    padding: 6px 8px;
    font-size: 14px;
    text-align: center;
    border-radius: 30px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
  }

  .bottom-bar-search input::placeholder {
    color: #cbd5e1;
  }

  .bottom-bar-pond select option {
    color: #111; /* el desplegable nativo usa fondo claro del sistema */
  }

  /* Espacio para que el contenido no quede tapado */
  #main-content {padding-bottom: 80px;}

  /* ==== CONTROLES (barra de escritorio, oculta en móvil) ==== */
  #controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  #controls label {
    justify-content: space-between;
  }

  /* La cinta de pond y el buscador de UID de escritorio quedan ocultos en
     móvil; la versión móvil vive ahora dentro de #bottom-bar. */
  .controls-left {
    display: none;
  }

/* ===================== CARDS ===================== */

  .cards-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .mass-actions {
    margin-top: 8px;
  }

  .mass-actions .btn-allshutdown,
  .mass-actions .btn-allstart {
    max-width: none;
  }
  /* Tres botones no entran en una fila: el ping va debajo, a lo ancho */
  .mass-actions { flex-wrap: wrap; }
  .mass-actions .btn-pingoffline { flex-basis: 100%; }

  .card {
    padding: 10px;
  }

  .card-number {
    font-size: 22px;
  }

  /* ==== OCULTAR TABLA ==== */
  table {
    display: none;
  }

  /* ==== TARJETAS DE EQUIPO ==== */
  .mobile-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .device-card.pressable {
    cursor: pointer;
  }

  .device-card.pressable:active {
    transform: scale(0.98);
    background: #e9e9e9;
  }

  .device-card {
    background: white;
    border-radius: 12px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .device-header {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
  }

  .device-status.online { color: #0b7; }
  .device-status.offline { color: #d33; }

  .device-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
  }

  /* ==== BOTONES ==== */
  .device-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
  }

  .device-actions button {
    flex: 1;
    padding: 10px;
    font-size: 14px;
  }

  /* ==== MODAL ==== */
  .modal-content {
    width: 75%;
    max-height: 85%;
  }

  /* ==== BOTÓN TOGGLE COLUMNAS ==== */
  #toggleColumns {
    bottom: 70px;
    right: 10px;
    font-size: 13px;
    padding: 6px 10px;
  }

  /* ===================== swipe ===================== */
  /* ==== SWIPE ACTIONS ==== */

  .card-swipe {
    position: relative;
    overflow: hidden;
  }

  /* Botones ocultos */
  .card-actions {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    display: flex;
    z-index: 1;
  }

  .card-actions button {
    width: 70px;
    border: none;
    color: white;
    font-size: 18px;
  }

  .action-btn-start { background: #27ae5f4b; }
  .action-btn-stop  { background: #c03a2b2f; }

  /* Pestañas del modal (Gráfico / Registro / Ubicación / Información): con 4
     no entran en una fila; se deslizan de lado sin partir el texto */
  .modal-tabs { overflow-x: auto; scrollbar-width: none; }
  .modal-tabs::-webkit-scrollbar { display: none; }
  .modal-tab-btn { flex: none; white-space: nowrap; padding: 6px 10px; }

  /* Acción a la izquierda: ping por LoRa (se abre deslizando hacia la derecha) */
  .card-actions-left {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    display: flex;
    z-index: 1;
  }
  .card-actions-left button {
    width: 70px;
    border: none;
  }
  .card-actions-left .ping-btn { background: #14b8a633; border-radius: 12px; }  /* mismo radio que .device-card */

  /* Tarjeta deslizable */
  .card-swipe .device-card {
    position: relative;
    z-index: 2;
    transition: transform 0.25s ease;
    touch-action: pan-y;
  }

  /* Estado abierto */
  .card-swipe.open .device-card {
    transform: translateX(-140px);
  }
  .card-swipe.open-left .device-card {
    transform: translateX(70px);
  }

  /* ⚠️ IMPORTANTE: desactiva scale cuando hay swipe */
  .card-swipe .device-card:active {
    transform: none;
  }

/* ===================== scroll to top button ===================== */
  #scrollTopBtn {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    right: 16px;
    width: 46px;
    height: 46px;
  }

  /* Escritorio: no swipe */
  @media (min-width: 769px) {
    .card-actions { display: none; }
    }
  
    * {
      -webkit-tap-highlight-color: transparent;
  }
}