/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * depending on specificity.
 */

*:not(.rounded-full) {
  border-radius: 0 !important;
}

/* MapLibre container must fill its sized parent (CSS resets position to relative). */
.maplibregl-map {
  width: 100%;
  height: 100%;
}

.maplibregl-canvas-container,
.maplibregl-canvas {
  width: 100% !important;
  height: 100% !important;
}

.map-marker {
  min-width: 64px;
  line-height: 0;
}

.map-marker__icon {
  object-fit: contain;
  max-width: none;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transform: translateZ(0);
}

/* Pagy 8 nav — responsive across Vehicles, Trips, History, Dashboard */
/* Hide scrollbars on filter chip strips (still scrollable) */
.scrollbar-none {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.scrollbar-none::-webkit-scrollbar {
  display: none;
}

.pagy-custom-nav {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

.pagy-custom-nav::-webkit-scrollbar {
  display: none;
}

.pagy-custom-nav .pagy.nav,
.pagy-custom-nav nav.pagy {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  align-items: center;
  justify-content: safe center;
  list-style: none;
  margin: 0 auto;
  padding: 0.25rem 0.1rem;
  width: max-content;
  max-width: none;
}

.pagy-custom-nav .pagy a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 2.125rem;
  height: 2.125rem;
  padding: 0 0.5rem;
  border-radius: 0.5rem;
  background-color: #ffffff;
  border: 1px solid rgba(203, 213, 225, 0.6);
  color: #475569;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  -webkit-tap-highlight-color: transparent;
}

@media (min-width: 640px) {
  .pagy-custom-nav .pagy.nav,
  .pagy-custom-nav nav.pagy {
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    width: auto;
    max-width: 100%;
  }

  .pagy-custom-nav .pagy a {
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 0.65rem;
    font-size: 0.8125rem;
  }
}

.pagy-custom-nav .pagy a:not([aria-disabled="true"]):hover {
  background-color: #f8fafc;
  border-color: #36ada3;
  color: #2f578a;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(54, 173, 163, 0.15);
}

.pagy-custom-nav .pagy a:not([aria-disabled="true"]):active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(54, 173, 163, 0.1);
}

.pagy-custom-nav .pagy a.current {
  background: linear-gradient(135deg, #36ADA3 0%, #2F578A 100%);
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(47, 87, 138, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: scale(1.02);
}

.pagy-custom-nav .pagy a.gap {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: #94a3b8;
  cursor: default;
  min-width: 1.5rem;
  padding: 0 0.25rem;
  pointer-events: none;
}

.pagy-custom-nav .pagy a[aria-disabled="true"]:not(.current):not(.gap) {
  background-color: #f8fafc;
  border-color: rgba(226, 232, 240, 0.8);
  box-shadow: none;
  color: #cbd5e1;
  cursor: not-allowed;
}

.pagy-custom-nav--compact .pagy a {
  min-width: 1.875rem;
  height: 1.875rem;
  padding: 0 0.4rem;
  font-size: 0.6875rem;
  border-radius: 0.4rem;
}

@media (min-width: 640px) {
  .pagy-custom-nav--compact .pagy a {
    min-width: 2rem;
    height: 2rem;
    font-size: 0.75rem;
  }
}

/* Mobile / PWA polish */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overscroll-behavior-y: none;
}

body.app-shell.is-standalone header {
  /* Keep content clear of the iOS status bar in installed PWA */
  padding-top: max(0.35rem, env(safe-area-inset-top));
}

.app-header {
  -webkit-tap-highlight-color: transparent;
}

/* Header action cluster */
.header-actions {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  max-width: 100%;
  border-radius: 0.875rem;
  border: 1px solid rgba(255, 255, 255, 0.85);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92) 0%, rgba(255, 246, 240, 0.88) 100%);
  box-shadow:
    0 1px 2px rgba(47, 87, 138, 0.06),
    0 4px 16px rgba(255, 90, 90, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
}

.header-actions__cluster {
  display: inline-flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0.2rem;
}

.header-actions__cluster--tools {
  padding-left: 0.35rem;
  padding-right: 0.15rem;
}

.header-actions__cluster--user {
  padding-right: 0.2rem;
  padding-left: 0.15rem;
}

.header-actions__divider {
  width: 1px;
  align-self: stretch;
  margin: 0.35rem 0;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(148, 163, 184, 0.35) 20%,
    rgba(148, 163, 184, 0.35) 80%,
    transparent 100%
  );
}

.header-sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  max-width: 8.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 0.55rem;
  line-height: 1.2;
  white-space: nowrap;
}

.header-sync-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.header-sync-pill--button {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}

.header-sync-pill--button:hover {
  box-shadow: 0 0 0 2px rgba(47, 87, 138, 0.12);
}

.header-sync-pill--button:focus-visible {
  outline: 2px solid #36ada3;
  outline-offset: 2px;
}

.header-sync-pill--button[aria-expanded="true"] {
  box-shadow: 0 0 0 2px rgba(54, 173, 163, 0.28);
}

@media (min-width: 640px) {
  .header-sync-pill {
    max-width: 11.5rem;
    padding: 0.4rem 0.6rem;
  }
}

@media (min-width: 768px) {
  .header-sync-pill {
    max-width: 14.5rem;
  }

  .header-sync-pill__time {
    font-size: 0.8125rem;
  }
}

@media (min-width: 1024px) {
  .header-sync-pill {
    max-width: 16.5rem;
    padding: 0.4rem 0.65rem;
  }
}

.header-sync-pill--ok {
  background: rgba(16, 185, 129, 0.08);
  color: #047857;
}

.header-sync-pill--active {
  background: rgba(14, 165, 233, 0.1);
  color: #0369a1;
}

.header-sync-pill--queued {
  background: rgba(139, 92, 246, 0.1);
  color: #6d28d9;
}

.header-sync-pill--none {
  background: rgba(148, 163, 184, 0.12);
  color: #64748b;
}

.header-sync-pill__dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 9999px;
  flex-shrink: 0;
  background: currentColor;
  opacity: 0.85;
}

.header-sync-pill__dot--pulse {
  animation: header-sync-pulse 1.4s ease-in-out infinite;
}

.header-sync-pill__label {
  font-size: 0.5625rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.9;
}

.header-sync-pill__time {
  font-size: 0.6875rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  color: #0f172a;
  flex-shrink: 0;
}

@media (min-width: 640px) {
  .header-sync-pill__time {
    font-size: 0.75rem;
  }
}

.header-sync-pill--active .header-sync-pill__time,
.header-sync-pill--queued .header-sync-pill__time {
  color: inherit;
}

/* Sync progress popup (header pill). Positioned via JS (fixed, appended to body)
   because .header-actions uses overflow:hidden which clips absolute children. */
.sync-progress-panel {
  position: fixed;
  z-index: 90;
  width: min(22rem, calc(100vw - 1.25rem));
}

.sync-progress-panel__inner {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 1rem;
  box-shadow:
    0 18px 40px rgba(15, 23, 42, 0.14),
    0 2px 8px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.sync-progress-panel__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem 0.55rem;
  border-bottom: 1px solid rgba(241, 245, 249, 0.95);
}

.sync-progress-panel__heading {
  margin: 0;
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #64748b;
}

.sync-progress-panel__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 0;
  border-radius: 0.45rem;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
}

.sync-progress-panel__close:hover {
  background: rgba(148, 163, 184, 0.14);
  color: #334155;
}

.sync-progress-panel__body {
  padding: 0.75rem 0.85rem 0.9rem;
  max-height: min(28rem, 70vh);
  overflow-y: auto;
}

.sync-progress__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.sync-progress__eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.5625rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #94a3b8;
}

.sync-progress__title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.35;
}

.sync-progress__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  padding: 0.2rem 0.45rem;
  border-radius: 0.35rem;
  border: 1px solid transparent;
  font-size: 0.5625rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sync-progress__badge--sm {
  padding: 0.12rem 0.35rem;
}

.sync-progress__badge--ok {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.sync-progress__badge--warn {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.sync-progress__badge--bad {
  background: #fff1f2;
  color: #be123c;
  border-color: #fecdd3;
}

.sync-progress__badge--active {
  background: #f0f9ff;
  color: #0369a1;
  border-color: #bae6fd;
}

.sync-progress__badge--queued {
  background: #f5f3ff;
  color: #6d28d9;
  border-color: #ddd6fe;
}

.sync-progress__badge--muted {
  background: #f8fafc;
  color: #64748b;
  border-color: #e2e8f0;
}

.sync-progress__pulse {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 9999px;
  background: currentColor;
  animation: header-sync-pulse 1.4s ease-in-out infinite;
}

.sync-progress__meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem 0.75rem;
  margin: 0 0 0.85rem;
}

.sync-progress__meta dt {
  margin: 0;
  font-size: 0.5625rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
}

.sync-progress__meta dd {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: #1e293b;
  font-variant-numeric: tabular-nums;
}

.sync-progress__eta {
  font-weight: 600;
  color: #64748b;
  font-size: 0.6875rem;
}

.sync-progress__bar {
  height: 0.35rem;
  border-radius: 9999px;
  background: rgba(148, 163, 184, 0.25);
  overflow: hidden;
  margin: 0 0 0.35rem;
}

.sync-progress__bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #2f578a, #36ada3);
  border-radius: 9999px;
  transition: width 0.35s ease;
}

.sync-progress__progress-label {
  margin: 0 0 0.75rem;
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

.sync-progress__section {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(241, 245, 249, 0.95);
}

.sync-progress__section-title {
  margin: 0 0 0.45rem;
  font-size: 0.5625rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #64748b;
}

.sync-progress__providers,
.sync-progress__errors,
.sync-progress__recent {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.sync-progress__provider {
  padding: 0.5rem 0.55rem;
  border-radius: 0.55rem;
  background: rgba(248, 250, 252, 0.9);
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.sync-progress__provider--error {
  background: #fff1f2;
  border-color: #fecdd3;
}

.sync-progress__provider--error p {
  margin: 0.25rem 0 0;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #be123c;
}

.sync-progress__provider-name {
  font-size: 0.75rem;
  font-weight: 800;
  color: #0f172a;
}

.sync-progress__provider-name span {
  margin-left: 0.35rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #94a3b8;
}

.sync-progress__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.4rem;
}

.sync-progress__chip {
  display: inline-flex;
  padding: 0.12rem 0.4rem;
  border-radius: 0.3rem;
  background: rgba(47, 87, 138, 0.08);
  color: #2f578a;
  font-size: 0.625rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.sync-progress__errors li {
  font-size: 0.6875rem;
  font-weight: 600;
  color: #b45309;
  line-height: 1.4;
}

.sync-progress__recent li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.4rem;
  align-items: center;
}

.sync-progress__recent-msg {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #334155;
}

.sync-progress__recent-time {
  font-size: 0.625rem;
  font-weight: 700;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}

.sync-progress__muted {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
}

.sync-progress__error {
  margin: 0 0 0.35rem;
  font-size: 0.8125rem;
  font-weight: 800;
  color: #be123c;
}

.sync-progress__empty {
  padding: 0.35rem 0;
}

.sync-progress__footer {
  margin-top: 0.85rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(241, 245, 249, 0.95);
}

.sync-progress__link {
  font-size: 0.6875rem;
  font-weight: 800;
  color: #2f578a;
  text-decoration: none;
}

.sync-progress__link:hover {
  color: #36ada3;
}

@media (max-width: 639px) {
  .sync-progress-panel {
    position: fixed;
    top: auto;
    right: 0.75rem;
    left: 0.75rem;
    bottom: calc(4.75rem + env(safe-area-inset-bottom));
    width: auto;
  }
}

.header-actions__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.125rem;
  height: 2.125rem;
  border-radius: 0.55rem;
  color: #64748b;
  transition: color 0.15s ease, background-color 0.15s ease, transform 0.12s ease;
  flex-shrink: 0;
}

@media (min-width: 640px) {
  .header-actions__btn {
    width: 2.25rem;
    height: 2.25rem;
  }
}

.header-actions__btn:hover {
  color: #36ada3;
  background: rgba(47, 87, 138, 0.08);
}

.header-actions__btn:active {
  transform: scale(0.94);
}

.header-actions__btn--sync:hover {
  color: #2f578a;
  background: rgba(54, 173, 163, 0.12);
}

.header-actions__btn--settings:hover {
  color: #2f578a;
}

.header-actions__btn--logout:hover {
  color: #36ada3;
  background: rgba(54, 173, 163, 0.1);
}

.header-actions__btn--spin .header-actions__icon {
  animation: header-sync-spin 0.9s linear infinite;
}

.header-actions__icon {
  width: 1.05rem;
  height: 1.05rem;
}

@media (min-width: 640px) {
  .header-actions__icon {
    width: 1.125rem;
    height: 1.125rem;
  }
}

.header-user__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.55rem;
  background: linear-gradient(135deg, #36ada3 0%, #2f578a 100%);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 2px 8px rgba(47, 87, 138, 0.25);
  flex-shrink: 0;
}

@media (min-width: 640px) {
  .header-user__avatar {
    width: 2.125rem;
    height: 2.125rem;
    font-size: 0.8125rem;
  }
}

.header-user__meta {
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  max-width: 7rem;
  margin: 0 0.15rem 0 0.35rem;
  line-height: 1.1;
}

@media (min-width: 1024px) {
  .header-user__meta {
    max-width: 8.5rem;
  }
}

.header-user__name {
  font-size: 0.75rem;
  font-weight: 700;
  color: #1e293b;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-user__role {
  margin-top: 0.125rem;
  font-size: 0.5625rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #2f578a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes header-sync-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes header-sync-pulse {
  0%, 100% { opacity: 0.45; transform: scale(0.92); }
  50% { opacity: 1; transform: scale(1); }
}

.app-bottom-nav__item {
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 639px) {
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    font-size: 16px !important; /* prevent iOS focus zoom */
  }

  .app-bottom-nav a {
    -webkit-tap-highlight-color: transparent;
  }
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@supports (padding: max(0px)) {
  .pb-safe {
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }
}

/* Duty editor: bottom sheet on phones */
.duty-popup-overlay {
  overscroll-behavior: contain;
}

.duty-popup-sheet {
  max-height: min(92dvh, 820px);
}

@media (max-width: 639px) {
  .duty-popup-sheet {
    border-top-left-radius: 1rem !important;
    border-top-right-radius: 1rem !important;
  }
}

/* Keep primary actions easy to hit */
.min-h-11 { min-height: 2.75rem; }
.min-h-12 { min-height: 3rem; }
.min-w-11 { min-width: 2.75rem; }

/* Top mileage chart — plate badges on y-axis */
[data-dashboard-charts-target="topMileage"] {
  position: relative;
  overflow: visible;
}

.chart-plate-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 7.25rem;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.chart-plate-row {
  position: absolute;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding-left: 2px;
}

.chart-plate-badge {
  display: inline-flex;
  max-width: 100%;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.1;
  color: #fff;
  background: linear-gradient(135deg, #232f72 0%, #121358 100%);
  border: 1px solid #fcd34d;
  box-shadow: 0 1px 2px rgba(35, 47, 114, 0.25);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-plate-name {
  display: block;
  max-width: 100%;
  padding-left: 2px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
