/* ══════════════════════════════════════════════════════
   📱  NATIVE APP FEEL — propiedades que eliminan
       comportamiento web y emulan app nativa
══════════════════════════════════════════════════════ */
html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  /* Disable pinch-to-zoom (native apps don't zoom) */
  touch-action: manipulation;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
  background: var(--body-bg, #f4f6fb);
  color: var(--text-color, #1a1a2e);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  overscroll-behavior-x: none;
  /* Prevent text selection on non-input elements */
  -webkit-user-select: none;
  user-select: none;
  /* Prevent long-press context menu */
  -webkit-touch-callout: none;
  /* Prevent image drag */
  -webkit-user-drag: none;
}

/* Re-enable text selection on inputs, textareas, and content areas */
input, textarea, select,
[contenteditable="true"],
.selectable {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* Prevent image ghost drag on long press */
img {
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}
/* Re-enable pointer events on images that need interaction */
img[onclick], a img, button img {
  pointer-events: auto;
}

/* Smooth GPU-accelerated scrolling for all scrollable containers */
.modal-content-full,
.screen {
  -webkit-overflow-scrolling: touch;
  will-change: scroll-position;
}

/* Safe area for devices with notch/status bar overlay */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Variables ── */
:root {
  --fire-red: #c0392b;
  --fire-dark: #1a1a2e;
  --fire-gold: #f39c12;
  --success: #27ae60;
  --card-bg: #ffffff;
  --body-bg: #f4f6fb;
  --text-color: #1a1a2e;
  --text-muted: #666666;
  --border-color: #e9ecef;
  --input-bg: #ffffff;
  --radius: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
  --bottom-nav-bg: #ffffff;
  --text-main: #1a1a2e;
  --bg-color: #f4f6fb;
  --glass-bg: rgba(255,255,255,0.7);
  --glass-border: rgba(255,255,255,0.3);
}

@media (prefers-color-scheme: dark) {
  :root {
    --card-bg: #2c3e50;
    --body-bg: #1a1a2e;
    --text-color: #f8f9fa;
    --text-muted: #adb5bd;
    --border-color: #34495e;
    --input-bg: #34495e;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    --bottom-nav-bg: #2c3e50;
    --text-main: #f8f9fa;
    --bg-color: #1a1a2e;
    --glass-bg: rgba(44,62,80,0.7);
    --glass-border: rgba(52,73,94,0.3);
  }

  /* Alert dark overrides */
  .alert-danger {
    background: #4a1c1c;
    color: #f5b7b1;
    border-color: #922b21;
  }
  .alert-success {
    background: #1a3a2a;
    color: #82e0aa;
    border-color: #1e8449;
  }
  .alert-warning {
    background: #3a3520;
    color: #f9e79f;
    border-color: #7d6608;
  }
  .alert-info {
    background: #1a2e3a;
    color: #85c1e9;
    border-color: #1a5276;
  }

  /* Badge dark overrides */
  .badge-ingreso {
    background: #1a3a2a;
    color: #82e0aa;
  }
  .badge-egreso {
    background: #2c3e50;
    color: #adb5bd;
  }

  /* Fichaje icon dark overrides */
  .fichaje-icon.ingreso {
    background: #1a3a2a;
  }
  .fichaje-icon.egreso {
    background: #2c3e50;
  }

  /* GPS status dark overrides */
  .gps-ok {
    background: #1a3a2a;
    color: #82e0aa;
  }
  .gps-fail {
    background: #4a1c1c;
    color: #f5b7b1;
  }
  .gps-wait {
    background: #3a3520;
    color: #f9e79f;
  }

  /* Fichaje item border */
  .fichaje-item {
    border-bottom-color: var(--border-color);
  }

  /* FAQ dark overrides */
  .ayuda-faq-a {
    background: var(--card-bg);
    color: var(--text-muted);
    border-top-color: var(--border-color);
  }
  .ayuda-faq {
    border-color: var(--border-color);
  }
  .ayuda-tip {
    background: #1a3a2a;
    color: #82e0aa;
  }
  .ayuda-tip i {
    color: #82e0aa;
  }
  .ayuda-warning {
    background: #3a3520;
    color: #f9e79f;
  }
  .ayuda-warning i {
    color: #f9e79f;
  }
  .ayuda-idx:hover {
    background: var(--border-color);
  }
}

/* ── Utility ── */
.hidden {
  display: none !important;
}

/* ── App shell ── */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}

/* ── Screens ── */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  padding: 1.25rem 1rem 5rem;
}
.screen.active {
  display: flex;
  animation: screenEnterUp 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}
/* Dirección: izquierda → derecha (avanzar en el stack) */
.screen.active.slide-forward {
  animation-name: screenEnterRight;
}
/* Dirección: derecha → izquierda (volver) */
.screen.active.slide-back {
  animation-name: screenEnterLeft;
}

/* ── Native feel: touch feedback with spring-back ── */
.bnav-btn,
.btn, .btn-fire, .btn-outline,
.card {
  transition: transform 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.bnav-btn:active {
  transform: scale(0.92);
  transition: transform 0.06s;
}
.btn:active, .btn-fire:active, .btn-outline:active {
  transform: scale(0.96);
  transition: transform 0.06s;
}
.card:active {
  transform: scale(0.985);
  transition: transform 0.08s;
}

/* Clickable elements get native-like touch delay removal */
a, button, .btn, .card, .bnav-btn, [onclick] {
  touch-action: manipulation;
}

@keyframes screenEnterUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes screenEnterRight {
  from { opacity: 0; transform: translateX(28px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes screenEnterLeft {
  from { opacity: 0; transform: translateX(-28px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Alias legacy para código que lo llame directamente */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}

/* ── Screen header (sticky title per screen) ── */
.screen-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--body-bg);
  margin: -1.25rem -1rem 0.9rem;
  padding: 0.7rem 1rem 0.65rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.screen-header-icon {
  color: var(--fire-red);
  font-size: 1.05rem;
  line-height: 1;
}
.screen-header-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-color);
  margin: 0;
}

/* ── Back button in screen headers ── */
.screen-header-back {
  background: none;
  border: none;
  color: var(--fire-red);
  font-size: 1.35rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  line-height: 1;
  margin-right: 0.1rem;
  border-radius: 8px;
  transition: background 0.15s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.screen-header-back:active {
  background: rgba(0, 0, 0, 0.06);
  transform: scale(0.9);
}

/* ── Section-colored headers ── */
.screen-header[data-section="inicio"] { border-bottom-color: var(--section-inicio, #c0392b); }
.screen-header[data-section="historial"] { border-bottom-color: var(--section-historial, #2980b9); }
.screen-header[data-section="partes"] { border-bottom-color: var(--section-partes, #8e44ad); }
.screen-header[data-section="disponibilidad"] { border-bottom-color: var(--section-disponibilidad, #27ae60); }
.screen-header[data-section="perfil"] { border-bottom-color: var(--section-perfil, #7f8c8d); }

.screen-header[data-section="inicio"] .screen-header-icon { color: var(--section-inicio); }
.screen-header[data-section="historial"] .screen-header-icon { color: var(--section-historial); }
.screen-header[data-section="partes"] .screen-header-icon { color: var(--section-partes); }
.screen-header[data-section="disponibilidad"] .screen-header-icon { color: var(--section-disponibilidad); }
.screen-header[data-section="perfil"] .screen-header-icon { color: var(--section-perfil); }

/* Section-colored back button */
.screen-header[data-section="historial"] .screen-header-back { color: var(--section-historial); }
.screen-header[data-section="partes"] .screen-header-back { color: var(--section-partes); }
.screen-header[data-section="disponibilidad"] .screen-header-back { color: var(--section-disponibilidad); }
.screen-header[data-section="perfil"] .screen-header-back { color: var(--section-perfil); }

/* Section border for cards in each tab context */
.section-inicio .card { border-left-color: var(--section-inicio); }
.section-historial .card { border-left-color: var(--section-historial); }
.section-partes .card { border-left-color: var(--section-partes); }
.section-disponibilidad .card { border-left-color: var(--section-disponibilidad); }
.section-perfil .card { border-left-color: var(--section-perfil); }

/* ── Swipe-back visual indicator ── */
.swipe-back-indicator {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%) translateX(0);
  z-index: 99999;
  width: 36px;
  height: 60px;
  background: var(--fire-red);
  color: #fff;
  border-radius: 0 14px 14px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease-out, transform 0.1s ease-out;
  box-shadow: 2px 2px 12px rgba(0, 0, 0, 0.25);
}
.swipe-back-indicator.visible {
  opacity: 1;
  pointer-events: none;
}

/* ── Swipe edge hint for sub-screens ── */
.screen-swipe-hint {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 48px;
  background: var(--fire-red);
  opacity: 0.18;
  border-radius: 0 4px 4px 0;
  pointer-events: none;
  animation: swipe-hint-pulse 3s ease-in-out 1s 2;
}
@keyframes swipe-hint-pulse {
  0%, 100% { opacity: 0.18; transform: translateY(-50%) scaleY(1); }
  50% { opacity: 0.35; transform: translateY(-50%) scaleY(1.3); }
}

/* ── Swipe tab indicators (left and right) ── */
.swipe-tab-indicator {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 99999;
  width: 32px;
  height: 56px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease-out, transform 0.1s ease-out;
  box-shadow: 2px 2px 12px rgba(0, 0, 0, 0.25);
}
.swipe-tab-left {
  left: 0;
  border-radius: 0 12px 12px 0;
}
.swipe-tab-right {
  right: 0;
  border-radius: 12px 0 0 12px;
}
.swipe-tab-indicator.visible {
  opacity: 1;
}

/* ── Modal tab slide transitions ── */
@keyframes modalSlideInRight {
  from { opacity: 0.3; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes modalSlideInLeft {
  from { opacity: 0.3; transform: translateX(-30px); }
  to   { opacity: 1; transform: translateX(0); }
}
.modal-slide-right {
  animation: modalSlideInRight 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.modal-slide-left {
  animation: modalSlideInLeft 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* ── Header ── */
.app-header {
  background: var(--fire-dark);
  color: #fff;
  padding: calc(0.6rem + var(--safe-top)) 1.25rem 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header h1 {
  font-size: 1.1rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.app-header .fire-icon {
  font-size: 1.4rem;
}

/* ── Bottom nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--fire-dark);
  display: flex;
  border-top: 2px solid rgba(255, 255, 255, 0.08);
  z-index: 9050;
  /* Safe area iPhone */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bnav-btn {
  flex: 1;
  padding: 0.75rem 0.5rem 0.6rem;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.68rem;
  cursor: pointer;
  transition: color 0.2s;
  position: relative;
}
/* Indicador activo — línea en la parte superior */
.bnav-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 22px;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: #fff;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.bnav-btn.active::after {
  transform: translateX(-50%) scaleX(1);
}
.bnav-btn .icon {
  font-size: 1.4rem;
  transition: transform 0.2s;
}
.bnav-btn.active,
.bnav-btn:hover {
  color: #fff;
}
.bnav-btn.active .icon {
  transform: translateY(-1px);
}

/* Botón Alerta — tratamiento especial */
#bnav-alerta {
  color: rgba(255, 100, 100, 0.7) !important;
}
#bnav-alerta .icon {
  background: rgba(192, 57, 43, 0.25);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.2s,
    transform 0.15s;
}
#bnav-alerta:hover .icon,
#bnav-alerta.active .icon {
  background: rgba(192, 57, 43, 0.55);
}
#bnav-alerta:hover,
#bnav-alerta.active {
  color: #ff8080 !important;
}
#bnav-alerta::after {
  display: none; /* sin indicador de línea en alerta */
}

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: transform 220ms ease, box-shadow 220ms ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,0,0,.16);
}
.card-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: 12px;
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 150ms ease, transform 110ms ease, box-shadow 150ms ease;
  text-decoration: none;
  width: auto;
  min-width: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.btn:active:not(:disabled) {
  transform: scale(0.96);
}
.btn-fire {
  background: var(--fire-red);
  color: #fff;
}
.btn-fire:hover {
  background: #a93226;
  transform: translateY(-1px);
}
.btn-gray {
  background: #5d6d7e;
  color: #fff;
}
.btn-gray:hover {
  background: #4a5568;
}
.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover {
  background: #229954;
}
.btn-outline {
  background: transparent;
  border: 2px solid var(--fire-red);
  color: var(--fire-red);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}
.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  border-radius: 8px;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 1rem;
}
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-color);
}
.form-control {
  width: 100%;
  box-sizing: border-box;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  font-size: 1rem;
  transition: border 0.2s;
  background: var(--input-bg);
  color: var(--text-color);
}
.form-control:focus {
  outline: none;
  border-color: var(--fire-red);
  background: var(--card-bg);
}

/* ── Alert / Toast ── */
.alert {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}
.alert-danger {
  background: #fdecea;
  color: #922b21;
  border: 1px solid #f5b7b1;
}
.alert-success {
  background: #eafaf1;
  color: #1e8449;
  border: 1px solid #a9dfbf;
}
.alert-warning {
  background: #fef9e7;
  color: #7d6608;
  border: 1px solid #f9e79f;
}
.alert-info {
  background: #ebf5fb;
  color: #1a5276;
  border: 1px solid #aed6f1;
}

.toast {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top, 1rem));
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a2e;
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  font-size: 0.9rem;
  z-index: 9999;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  animation:
    toastIn 0.3s ease,
    toastOut 0.3s ease 2.5s forwards;
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}
@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
}

/* ── Hero fichar ── */
.hero-card {
  background: linear-gradient(135deg, var(--fire-dark), #2c3e50);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1rem;
}
.hero-card .name {
  font-size: 1.3rem;
  font-weight: 700;
}
.hero-card .cuartel {
  font-size: 0.85rem;
  opacity: 0.7;
}
.hero-card .time {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin: 0.5rem 0 0;
}

/* ── Steps (registro) ── */
.steps {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.step {
  flex: 1;
  height: 4px;
  border-radius: 4px;
  background: var(--border-color);
  transition: background 0.3s;
}
.step.done {
  background: var(--fire-red);
}

/* ── Badge tipo ── */
.badge-ingreso {
  background: #eafaf1;
  color: #1e8449;
  padding: 0.2rem 0.6rem;
  border-radius: 50px;
  font-size: 0.78rem;
  font-weight: 700;
}
.badge-egreso {
  background: #f2f3f4;
  color: #555;
  padding: 0.2rem 0.6rem;
  border-radius: 50px;
  font-size: 0.78rem;
  font-weight: 700;
}

/* ── Historial items ── */
.fichaje-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}
.fichaje-item:last-child {
  border-bottom: none;
}
.fichaje-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.fichaje-icon.ingreso {
  background: #eafaf1;
  color: #27ae60;
}
.fichaje-icon.egreso {
  background: #f2f3f4;
  color: #555;
}
.fichaje-info {
  flex: 1;
}
.fichaje-tipo {
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: capitalize;
}
.fichaje-fecha {
  font-size: 0.78rem;
  color: #888;
}
.fichaje-badges {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.15rem;
}
.icon-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 50px;
  border: 1px solid;
}

/* ── QR scanner overlay Premium ── */
#qr-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 20, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#qr-overlay.hidden {
  display: none;
}
.qr-header {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  z-index: 510;
}
#qr-cancel {
  color: rgba(255, 255, 255, 0.7);
  font-size: 2rem;
  cursor: pointer;
  transition: color 0.2s;
}
#qr-cancel:hover {
  color: #fff;
}

.qr-title-container {
  position: absolute;
  top: 15%;
  text-align: center;
  width: 90%;
  z-index: 510;
}

.qr-viewport {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  border-radius: 20px;
}

#qr-video {
  width: min(300px, 85vw);
  height: min(300px, 85vw);
  border-radius: 20px;
  object-fit: cover;
  background: #000;           /* evita el ícono placeholder mientras carga */
  display: block;             /* elimina espacio baseline de inline elements */
}

.qr-frame-ring {
  position: absolute;
  width: min(260px, 75vw);
  height: min(260px, 75vw);
  border: 4px solid var(--fire-red);
  border-radius: 16px;
  box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.4); /* Opacates borders of video */
  overflow: hidden;
}

/* Esquinas destacadas */
.qr-frame-ring::before,
.qr-frame-ring::after {
  content: "";
  position: absolute;
  width: 30px;
  height: 30px;
  border: 4px solid #fff;
  z-index: 2;
  border-radius: 8px;
}
.qr-frame-ring::before {
  top: -4px;
  left: -4px;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 12px;
}
.qr-frame-ring::after {
  bottom: -4px;
  right: -4px;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 12px;
}

.qr-laser {
  position: absolute;
  width: 100%;
  height: 3px;
  background: #c0392b; /* Rojo fuego */
  box-shadow:
    0 0 15px rgba(192, 57, 43, 0.8),
    0 0 30px rgba(192, 57, 43, 0.5);
  top: 0;
  left: 0;
  animation: scanLaser 2.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes scanLaser {
  0% {
    top: 0;
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    top: 100%;
    opacity: 1;
  }
  100% {
    top: 100%;
    opacity: 0;
  }
}

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Estado pendiente ── */
.pending-screen {
  text-align: center;
  padding: 2rem 1rem;
}
.pending-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

/* ── Scrollable list ── */
.scroll-list {
  overflow-y: auto;
  max-height: 60vh;
}

/* ── GPS status ── */
.gps-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
}
.gps-ok {
  background: #eafaf1;
  color: #27ae60;
}
.gps-fail {
  background: #fdecea;
  color: #c0392b;
}
.gps-wait {
  background: #fef9e7;
  color: #856404;
}

/* ── Modales ── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(1rem + var(--safe-top)) 1rem 1rem;
}
.modal-overlay.hidden {
  display: none !important;
}
.modal-overlay.modal-full {
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  box-sizing: border-box;
}
.modal-overlay.modal-full > div {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* ── Color accent system per modal ── */
.modal-full .modal-header-colored {
  color: #fff !important;
}
.modal-full .modal-header-colored h5 {
  color: #fff !important;
}
.modal-full .modal-header-colored .bi {
  color: #fff !important;
}
.modal-full .modal-header-colored button {
  color: rgba(255,255,255,.85) !important;
}
.modal-full .modal-header-colored button:hover {
  color: #fff !important;
}

/* Historial - Blue */
#modal-historial { border-top: 3px solid #2980b9; }
#modal-historial .modal-header-colored {
  background: linear-gradient(135deg, #2980b9, #3498db) !important;
  border-bottom: none !important;
}
/* Partes - Green */
#modal-partes { border-top: 3px solid #27ae60; }
#modal-partes .modal-header-colored {
  background: linear-gradient(135deg, #27ae60, #2ecc71) !important;
  border-bottom: none !important;
}
/* Disponibilidad - Orange */
#modal-disponibilidad { border-top: 3px solid #e67e22; }
#modal-disponibilidad .modal-header-colored {
  background: linear-gradient(135deg, #e67e22, #f39c12) !important;
  border-bottom: none !important;
}
/* Perfil - Purple */
#modal-perfil { border-top: 3px solid #8e44ad; }
#modal-perfil .modal-header-colored {
  background: linear-gradient(135deg, #8e44ad, #9b59b6) !important;
  border-bottom: none !important;
}
/* Protocolos - Teal */
#modal-protocolos { border-top: 3px solid #16a085; }
#modal-protocolos #protocolos-modal-header {
  background: linear-gradient(135deg, #16a085, #1abc9c) !important;
}
/* Ayuda - Red */
#modal-ayuda { border-top: 3px solid #c0392b; }
#modal-ayuda .modal-header-colored {
  background: linear-gradient(135deg, #c0392b, #e74c3c) !important;
  border-bottom: none !important;
}
/* Modal tabs (historial, partes, disponibilidad, perfil) need bottom padding for the bottom nav */
#modal-historial,
#modal-partes,
#modal-disponibilidad,
#modal-perfil {
  padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
}
.modal-content {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 1.5rem;
  width: 100%;
  max-width: 450px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  position: relative;
  color: var(--text-color);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-content.modal-content-full {
  width: 100%;
  max-width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@keyframes badge-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.4);
    opacity: 0.7;
  }
}

/* ── Pull to refresh ─────────────────────────────────── */
#ptr-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-56px);
    z-index: 9000;
    pointer-events: none;
}
#ptr-inner {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 24px;
    padding: .4rem 1.1rem;
    box-shadow: 0 2px 12px rgba(0,0,0,.15);
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-color, #1a1a2e);
}
#ptr-icon { font-size: 1.1rem; line-height: 1; }
@keyframes ptr-rotate {
    to { transform: rotate(360deg); }
}
.ptr-spin {
    display: inline-block;
    animation: ptr-rotate .7s linear infinite;
}

/* ── Compact mode: celulares chicos (ej: 360x640) ───────────────────── */
@media (max-width: 380px), (max-height: 700px) {
  #modal-inventario > .modal-content > div:first-child,
  #modal-moviles > .modal-content > div:first-child,
  #modal-combustible > .modal-content > div:first-child,
  #modal-servicio-especial > .modal-content > div:first-child {
    padding-top: calc(var(--safe-top) + .55rem) !important;
    padding-bottom: .6rem !important;
  }

  #modal-inventario .btn,
  #modal-moviles button,
  #modal-combustible button,
  #modal-servicio-especial button,
  #modal-inspeccion button {
    min-height: 38px;
  }

  #modal-inventario #inv-items-list {
    gap: .4rem !important;
  }

  #modal-inventario #inv-tab-rondas {
    font-size: .75rem !important;
  }

  #modal-servicio-especial #se-panel-lista,
  #modal-servicio-especial #se-panel-nuevo {
    padding: .65rem .8rem calc(.65rem + var(--safe-bottom)) !important;
  }

  #modal-servicio-especial #se-filtro-descripcion {
    font-size: .8rem !important;
    padding-top: .45rem !important;
    padding-bottom: .45rem !important;
  }

  #modal-moviles #moviles-lista button {
    font-size: .66rem !important;
    padding: .18rem .45rem !important;
  }

  #modal-combustible #comb-panel-form {
    padding: 1rem .9rem !important;
  }

  #modal-combustible #comb-panel-form input,
  #modal-combustible #comb-panel-form select,
  #modal-combustible #comb-panel-form textarea {
    font-size: .84rem !important;
    padding: .5rem !important;
  }

  #modal-combustible #comb-panel-hist {
    padding: .75rem !important;
  }

  #modal-inspeccion .modal-content,
  #modal-ronda .modal-content,
  #modal-historial-movil .modal-content {
    max-height: 94vh !important;
  }

  #modal-inspeccion #insp-body {
    padding: .65rem .8rem !important;
  }

  #modal-ronda #ronda-paso-seleccion {
    padding: 1rem .9rem !important;
  }

  #modal-ronda #ronda-paso-revision > div:first-child,
  #modal-ronda #ronda-paso-revision > div:last-child {
    padding-left: .8rem !important;
    padding-right: .8rem !important;
  }
}

/* ══════════════════════════════════════════════════════
   ♿  ACCESIBILIDAD
══════════════════════════════════════════════════════ */

/* Focus visible — outline rojo para navegación por teclado */
:focus-visible {
  outline: 2.5px solid var(--fire-red);
  outline-offset: 2px;
  border-radius: 4px;
}
:focus:not(:focus-visible) { outline: none; }

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Región de anuncios para screen readers */
#a11y-live {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════
   🎬  MODALES — animación de entrada y salida
══════════════════════════════════════════════════════ */

.modal-overlay:not(.hidden) {
  animation: overlayFadeIn 0.22s ease both;
}
.modal-overlay:not(.hidden) .modal-content {
  animation: modalSlideUp 0.3s cubic-bezier(0.34, 1.36, 0.64, 1) both;
}
.modal-overlay.modal-closing {
  animation: overlayFadeOut 0.2s ease forwards !important;
}
.modal-overlay.modal-closing .modal-content {
  animation: modalSlideDown 0.2s ease forwards !important;
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes overlayFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes modalSlideDown {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(24px) scale(0.97); }
}

/* ══════════════════════════════════════════════════════
   🍞  TOAST MEJORADO — bottom-center, con tipo
══════════════════════════════════════════════════════ */

.toast {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: #1e2637;
  color: #fff;
  padding: 0.65rem 1.2rem;
  border-radius: 50px;
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 9999;
  box-shadow: 0 8px 32px rgba(0,0,0,.35);
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: toastIn 0.3s cubic-bezier(0.34, 1.36, 0.64, 1), toastOut 0.3s ease 2.5s forwards;
  top: auto;
}
.toast-success { background: #1a6b3a; border-left: 3px solid #2ecc71; }
.toast-error   { background: #7b1d1d; border-left: 3px solid #e74c3c; }
.toast-info    { background: #1a3a6b; border-left: 3px solid #3498db; }
.toast-warn    { background: #7b5a1d; border-left: 3px solid #f39c12; }
.toast-icon    { font-size: 1rem; flex-shrink: 0; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px) scale(0.92); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@keyframes toastOut {
  to   { opacity: 0; transform: translateX(-50%) translateY(12px) scale(0.95); }
}

/* ══════════════════════════════════════════════════════
   💀  SKELETON LOADER — shimmer
══════════════════════════════════════════════════════ */

.skeleton {
  background: linear-gradient(90deg,
    var(--border-color) 25%,
    var(--card-bg) 50%,
    var(--border-color) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: var(--radius);
  color: transparent !important;
  user-select: none;
  pointer-events: none;
}
.skeleton-text {
  display: block;
  height: 0.85em;
  border-radius: 4px;
  margin-bottom: 0.45rem;
}
.skeleton-text:last-child { width: 65%; }
.skeleton-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border-color);
}
.skeleton-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  flex-shrink: 0;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ══════════════════════════════════════════════════════
   👆  BOTTOM NAV — tap feedback mejorado
══════════════════════════════════════════════════════ */

.bnav-btn {
  transition: color 0.2s, transform 0.1s ease !important;
}
.bnav-btn:active {
  transform: scale(0.90) !important;
}

/* ══════════════════════════════════════════════════════
   ✨  ANIMATE-IN helper — entradas escalonadas
══════════════════════════════════════════════════════ */

.animate-in {
  animation: screenEnterUp 0.3s ease both;
}
.animate-in-delay-1 { animation-delay:  60ms; }
.animate-in-delay-2 { animation-delay: 120ms; }
.animate-in-delay-3 { animation-delay: 180ms; }

/* ══════════════════════════════════════════════════════
   ♿  prefers-reduced-motion — SIEMPRE AL FINAL
══════════════════════════════════════════════════════ */

/* ── Feature cards (módulos del home) ── */
.feature-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  color: #fff;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}
.feature-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 120px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.03));
  pointer-events: none;
}
.feature-card:active {
  transform: scale(0.97);
}
.feature-card .feature-emoji {
  font-size: 1.8rem;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}
.feature-card .feature-title {
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.feature-card .feature-desc {
  font-size: 0.73rem;
  opacity: 0.75;
  margin-top: 0.15rem;
}

/* ── Módulos en formato Grid (Dashboard) ── */
.feature-card-grid {
  width: 100%;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 1.25rem 0.5rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.feature-card-grid:active {
  transform: scale(0.96);
}
.feature-card-grid .feature-emoji-grid {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
}
.feature-card-grid .feature-title-grid {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin-bottom: 0.2rem;
}
.feature-card-grid .feature-desc-grid {
  font-size: 0.65rem;
  opacity: 0.8;
  line-height: 1.2;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration:        0.01ms !important;
    animation-iteration-count: 1      !important;
    transition-duration:       0.01ms !important;
    scroll-behavior:           auto   !important;
  }
}

/* ═══════════════════════════════════════════════════════
   MODO EMERGENCIA — Pantalla de emergencia activa
   ═══════════════════════════════════════════════════════ */

/* Body class when emergency mode is active */
body.emergency-mode .app-header {
  background: #0d0d1a !important;
  border-bottom: 2px solid #c0392b;
}
body.emergency-mode #bottom-nav {
  display: none !important;
}

/* Container */
.em-activa-container {
  background: #1a1a2e;
  min-height: 100vh;
  padding: 1rem 1rem calc(env(safe-area-inset-bottom, 0px) + 1rem);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

/* Pulsing border animation */
#screen-emergencia-activa.active {
  animation: em-border-pulse 2s ease-in-out infinite;
}
@keyframes em-border-pulse {
  0%, 100% { box-shadow: inset 0 0 0 3px rgba(192, 57, 43, 0.3); }
  50%      { box-shadow: inset 0 0 0 3px rgba(192, 57, 43, 0.8); }
}

/* Header: badge + timer */
.em-activa-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.em-activa-badge {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: #c0392b;
  color: #fff;
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .35rem .8rem;
  border-radius: 8px;
}
.em-activa-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  animation: em-dot-pulse 1.2s ease-in-out infinite;
}
@keyframes em-dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .4; transform: scale(.7); }
}
.em-activa-timer {
  font-size: 1.6rem;
  font-weight: 900;
  color: #e74c3c;
  font-variant-numeric: tabular-nums;
  letter-spacing: .05em;
}

/* Tipo/observacion */
.em-activa-tipo {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}

/* Direccion prominente */
.em-activa-direccion {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  background: rgba(192, 57, 43, 0.25);
  border: 2px solid rgba(192, 57, 43, 0.5);
  border-radius: 12px;
  padding: .75rem 1rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}
.em-activa-direccion i {
  color: #e74c3c;
  font-size: 1.3rem;
  flex-shrink: 0;
  margin-top: .1rem;
}

/* Map */
.em-activa-map-wrap {
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,.15);
}
.em-activa-map {
  height: 200px;
  width: 100%;
  background: #2c3e50;
}

/* Stats row */
.em-activa-stats {
  display: flex;
  justify-content: space-around;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: .6rem .5rem;
}
.em-activa-stat {
  text-align: center;
}
.em-activa-stat-num {
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1;
}
.em-activa-stat-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: rgba(255,255,255,.6);
  margin-top: .2rem;
}

/* Distancia */
.em-activa-distancia {
  background: rgba(39, 174, 96, 0.2);
  border: 1px solid rgba(39, 174, 96, 0.4);
  border-radius: 10px;
  padding: .5rem .8rem;
  font-size: .9rem;
  font-weight: 700;
  text-align: center;
  color: #2ecc71;
}

/* Meta info (sender, hora) */
.em-activa-meta {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  color: rgba(255,255,255,.5);
}

/* Clima strip */
.em-activa-clima {
  background: rgba(255,255,255,.06);
  border-radius: 8px;
  padding: .4rem .7rem;
  font-size: .75rem;
  color: rgba(255,255,255,.8);
}

/* Novedades section */
.em-activa-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.em-activa-section-title {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: rgba(255,255,255,.6);
  font-weight: 700;
  margin-bottom: .35rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.em-activa-updates {
  background: rgba(255,255,255,.06);
  border-radius: 10px;
  padding: .5rem;
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  font-size: .82rem;
  flex: 1;
}
.em-activa-updates-empty {
  color: rgba(255,255,255,.35);
  text-align: center;
  padding: .5rem;
  font-size: .8rem;
}
.em-activa-update-bubble {
  background: rgba(255,255,255,.08);
  border-radius: 8px;
  padding: .4rem .6rem;
}
.em-activa-update-who {
  font-weight: 700;
  font-size: .75rem;
  color: rgba(255,255,255,.7);
}
.em-activa-update-hour {
  font-size: .7rem;
  color: rgba(255,255,255,.4);
  float: right;
}
.em-activa-update-msg {
  color: #fff;
  margin-top: .15rem;
}

/* Bitacora input */
.em-activa-bitacora {
  margin-top: .25rem;
}
.em-activa-bitacora-input {
  flex: 1;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.08);
  color: #fff;
  padding: .5rem .75rem;
  font-size: .82rem;
  resize: none;
  font-family: inherit;
}
.em-activa-bitacora-input::placeholder {
  color: rgba(255,255,255,.35);
}
.em-activa-bitacora-send {
  background: #27ae60;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: .5rem .9rem;
  font-size: 1.1rem;
  cursor: pointer;
}
.em-activa-bitacora-send:active {
  opacity: .7;
}

/* Action buttons */
.em-activa-actions {
  display: flex;
  gap: .6rem;
}
.em-activa-btn-modal,
.em-activa-btn-contactos {
  flex: 1;
  background: rgba(255,255,255,.1);
  border: 2px solid rgba(255,255,255,.25);
  color: #fff;
  border-radius: 12px;
  padding: .6rem .5rem;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
}
.em-activa-btn-modal:active,
.em-activa-btn-contactos:active {
  opacity: .7;
}

/* Exit button */
.em-activa-btn-salir {
  background: none;
  border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.5);
  border-radius: 10px;
  padding: .5rem;
  font-size: .8rem;
  cursor: pointer;
  text-align: center;
  margin-top: .25rem;
}
.em-activa-btn-salir:active {
  color: #fff;
  border-color: rgba(255,255,255,.5);
}
