/* ==========================================================================
   FieldMeter — Sistema Móvil y PC de Toma de Lecturas
   Estilos principales y adaptación responsiva (Mobile-first & Desktop PC)
   ========================================================================== */

:root {
  color-scheme: light;
  font-family: "DM Sans", "Trebuchet MS", -apple-system, BlinkMacSystemFont, sans-serif;
  --bg-app: #f2f6f1;
  --bg-screen: #dfeae2;
  --bg-surface: #f8fbf6;
  --bg-surface-alt: #e7f4eb;
  --primary-deep: #123e39;
  --primary-dark: #18312c;
  --primary-mid: #315e56;
  --primary-mint: #087f72;
  --accent-orange: #e56f43;
  --accent-amber: #f1b635;
  --border-subtle: #dbe6dc;
  --border-strong: #cce1d6;
  --text-main: #18312c;
  --text-muted: #73817c;
  --text-faint: #94a09b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  min-width: 320px;
  background-color: var(--bg-screen);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* Scrollbars estilizados */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(18, 62, 57, 0.15);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(18, 62, 57, 0.3);
}

/* Scroll vertical en vista móvil */
.screen-scroll {
  height: calc(100dvh - 78px);
  overflow-y: auto;
  scrollbar-width: none;
}
.screen-scroll::-webkit-scrollbar {
  display: none;
}

/* ==========================================================================
   LAYOUT RESPONSIVO (MÓVIL VS PC / LAPTOP)
   ========================================================================== */

/* En pantallas móviles (< 640px) */
.fieldmeter-shell {
  position: relative;
  min-height: calc(100dvh - 56px);
  width: 100%;
  margin: 0 auto;
  background: var(--bg-app);
  color: var(--text-main);
}

/* En Modo Laptop / Pantalla dividida / PC (>= 640px): adaptación fluida sin marco de teléfono */
@media (min-width: 640px) {
  body {
    background-color: var(--bg-screen);
    height: 100vh;
    overflow: hidden;
  }

  .fieldmeter-shell {
    max-width: 100% !important;
    width: 100% !important;
    min-height: calc(100vh - 56px) !important;
    height: calc(100vh - 56px) !important;
    display: flex !important;
    flex-direction: row !important;
    border: none !important;
    box-shadow: none !important;
    background: var(--bg-app) !important;
  }

  /* El sidebar de escritorio se adapta fluidamente */
  .desktop-sidebar {
    display: flex !important;
    width: 230px;
    min-width: 230px;
    height: calc(100vh - 56px);
    flex-shrink: 0;
    flex-direction: column;
    justify-content: space-between;
    background: var(--primary-deep);
    color: #effaf0;
    padding: 16px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    position: sticky;
    top: 56px;
    z-index: 30;
    overflow-y: auto;
    overflow-x: hidden;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  }

  .desktop-sidebar::-webkit-scrollbar {
    width: 4px;
  }
  .desktop-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 99px;
  }

  .desktop-sidebar.collapsed {
    margin-left: -230px !important;
    opacity: 0;
    pointer-events: none;
  }

  /* El contenedor principal de contenido en PC y pantalla dividida se vuelve fluido y scrolleable */
  .desktop-main-wrapper {
    flex: 1;
    min-width: 0;
    height: calc(100vh - 56px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: var(--bg-app);
  }

  /* El contenido de las pantallas no usa el scroll limitado del celular */
  .screen-scroll {
    height: auto !important;
    overflow-y: visible !important;
    padding-bottom: 40px !important;
  }
}

/* En pantallas de escritorio amplias (>= 1024px) */
@media (min-width: 1024px) {
  .desktop-sidebar {
    width: 280px;
    min-width: 280px;
    padding: 24px;
  }
}

/* ==========================================================================
   COMPONENTES Y UTILIDADES DE DISEÑO
   ========================================================================== */

/* Animación de entrada de pestañas */
.tab-panel {
  animation: rise-in 220ms ease-out both;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Efecto al presionar botones táctiles */
.button-pop {
  transition: transform 0.15s cubic-bezier(0.2, 0.8, 0.2, 1), background-color 0.15s ease, opacity 0.15s ease;
}
.button-pop:active {
  transform: scale(0.97);
}

/* Estilos de la simulación del mapa cartográfico */
.map-grid {
  background-image:
    linear-gradient(rgba(86, 124, 104, 0.11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(86, 124, 104, 0.11) 1px, transparent 1px);
  background-size: 24px 24px;
}

.map-road {
  position: absolute;
  height: 5px;
  transform-origin: left center;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 1px rgba(122, 150, 131, 0.15);
}

/* Tarjetas con sombras suaves estilo FieldMeter */
.card-soft {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.card-soft:hover {
  border-color: var(--border-strong);
}

/* Input numérico de lectura grande */
.dial-input {
  font-family: "IBM Plex Mono", monospace;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

/* Indicadores de pulso para estado online/offline */
.pulse-dot {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

/* ==========================================================================
   Iconos SVG responsivos garantizados (Mobile & Desktop)
   ========================================================================== */
svg {
  display: inline-block;
  vertical-align: middle;
}

span.inline-flex > svg {
  width: 100% !important;
  height: 100% !important;
  display: block !important;
  flex-shrink: 0;
}

/* Barra inferior móvil fixed para asegurar visibilidad en cualquier dispositivo */
@media (max-width: 639px) {
  nav.sm\:hidden {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 50 !important;
  }
}

