/* Trackneer Demo Shared UI & Motion Tokens */
:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}

/* Technical Coordinate Grid Background */
.bg-grid-light {
  background-color: #f8fafc;
  background-image:
    radial-gradient(#94a3b8 0.75px, transparent 0.75px),
    linear-gradient(to right, rgba(226, 232, 240, 0.4) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(226, 232, 240, 0.4) 1px, transparent 1px);
  background-size: 24px 24px, 96px 96px, 96px 96px;
}

.dark .bg-grid-dark {
  background-color: #09090b;
  background-image:
    radial-gradient(#27272a 0.75px, transparent 0.75px),
    linear-gradient(to right, rgba(39, 39, 42, 0.25) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(39, 39, 42, 0.25) 1px, transparent 1px);
  background-size: 24px 24px, 96px 96px, 96px 96px;
}

/* Layered Surface Elevation */
.layer-surface {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow:
    inset 0 1px 0 0 rgba(255, 255, 255, 0.9),
    0 1px 2px 0 rgba(0, 0, 0, 0.04),
    0 4px 12px -2px rgba(0, 0, 0, 0.03);
}

.dark .layer-surface {
  background: #121215;
  border: 1px solid #27272a;
  box-shadow:
    inset 0 1px 0 0 rgba(255, 255, 255, 0.07),
    0 2px 4px 0 rgba(0, 0, 0, 0.4),
    0 8px 24px -4px rgba(0, 0, 0, 0.5);
}

/* Recessed Inset Bay */
.layer-recessed {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  box-shadow: inset 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.dark .layer-recessed {
  background: #09090b;
  border: 1px solid #1f1f23;
  box-shadow: inset 0 1px 3px 0 rgba(0, 0, 0, 0.6);
}

/* Floating Pill Header Glass */
.nav-pill-glass {
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(226, 232, 240, 0.85);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 4px 20px -2px rgba(15, 23, 42, 0.06);
}

.dark .nav-pill-glass {
  background: rgba(18, 18, 21, 0.86);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(39, 39, 42, 0.85);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 8px 32px -4px rgba(0, 0, 0, 0.6);
}

/* Tactile Press Feedback */
.btn-press {
  transition:
    transform 160ms var(--ease-out),
    background-color 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    opacity 150ms ease;
}

.btn-press:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-press:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Tabular Numbers for Live Metrics */
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* Hover-capable pointer gating (prevents sticky touch hover states) */
.hover-arrow {
  transition: transform 160ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .group:hover .hover-arrow {
    transform: translate(2px, -2px);
  }
  .card-interactive:hover {
    border-color: #94a3b8;
  }
  .dark .card-interactive:hover {
    border-color: #52525b;
  }
}

/* Hold-to-Confirm SOS Pattern (Asymmetric timing: 2s linear hold, 200ms ease-out snapback) */
.hold-trigger {
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.hold-overlay {
  position: absolute;
  inset: 0;
  background: rgba(220, 38, 38, 0.22);
  clip-path: inset(0 100% 0 0);
  transition: clip-path 200ms var(--ease-out);
  pointer-events: none;
}

.dark .hold-overlay {
  background: rgba(239, 68, 68, 0.28);
}

.hold-trigger.is-holding .hold-overlay {
  clip-path: inset(0 0 0 0);
  transition: clip-path 2000ms linear;
}

/* Centered Modal Entrance (Never scale(0), always scale(0.96) + opacity) */
.modal-backdrop {
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease-out);
}

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-panel {
  transform: scale(0.96);
  opacity: 0;
  transform-origin: center;
  transition: transform 200ms var(--ease-out), opacity 200ms var(--ease-out);
}

.modal-backdrop.is-open .modal-panel {
  transform: scale(1);
  opacity: 1;
}

/* Smooth Step / Verdict Entrance */
@keyframes panelEnter {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.panel-enter {
  animation: panelEnter 180ms var(--ease-out) both;
}

/* Sonner-Style Toast Stack */
.trk-toast-container {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 24rem;
  width: calc(100vw - 2rem);
  pointer-events: none;
}

.trk-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.75rem 0.875rem;
  border-radius: 0.875rem;
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
  border: 1px solid #e2e8f0;
  box-shadow: 0 10px 30px -6px rgba(15, 23, 42, 0.14), 0 2px 6px -1px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 0.75rem;
  line-height: 1.35;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: transform 400ms ease, opacity 400ms ease;
  cursor: pointer;
}

.dark .trk-toast {
  background: rgba(24, 24, 27, 0.96);
  color: #f4f4f5;
  border-color: #27272a;
  box-shadow: 0 12px 32px -6px rgba(0, 0, 0, 0.65);
}

@starting-style {
  .trk-toast {
    opacity: 0;
    transform: translateY(100%);
  }
}

.trk-toast[data-leaving="true"] {
  opacity: 0;
  transform: translateY(16px) scale(0.96);
}

/* Dark Mode Leaflet Map Harmonization */
.dark .leaflet-tile-pane {
  filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

.dark .leaflet-popup-content-wrapper,
.dark .leaflet-popup-tip {
  background: #18181b;
  color: #f4f4f5;
  border: 1px solid #27272a;
}

/* Embedded Iframe Mode for Technician App */
.is-embedded body {
  padding: 0.75rem !important;
}

.is-embedded .tech-phone-frame {
  max-width: 100% !important;
  min-height: auto !important;
  border-width: 1px !important;
  border-radius: 1rem !important;
  box-shadow: none !important;
}

.is-embedded .tech-notch,
.is-embedded .tech-home-pill {
  display: none !important;
}

/* Reduced Motion Respect */
@media (prefers-reduced-motion: reduce) {
  .btn-press,
  .hover-arrow,
  .hold-overlay,
  .modal-backdrop,
  .modal-panel,
  .trk-toast {
    transition-duration: 150ms !important;
  }
  .btn-press:active:not(:disabled),
  .modal-panel,
  .trk-toast[data-leaving="true"] {
    transform: none !important;
  }
  .panel-enter {
    animation: none !important;
  }
  .animate-pulse,
  .animate-ping,
  .animate-bounce {
    animation: none !important;
  }
}

/* Print Certificate Styling */
@media print {
  header,
  .no-print,
  .trk-toast-container {
    display: none !important;
  }
  body {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
  }
  .tech-phone-frame {
    border: 1px solid #cbd5e1 !important;
    border-radius: 0.75rem !important;
    box-shadow: none !important;
    min-height: auto !important;
    max-width: 100% !important;
  }
}
