/* public/css/monitor.css — Estilos exclusivos de la página de monitoreo */

.schedule-pill {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--text2);
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 5px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.btn-seguimiento {
  background: linear-gradient(135deg, #1e3a5f, #2a4a7f);
  color: #7eb8f7;
  border: 1px solid #2e5090;
  font-size: .9rem;
  font-weight: 600;
  padding: 11px 28px;
}
.btn-seguimiento:hover {
  background: linear-gradient(135deg, #2a4a7f, #3a5a9f);
  color: #aaccff;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  display: inline-block;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

.refreshing-bar {
  height: 2px;
  background: linear-gradient(90deg, var(--accent), #7eb8f7, var(--accent));
  background-size: 200%;
  animation: shimmer 1.2s infinite;
  display: none;
}
.refreshing-bar.show { display: block; }
@keyframes shimmer { 0%{background-position:200%} 100%{background-position:-200%} }

/* Badges de horas */
.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}
.b-green  { background: rgba(34,197,94,.15);  color: #4ade80; }
.b-yellow { background: rgba(234,179,8,.15);  color: #fbbf24; }
.b-orange { background: rgba(245,158,11,.15); color: #fb923c; }
.b-red    { background: rgba(252, 41, 41, 0.15);  color: #f87171; }

/* ID copiable */
.td-id { font-family: var(--mono); font-size: .72rem; }
.td-id span {
  background: rgba(79,126,248,.15);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
}
.td-id span:hover { background: rgba(79,126,248,.28); }

/* Mapa y acciones en tabla */
.td-actions-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.map-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  color: var(--accent);
  padding: 4px 10px;
  border: 1px solid var(--border2);
  border-radius: 6px;
  background: var(--surface2);
  transition: all .2s;
  text-decoration: none;
}
.map-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.speed-val { font-family: var(--mono); font-size: .75rem; color: var(--text2); }

/* Controles de búsqueda */
.controls { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.search-box {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 8px 14px;
  color: var(--text);
  font-family: var(--sans);
  font-size: .82rem;
  outline: none;
  width: 220px;
}
.search-box:focus { border-color: var(--accent); }
.search-box::placeholder { color: var(--text3); }

.filter-group { display: flex; gap: 6px; flex-wrap: wrap; }
.fbtn-mon {
  padding: 7px 14px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text2);
  transition: all .2s;
  font-family: var(--sans);
}
.fbtn-mon:hover { border-color: var(--text3); color: var(--text); }
.fbtn-mon.active { color: #fff; border-color: transparent; }
.fbtn-mon.f-all.active    { background: var(--surface2); border-color: var(--border2); color: var(--text); }
.fbtn-mon.f-red.active    { background: var(--red); }
.fbtn-mon.f-orange.active { background: #dd8500;}
.fbtn-mon.f-yellow.active { background: #dbb300; }
.fbtn-mon.f-green.active  { background: #16a34a; }

/* ── Botón copiar nombre/placa (a la izquierda del texto) ── */
.td-name { white-space: nowrap; }
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-right: 9px;
  vertical-align: middle;
  border: 1px solid var(--border2);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text2);
  font-size: .8rem;
  line-height: 1;
  cursor: pointer;
  transition: all .15s;
  flex-shrink: 0;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); background: rgba(79,126,248,.14); }
.copy-btn:active { transform: scale(.88); }
.name-text { vertical-align: middle; }

/* ── Fila revisada — color que se mantiene hasta el otro día ── */
tr.reviewed td { background: rgba(34,197,94,.12) !important; }
tr.reviewed:hover td { background: rgba(34,197,94,.18) !important; }
tr.reviewed .td-name { box-shadow: inset 3px 0 0 var(--green); }
tr.reviewed .copy-btn {
  color: var(--green);
  border-color: rgba(34,197,94,.45);
  background: rgba(34,197,94,.14);
}

/* ── Fila sin información de fecha ── */
.row-sininfo { background: rgba(79,126,248,.04) !important; }
.row-sininfo:hover { background: rgba(79,126,248,.08) !important; }

/* Badge sin fecha */
.b-nodate { background: rgba(79,126,248,.15); color: #93b4fb; }

/* Botón + Seguimiento */
.btn-seg {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: rgba(79,126,248,.12);
  color: var(--accent);
  border: 1px solid rgba(79,126,248,.3);
  border-radius: 6px;
  font-family: var(--sans);
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all .2s;
}
.btn-seg:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-seg:active { transform: scale(.96); }

/* ── Columna y badge de Modo Ahorro de Energía ── */
.td-sleep {
  white-space: nowrap;
}
.sleep-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(14, 165, 233, 0.28);
  color: #38bdf8;
  padding: 4px 10px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: .74rem;
  font-weight: 500;
  letter-spacing: -0.2px;
}
.sleep-badge svg {
  color: #38bdf8;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════════════════════
   REGLAS RESPONSIVE PARA MONITOR & AHORRO (GUIA_RESPONSIVE.md)
   ══════════════════════════════════════════════════════════════════════════════ */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.table-wrap table {
  min-width: 720px;
}

/* ── Pantallas Medianas / Tablet (<= 1023px) ── */
@media (max-width: 1023px) {
  .controls {
    gap: 8px;
  }
}

/* ── Móvil y Tablet Pequeña (<= 767px) ── */
@media (max-width: 767px) {
  .controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    width: 100%;
  }

  .search-box {
    width: 100% !important;
    min-height: var(--touch-size);
    box-sizing: border-box;
  }

  .filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
  }

  .fbtn-mon {
    flex: 1 1 calc(33.333% - 6px);
    min-height: 38px;
    padding: 8px 10px;
    text-align: center;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .table-wrap {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .table-wrap table {
    min-width: 440px;
    width: 100%;
    font-size: 0.78rem;
  }

  /* Ocultar número de fila, ID y velocidad en móvil para priorizar dispositivo y estado */
  .th-num, .td-num,
  .th-id, .td-id,
  .th-speed, .td-speed {
    display: none !important;
  }

  /* Columna de Dispositivo fija (Sticky) a la izquierda para que nunca se oculte */
  .th-name, .td-name {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #101528;
    min-width: 135px;
    max-width: 160px;
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.45);
    padding: 8px 6px !important;
  }

  tbody tr:nth-child(odd) .td-name {
    background: #101528;
  }

  tbody tr:nth-child(even) .td-name {
    background: #1a223d;
  }

  [data-theme="light"] tbody tr:nth-child(odd) .td-name {
    background: #ffffff;
    box-shadow: 2px 0 6px rgba(15, 23, 42, 0.08);
  }

  [data-theme="light"] tbody tr:nth-child(even) .td-name {
    background: #f1f5f9;
    box-shadow: 2px 0 6px rgba(15, 23, 42, 0.08);
  }

  thead th.th-name {
    z-index: 4;
    background: #171b30 !important;
  }

  [data-theme="light"] thead th.th-name {
    background: #f8fafc !important;
    box-shadow: 2px 0 6px rgba(15, 23, 42, 0.08);
  }

  .th-date, .td-date {
    display: table-cell !important;
    font-size: 0.68rem;
    padding: 6px 6px;
    white-space: normal;
    line-height: 1.25;
    min-width: 105px;
  }

  .th-hours, .td-hours {
    display: table-cell !important;
    padding: 6px 4px;
    text-align: center;
    min-width: 75px;
  }

  .td-hours .badge {
    padding: 3px 6px;
    font-size: 0.70rem;
    white-space: nowrap;
  }

  .th-action, .td-action {
    display: table-cell !important;
    padding: 6px 6px;
    text-align: center;
    min-width: 60px;
  }

  .map-btn {
    padding: 4px 8px;
    font-size: 0.70rem;
    min-height: 28px;
  }

  .copy-btn {
    width: 22px;
    height: 22px;
    margin-right: 4px;
    font-size: 0.75rem;
  }

  .name-text {
    font-size: 0.78rem;
    word-break: break-word;
  }
}

/* ── Móvil Compacto (<= 480px) ── */
@media (max-width: 480px) {
  .fbtn-mon {
    flex: 1 1 calc(50% - 6px);
  }
}

/* ==========================================================================
   MODO DÍA (LIGHT MODE) — MONITOREO GPS
   ========================================================================== */
[data-theme="light"] .schedule-pill {
  background: #ffffff;
  border-color: var(--border);
  color: #475569;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .btn-seguimiento {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #ffffff;
  border-color: #1d4ed8;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

[data-theme="light"] .btn-seguimiento:hover {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

[data-theme="light"] .status-bar {
  background: #ffffff;
  border-color: var(--border);
}

[data-theme="light"] .map-btn,
[data-theme="light"] .copy-btn {
  background: #f1f5f9;
  border-color: var(--border2);
  color: #475569;
}

[data-theme="light"] .map-btn:hover,
[data-theme="light"] .copy-btn:hover {
  background: #eff6ff;
  border-color: var(--accent);
  color: var(--accent);
}

[data-theme="light"] .td-id span {
  background: #eff6ff;
  color: #1d4ed8;
}

[data-theme="light"] tr.reviewed td {
  background: rgba(34, 197, 94, 0.08) !important;
}

/* Badges con contraste legible en Modo Día */
[data-theme="light"] .b-green  { background: #dcfce7; color: #15803d; }
[data-theme="light"] .b-yellow { background: #fef9c3; color: #a16207; }
[data-theme="light"] .b-orange { background: #ffedd5; color: #c2410c; }
[data-theme="light"] .b-red    { background: #fee2e2; color: #b91c1c; }
[data-theme="light"] .b-nodate { background: #dbeafe; color: #1d4ed8; }
[data-theme="light"] .sleep-badge {
  background: #e0f2fe;
  border-color: #7dd3fc;
  color: #0369a1;
}
[data-theme="light"] .sleep-badge svg {
  color: #0284c7;
}
