/* ============================================================
   monitoreo.css
   Estilos de los dashboards demo de "Monitoreo en tiempo real":
     - .monitoreo-mapa-page     (mapa con 17 pozos)
     - .monitoreo-slideshow-page (kiosko fullscreen)
   Respeta las variables de tema (--surface, --ink, --primary, etc.)
   definidas en core/static/core/css/base.css para funcionar en
   claro/oscuro sin cambios.
   ============================================================ */

/* --------- Puntos "en vivo" compartidos --------- */
.mon-live-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, .55);
  animation: mon-pulse 1.8s ease-out infinite;
  vertical-align: middle;
  margin-right: .35rem;
}
@keyframes mon-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.55); }
  70%  { box-shadow: 0 0 0 10px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* ==========================================================
   1) DASHBOARD MAPA
   ========================================================== */
.monitoreo-mapa-page .mon-card {
  border: 0;
  border-radius: 14px;
  background: var(--surface, #fff);
  box-shadow: 0 8px 28px rgba(16, 18, 19, .06);
  overflow: hidden;
}
[data-theme="dark"] .monitoreo-mapa-page .mon-card {
  box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
}

.mon-map-toolbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: var(--surface-alt, #fafbfd);
  flex-wrap: wrap;
}
[data-theme="dark"] .mon-map-toolbar {
  background: var(--surface-2, #1e232b);
  border-bottom-color: var(--border, #2a3038);
}
@media (max-width: 575.98px) {
  .mon-map-toolbar { padding: .5rem; gap: .5rem; }
}

.mon-map-search {
  position: relative;
  flex: 1 1 240px;
  min-width: 220px;
}
.mon-map-search > i.fas {
  position: absolute;
  left: .7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted, #64748b);
  pointer-events: none;
  font-size: .8rem;
}
.mon-map-search input {
  padding-left: 2rem;
  background: var(--surface, #fff);
  border-color: var(--border, #e5e7eb);
}
.mon-map-legend {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}
@media (max-width: 575.98px) {
  .mon-map-legend { gap: .5rem; width: 100%; justify-content: space-between; }
  .mon-legend-item { font-size: .7rem; }
}
.mon-legend-item {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .75rem;
  color: var(--muted, #64748b);
}
.mon-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.mon-legend-dot.ok   { background: #22c55e; }
.mon-legend-dot.warn { background: #f59e0b; }
.mon-legend-dot.err  { background: #ef4444; }

.mon-map-canvas {
  height: 600px;
  width: 100%;
}
@media (max-width: 991.98px) {
  .mon-map-canvas { height: 500px; }
}
@media (max-width: 575.98px) {
  .mon-map-canvas { height: calc(100vh - 280px); min-height: 400px; }
}

/* ---- Marcadores dinámicos por estado ---- */
.custom-marker-icon.mon-well {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #fff;
  border: 3px solid #22c55e;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .2);
  font-size: .8rem;
}
.custom-marker-icon.mon-well.ok   { border-color: #22c55e; color: #16a34a; background: #ecfdf5; }
.custom-marker-icon.mon-well.warn { border-color: #f59e0b; color: #b45309; background: #fffbeb; }
.custom-marker-icon.mon-well.err  { border-color: #ef4444; color: #b91c1c; background: #fef2f2; animation: mon-marker-alarm 1.4s ease-in-out infinite; }
@keyframes mon-marker-alarm {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, .5); }
  50%      { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ---- Popup "vivo" ---- */
.mon-popup .leaflet-popup-content-wrapper {
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 14px 44px rgba(0, 0, 0, .18);
  background: var(--surface, #fff);
}
.mon-popup .leaflet-popup-content { margin: 0; width: 320px !important; }
.mon-popup-head {
  padding: .75rem 1rem;
  background: linear-gradient(135deg, var(--primary, #3b82f6), #1d4ed8);
  color: #fff;
}
.mon-popup-head h6 {
  margin: 0;
  font-size: .95rem;
  font-weight: 700;
}
.mon-popup-head small {
  display: block;
  opacity: .85;
  font-size: .72rem;
  margin-top: .15rem;
}
.mon-popup-body {
  padding: .65rem .85rem .85rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem .75rem;
}
.mon-popup-cell {
  background: var(--surface-2, #f8fafc);
  border-radius: 8px;
  padding: .5rem .6rem;
}
[data-theme="dark"] .mon-popup-cell { background: var(--surface-alt, #1b2028); }
.mon-popup-label {
  display: flex;
  align-items: center;
  gap: .25rem;
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted, #64748b);
  font-weight: 600;
}
.mon-popup-value {
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink, #0f172a);
  font-variant-numeric: tabular-nums;
  margin-top: .1rem;
}
[data-theme="dark"] .mon-popup-value { color: #f1f5f9; }
.mon-popup-unit {
  font-weight: 500;
  font-size: .7rem;
  color: var(--muted, #64748b);
  margin-left: .15rem;
}
.mon-popup-footer {
  padding: .4rem .85rem .75rem;
  border-top: 1px solid var(--border, #e5e7eb);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .7rem;
  color: var(--muted, #64748b);
}
[data-theme="dark"] .mon-popup-footer { border-top-color: #2a3038; }

/* ---- Panel lateral con lista de pozos ---- */
.mon-panel-list { border: 0; border-radius: 14px; }
.mon-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
[data-theme="dark"] .mon-panel-head { border-bottom-color: #2a3038; }
.mon-panel-body {
  max-height: 620px;
  overflow-y: auto;
  padding: .5rem;
}
@media (max-width: 991.98px) {
  .mon-panel-body { max-height: 400px; }
}
.mon-list-item {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: .6rem;
  align-items: center;
  padding: .55rem .6rem;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.mon-list-item:hover {
  background: var(--surface-alt, #f8fafc);
  border-color: var(--border, #e5e7eb);
}
[data-theme="dark"] .mon-list-item:hover {
  background: var(--surface-2, #1e232b);
  border-color: #2a3038;
}
.mon-list-item.is-active {
  background: rgba(59, 130, 246, .08);
  border-color: rgba(59, 130, 246, .25);
}
.mon-list-item .mon-list-dot {
  width: 10px; height: 10px; border-radius: 50%;
}
.mon-list-item .mon-list-dot.ok   { background: #22c55e; }
.mon-list-item .mon-list-dot.warn { background: #f59e0b; }
.mon-list-item .mon-list-dot.err  { background: #ef4444; animation: mon-pulse 1.4s ease-out infinite; }
.mon-list-item .mon-list-title {
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink, #0f172a);
  line-height: 1.2;
  margin: 0;
}
[data-theme="dark"] .mon-list-item .mon-list-title { color: #f1f5f9; }
.mon-list-item .mon-list-sub {
  font-size: .7rem;
  color: var(--muted, #64748b);
  margin-top: .1rem;
}
.mon-list-item .mon-list-metric {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: .75rem;
  color: var(--muted, #64748b);
}
.mon-list-item .mon-list-metric strong {
  display: block;
  font-size: .88rem;
  color: var(--ink, #0f172a);
  font-weight: 700;
}
[data-theme="dark"] .mon-list-item .mon-list-metric strong { color: #f1f5f9; }

/* ==========================================================
   2) DASHBOARD SLIDESHOW (kiosko)
   ========================================================== */
.monitoreo-slideshow-page {
  min-height: calc(100vh - 56px - 3rem);
  margin: -1.25rem -1.5rem -1.5rem;
  padding: 1.25rem 1.5rem 1.5rem;
  background: 
    radial-gradient(ellipse at top right, rgba(67, 97, 238, 0.08), transparent 60%),
    radial-gradient(ellipse at bottom left, rgba(22, 197, 94, 0.05), transparent 55%),
    linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  color: var(--ink, #0f172a);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-radius: 0;
  position: relative;
  overflow: hidden;
}

[data-theme="dark"] .monitoreo-slideshow-page {
  background:
    radial-gradient(ellipse at top right, rgba(59, 130, 246, .12), transparent 60%),
    radial-gradient(ellipse at bottom left, rgba(16, 185, 129, .1), transparent 55%),
    linear-gradient(180deg, #0b1020 0%, #0f172a 100%);
  color: #e2e8f0;
}

.slideshow-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
}
.slideshow-header-left {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  min-width: 0;
  flex: 1 1 420px;
}
.slideshow-brand {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: rgba(34, 197, 94, .14);
  color: #86efac;
  padding: .3rem .6rem;
  border-radius: 999px;
  font-size: .7rem;
  letter-spacing: .12em;
  font-weight: 700;
  width: max-content;
  border: 1px solid rgba(34, 197, 94, .25);
}
.slideshow-brand-label { line-height: 1; }
.slideshow-pozo-title h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3.2vw, 2.6rem);
  font-weight: 700;
  color: var(--ink, #0f172a);
  letter-spacing: -0.02em;
  line-height: 1.1;
  word-break: break-word;
}
[data-theme="dark"] .slideshow-pozo-title h1 {
  color: #f8fafc;
}
.slideshow-pozo-meta {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: .5rem;
}
.slideshow-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  padding: .3rem .65rem;
  border-radius: 8px;
  color: var(--ink-muted, #64748b);
  font-size: .8rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.slideshow-meta-chip i { color: var(--primary, #4361ee); }

[data-theme="dark"] .slideshow-meta-chip {
  background: rgba(255, 255, 255, .05);
  border-color: rgba(255, 255, 255, .08);
  color: #cbd5e1;
  box-shadow: none;
}
[data-theme="dark"] .slideshow-meta-chip i { color: #93c5fd; }

.slideshow-header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .6rem;
}
.slideshow-counter {
  font-family: 'Handjet', 'Courier New', monospace;
  font-weight: 500;
  line-height: 1;
  color: var(--ink, #0f172a);
}
.slideshow-counter-current {
  font-size: clamp(2rem, 4.2vw, 3.4rem);
  color: var(--primary, #4361ee);
}
.slideshow-counter-sep {
  font-size: clamp(1.4rem, 2.8vw, 2.2rem);
  opacity: .4;
  margin: 0 .2rem;
}
.slideshow-counter-total {
  font-size: clamp(1.4rem, 2.8vw, 2.2rem);
  opacity: .7;
}
[data-theme="dark"] .slideshow-counter { color: #fff; }
[data-theme="dark"] .slideshow-counter-current { color: #60a5fa; }
.slideshow-controls {
  display: flex;
  gap: .4rem;
}
.slideshow-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(0,0,0,0.1));
  color: var(--ink-muted, #64748b);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .15s ease;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.slideshow-btn:hover {
  background: var(--surface-2, #f1f5f9);
  color: var(--primary, #4361ee);
  transform: translateY(-1px);
}
.slideshow-btn-play {
  background: rgba(67, 97, 238, 0.1);
  border-color: rgba(67, 97, 238, 0.2);
  color: var(--primary, #4361ee);
}
.slideshow-btn-play:hover { background: rgba(67, 97, 238, 0.2); }

[data-theme="dark"] .slideshow-btn {
  background: rgba(255, 255, 255, .06);
  border-color: rgba(255, 255, 255, .1);
  color: #e2e8f0;
  box-shadow: none;
}
[data-theme="dark"] .slideshow-btn:hover {
  background: rgba(255, 255, 255, .12);
  color: #fff;
}
[data-theme="dark"] .slideshow-btn-play {
  background: rgba(59, 130, 246, .3);
  border-color: rgba(59, 130, 246, .5);
  color: #dbeafe;
}
[data-theme="dark"] .slideshow-btn-play:hover { background: rgba(59, 130, 246, .5); }

/* Barra de progreso */
.slideshow-progress {
  height: 4px;
  background: rgba(255, 255, 255, .05);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.slideshow-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #22c55e, #60a5fa, #a855f7);
  transition: width .15s linear;
  box-shadow: 0 0 16px rgba(96, 165, 250, .5);
}

/* Grid 3x2 de métricas */
.slideshow-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: minmax(180px, 1fr);
  gap: 1rem;
  flex: 1 1 auto;
}
.slide-metric-wide { grid-column: span 1; }
@media (max-width: 1199.98px) {
  .slideshow-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 767.98px) {
  .slideshow-grid { grid-template-columns: 1fr; grid-auto-rows: auto; }
}

.slide-metric {
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(0,0,0,0.06));
  border-radius: 16px;
  padding: 1rem 1.1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  animation: slide-in-fade .4s ease-out both;
}
[data-theme="dark"] .slide-metric {
  background: linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .015));
  border-color: rgba(255, 255, 255, .06);
  backdrop-filter: blur(12px);
  box-shadow: none;
}
.slide-metric::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, #60a5fa, transparent);
  opacity: .7;
}
.slide-metric[data-metric="conductividad"]::before     { background: linear-gradient(90deg, #a855f7, transparent); }
.slide-metric[data-metric="totalizador"]::before       { background: linear-gradient(90deg, #22c55e, transparent); }
.slide-metric[data-metric="flujo_instantaneo"]::before { background: linear-gradient(90deg, #06b6d4, transparent); }
.slide-metric[data-metric="temperatura"]::before       { background: linear-gradient(90deg, #f59e0b, transparent); }
.slide-metric[data-metric="ph"]::before                { background: linear-gradient(90deg, #ec4899, transparent); }

@keyframes slide-in-fade {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.slide-metric-head {
  display: flex;
  gap: .65rem;
  align-items: flex-start;
}
.slide-metric-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(96, 165, 250, .15);
  color: #93c5fd;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.slide-metric[data-metric="conductividad"] .slide-metric-icon     { background: rgba(168, 85, 247, .15); color: #d8b4fe; }
.slide-metric[data-metric="totalizador"] .slide-metric-icon       { background: rgba(34, 197, 94, .15);  color: #86efac; }
.slide-metric[data-metric="flujo_instantaneo"] .slide-metric-icon { background: rgba(6, 182, 212, .15);  color: #67e8f9; }
.slide-metric[data-metric="temperatura"] .slide-metric-icon       { background: rgba(245, 158, 11, .15); color: #fcd34d; }
.slide-metric[data-metric="ph"] .slide-metric-icon                { background: rgba(236, 72, 153, .15); color: #f9a8d4; }

.slide-metric-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--ink, #0f172a);
  letter-spacing: .01em;
}
.slide-metric-sub {
  font-size: .7rem;
  color: var(--ink-muted, #94a3b8);
  margin-top: .1rem;
}
[data-theme="dark"] .slide-metric-title { color: #e2e8f0; }
[data-theme="dark"] .slide-metric-sub { color: #94a3b8; }

.slide-metric-value-wrap {
  display: flex;
  align-items: baseline;
  gap: .3rem;
  margin-top: auto;
  flex: 1 1 auto;
  padding: .25rem 0;
}
.slide-metric-value {
  font-family: 'Handjet', 'Courier New', monospace;
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 500;
  line-height: 1;
  color: var(--ink, #0f172a);
  font-variant-numeric: tabular-nums;
  transition: color .2s ease;
}
.slide-metric-value.is-flash { color: var(--primary, #4361ee); }
[data-theme="dark"] .slide-metric-value {
  color: #f1f5f9;
  text-shadow: 0 0 12px rgba(147, 197, 253, .3);
}
[data-theme="dark"] .slide-metric-value.is-flash { color: #60a5fa; }
.slide-metric-unit {
  font-size: .95rem;
  color: var(--ink-muted, #94a3b8);
  font-weight: 500;
}

.slide-metric-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  min-height: 28px;
}
.slide-spark {
  flex: 1 1 auto;
  max-width: 70%;
  height: 28px;
}
.slide-metric-trend {
  font-size: .7rem;
  font-weight: 600;
  color: #94a3b8;
  padding: .15rem .4rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, .04);
}
.slide-metric-trend.up   { color: #86efac; background: rgba(34, 197, 94, .12); }
.slide-metric-trend.down { color: #fca5a5; background: rgba(239, 68, 68, .12); }

/* Footer: dots y reloj */
.slideshow-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.slideshow-dots {
  display: flex;
  gap: .3rem;
  flex-wrap: wrap;
  flex: 1 1 auto;
}
.slideshow-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface-2, rgba(0, 0, 0, 0.15));
  border: 1px solid var(--border, transparent);
  cursor: pointer;
  padding: 0;
  transition: all .15s ease;
}
.slideshow-dot:hover { background: var(--border, rgba(0, 0, 0, 0.2)); }
.slideshow-dot.is-active {
  background: var(--primary, #4361ee);
  transform: scale(1.35);
  box-shadow: 0 0 10px rgba(67, 97, 238, .3);
}

[data-theme="dark"] .slideshow-dot {
  background: rgba(255, 255, 255, .15);
  border: none;
}
[data-theme="dark"] .slideshow-dot:hover { background: rgba(255, 255, 255, .3); }
[data-theme="dark"] .slideshow-dot.is-active {
  background: #60a5fa;
  box-shadow: 0 0 10px rgba(96, 165, 250, .6);
}
.slideshow-clock {
  color: var(--ink-muted, #6b7280);
  font-size: .85rem;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.slideshow-clock i { color: var(--primary, #4361ee); }

[data-theme="dark"] .slideshow-clock { color: #cbd5e1; }
[data-theme="dark"] .slideshow-clock i { color: #94a3b8; }

/* Respeto al tema claro: Ahora el slideshow se adapta dinámicamente. */
/* ==========================================================
   3) MEJORAS MAPA SMA (Pulsos y Tooltips)
   ========================================================== */
.mon-marker-pulse {
  animation: mon-marker-alarm 1.4s ease-in-out infinite;
}

.mon-map-tooltip {
  background: rgba(15, 23, 42, 0.9) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: white !important;
  font-weight: 600 !important;
  font-size: 0.75rem !important;
  border-radius: 6px !important;
  padding: 2px 8px !important;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3) !important;
}

.mon-map-tooltip:before {
  border-top-color: rgba(15, 23, 42, 0.9) !important;
}

/* Ajustes para el modal SMA */
#modalPozoSMA .nav-tabs-bordered .nav-link.active {
  background-color: transparent;
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
}

#modalPozoSMA .card {
  transition: transform 0.2s ease;
}

#modalPozoSMA .card:hover {
  transform: translateY(-2px);
}

/* Modal responsivo - estilo nativo */
@media (max-width: 575.98px) {
  #modalPozoSMA .modal-dialog {
    margin: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
  }
  #modalPozoSMA .modal-content {
    height: 100%;
    border-radius: 0;
  }
  #modalPozoSMA .modal-body {
    overflow-y: auto;
    padding: 1rem .75rem;
  }
  #modalPozoSMA .nav-tabs-bordered .nav-link {
    padding: .5rem .75rem;
    font-size: .85rem;
  }
}
