/* Way Pulse — Vehicle panel (responsive, all breakpoints) */
:root {
  --wp-weather-offset: 0px;
  --wp-bottom-offset: 0px;
  --wp-panel-width: min(520px, 100vw);
  --wp-safe-top: env(safe-area-inset-top, 0px);
  --wp-safe-bottom: env(safe-area-inset-bottom, 0px);
  --wp-safe-left: env(safe-area-inset-left, 0px);
  --wp-safe-right: env(safe-area-inset-right, 0px);
}

body:not(.wp-page-main) #wp-vehicle-panel,
body:not(.wp-page-main) #wp-vehicle-panel-backdrop {
  display: none !important;
}

/* Hide FAB + language when vehicle panel is open (mobile & desktop) */
body.wp-vehicle-panel-open .wp-fab,
body.wp-vehicle-panel-open .wp-registry-fab,
body.wp-vehicle-panel-open .wp-geo-fab,
body.wp-vehicle-panel-open .wp-fuel-fab,
body.wp-vehicle-panel-open #wp-lang-switch {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

#wp-vehicle-panel-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1550;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

body.wp-vehicle-panel-open #wp-vehicle-panel-backdrop {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* ── Panel shell ── */
#wp-vehicle-panel {
  position: fixed;
  top: calc(var(--wp-weather-offset) + var(--wp-safe-top));
  right: var(--wp-safe-right);
  width: var(--wp-panel-width);
  height: calc(
    100dvh - var(--wp-weather-offset) - var(--wp-bottom-offset) - var(--wp-safe-top) -
      var(--wp-safe-bottom)
  );
  max-height: calc(
    100vh - var(--wp-weather-offset) - var(--wp-bottom-offset) - var(--wp-safe-top) -
      var(--wp-safe-bottom)
  );
  z-index: 1600;
  display: flex;
  flex-direction: column;
  background: #eef1f6;
  color: #1e293b;
  font-family: 'Inter', 'Roboto', 'Segoe UI', sans-serif;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.18);
  box-sizing: border-box;
  overscroll-behavior: contain;
}

#wp-vehicle-panel.open {
  transform: translateX(0);
  pointer-events: auto;
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1023px) {
  :root {
    --wp-panel-width: min(400px, 92vw);
  }
}

/* Desktop */
@media (min-width: 1024px) {
  :root {
    --wp-panel-width: min(480px, 38vw);
  }
}

@media (min-width: 1440px) {
  :root {
    --wp-panel-width: min(520px, 32vw);
  }
}

/* Mobile: bottom sheet (map stays visible at top) */
@media (max-width: 767px) {
  :root {
    --wp-panel-width: 100%;
  }

  #wp-vehicle-panel {
    left: var(--wp-safe-left);
    right: var(--wp-safe-right);
    top: auto;
    bottom: calc(var(--wp-bottom-offset) + var(--wp-safe-bottom));
    height: min(
      88dvh,
      calc(
        100dvh - var(--wp-weather-offset) - var(--wp-bottom-offset) - var(--wp-safe-top) -
          var(--wp-safe-bottom) - 8px
      )
    );
    max-height: min(
      88vh,
      calc(
        100vh - var(--wp-weather-offset) - var(--wp-bottom-offset) - var(--wp-safe-top) -
          var(--wp-safe-bottom) - 8px
      )
    );
    border-radius: 18px 18px 0 0;
    transform: translateY(calc(100% + var(--wp-bottom-offset)));
    box-shadow: 0 -8px 40px rgba(15, 23, 42, 0.22);
  }

  #wp-vehicle-panel.open {
    transform: translateY(0);
  }

  body.wp-vehicle-panel-open {
    overflow: hidden;
  }

  /* Drag handle hint — must not block header buttons on touch devices */
  #wp-vehicle-panel::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    border-radius: 4px;
    background: rgba(15, 23, 42, 0.15);
    z-index: 1;
    pointer-events: none;
  }
}

/* Landscape phone: side drawer to keep map usable */
@media (max-width: 767px) and (orientation: landscape) {
  :root {
    --wp-panel-width: min(400px, 72vw);
  }

  #wp-vehicle-panel {
    top: calc(var(--wp-weather-offset) + var(--wp-safe-top));
    left: auto;
    bottom: var(--wp-safe-bottom);
    right: var(--wp-safe-right);
    height: calc(
      100dvh - var(--wp-weather-offset) - var(--wp-bottom-offset) - var(--wp-safe-top) -
        var(--wp-safe-bottom)
    );
    max-height: none;
    border-radius: 0;
    transform: translateX(100%);
  }

  #wp-vehicle-panel.open {
    transform: translateX(0);
  }

  #wp-vehicle-panel::before {
    display: none;
  }
}

/* Very small phones */
@media (max-width: 359px) {
  .wp-vp-name {
    font-size: 17px;
  }

  .wp-vp-speed {
    font-size: 18px;
  }

  .wp-vp-hero {
    height: 130px;
  }
}

@media (min-width: 768px) {
  body.wp-vehicle-panel-open #root .react-draggable,
  body.wp-vehicle-panel-open #root [class*='react-draggable'] {
    display: none !important;
  }
}

/* Hero */
.wp-vp-hero {
  position: relative;
  height: clamp(130px, 22vw, 168px);
  flex-shrink: 0;
  background: #cbd5e1 center/cover no-repeat;
  overflow: hidden;
}

.wp-vp-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.15) 0%, rgba(15, 23, 42, 0.75) 100%);
  pointer-events: none;
}

.wp-vp-hero-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top, 0px));
  pointer-events: none;
}

.wp-vp-hero-bar > * {
  pointer-events: auto;
}

@media (max-width: 767px) {
  .wp-vp-hero-bar {
    padding-top: 18px;
  }
}

.wp-vp-icon-btn {
  background: rgba(255, 255, 255, 0.92);
  border: none;
  color: #334155;
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  font-size: 18px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  position: relative;
  z-index: 21;
  pointer-events: auto;
}

.wp-vp-icon-btn:active {
  transform: scale(0.96);
}

.wp-vp-icon-btn:hover {
  background: #fff;
  color: #0ea5e9;
}

.wp-vp-hero-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 10px 14px 12px;
  color: #fff;
}

.wp-vp-name {
  margin: 0 0 4px;
  font-size: clamp(17px, 4.5vw, 20px);
  font-weight: 700;
  line-height: 1.2;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wp-vp-hero-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  margin-top: 2px;
}

.wp-vp-speed {
  font-size: clamp(18px, 5vw, 22px);
  font-weight: 800;
}

.wp-vp-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wp-vp-pill.online {
  background: rgba(16, 185, 129, 0.35);
}

.wp-vp-pill.offline {
  background: rgba(239, 68, 68, 0.35);
}

/* Layout */
.wp-vp-layout {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.wp-vp-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 12px calc(16px + var(--wp-safe-bottom));
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.wp-vp-rail {
  width: 0;
  overflow: hidden;
  transition: width 0.3s ease;
  background: #fff;
  border-left: 1px solid #e2e8f0;
  flex-shrink: 0;
}

body.wp-vp-rail-open .wp-vp-rail {
  width: min(200px, 42vw);
}

.wp-vp-rail-inner {
  width: min(200px, 42vw);
  padding: 12px 10px;
  height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
  body.wp-vp-rail-open .wp-vp-rail {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(260px, 78vw) !important;
    z-index: 20;
    box-shadow: -10px 0 30px rgba(15, 23, 42, 0.12);
  }

  .wp-vp-rail-inner {
    width: 100%;
  }
}

.wp-vp-rail h4 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
}

.wp-vp-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
  cursor: pointer;
  color: #334155;
  line-height: 1.35;
  min-height: 44px;
  box-sizing: border-box;
}

.wp-vp-check input {
  margin-top: 4px;
  width: 18px;
  height: 18px;
  accent-color: #0ea5e9;
  flex-shrink: 0;
}

/* Cards */
.wp-vp-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
  border: 1px solid #e8ecf2;
  margin-bottom: 10px;
  overflow: hidden;
}

.wp-vp-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
}

.wp-vp-card-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}

.wp-vp-card-head a {
  font-size: 12px;
  color: #0ea5e9;
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.wp-vp-card-body {
  padding: 10px 14px 12px;
  font-size: 13px;
}

.wp-vp-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid #f1f5f9;
}

.wp-vp-row:last-child {
  border-bottom: none;
}

.wp-vp-row span:first-child {
  color: #64748b;
  flex: 0 1 45%;
  font-size: 12px;
  line-height: 1.35;
}

.wp-vp-row span:last-child {
  font-weight: 600;
  color: #0f172a;
  text-align: right;
  word-break: break-word;
  flex: 1 1 55%;
  font-size: 13px;
  line-height: 1.35;
}

@media (max-width: 400px) {
  .wp-vp-row {
    flex-direction: column;
    gap: 3px;
  }

  .wp-vp-row span:last-child {
    text-align: left;
  }
}

.wp-vp-empty {
  color: #94a3b8;
  font-size: 12px;
  padding: 6px 0;
}

/* Events */
.wp-vp-event {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
}

.wp-vp-event:last-child {
  border-bottom: none;
}

.wp-vp-event-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0ea5e9;
  margin-top: 6px;
  flex-shrink: 0;
}

.wp-vp-event-dot.alarm {
  background: #ef4444;
}

.wp-vp-event-title {
  font-weight: 600;
  font-size: 13px;
  color: #0f172a;
  margin-bottom: 2px;
  line-height: 1.35;
}

.wp-vp-event-time {
  font-size: 11px;
  color: #94a3b8;
}

/* Tags */
.wp-vp-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.wp-vp-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fce7f3;
  color: #9d174d;
}

.wp-vp-tag.blue {
  background: #dbeafe;
  color: #1d4ed8;
}

/* Quick actions — replay only */
.wp-vp-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 0 12px 10px;
  flex-shrink: 0;
}

.wp-vp-action {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 6px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  text-align: center;
  line-height: 1.25;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.wp-vp-action:active {
  background: #f8fafc;
}

.wp-vp-action:hover {
  border-color: #0ea5e9;
  color: #0ea5e9;
}

/* Settings */
.wp-vp-settings {
  position: fixed;
  inset: 0;
  z-index: 1700;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(15, 23, 42, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  padding: var(--wp-safe-top) var(--wp-safe-right) var(--wp-safe-bottom) var(--wp-safe-left);
  box-sizing: border-box;
}

.wp-vp-settings.open {
  opacity: 1;
  pointer-events: auto;
}

.wp-vp-settings-box {
  width: min(420px, 100%);
  max-height: min(85dvh, 85vh);
  overflow-y: auto;
  background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 20px 20px calc(20px + var(--wp-safe-bottom));
  box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.15);
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
  .wp-vp-settings {
    align-items: center;
    justify-content: flex-end;
  }

  .wp-vp-settings-box {
    width: min(360px, 90vw);
    max-height: 80vh;
    border-radius: 16px;
    margin-right: calc(var(--wp-panel-width) + 12px);
    margin-bottom: 20px;
  }
}

.wp-vp-settings-box h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.wp-vp-settings-hint {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 14px;
  line-height: 1.4;
}

.wp-vp-settings-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.wp-vp-btn {
  flex: 1;
  min-height: 44px;
  padding: 10px;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  touch-action: manipulation;
}

.wp-vp-btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #3b82f6);
  color: #fff;
}

.wp-vp-btn-ghost {
  background: #f1f5f9;
  color: #334155;
}
