/**
 * iToll Marketplace — My Vehicles ("خودروهای من")
 *
 * Rendered inside the My Account shell, so it borrows the theme's design system
 * (blocksy-child / assets/css/aita-account.css): the `--aita-*` tokens, the
 * `.aita-card` shell, `.aita-badge`, `.aita-input` and `.aita-empty`.
 * Every token carries a fallback so the page still degrades sanely if the
 * account stylesheet is not on the page.
 *
 * Only what the theme has no equivalent for lives here: the license plate,
 * the vehicle row, and the config modal.
 */

/* ============================================
   CARD HEAD
   ============================================ */
.im-vehicles .aita-card__head {
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.im-vehicles__sub {
  font-size: 13px;
  line-height: 1.9;
  color: var(--aita-muted, #6b7280);
  margin: 6px 0 0;
  max-width: 62ch;
}

/* ============================================
   VEHICLE LIST
   ============================================ */
.im-vlist {
  list-style: none;
  margin: 0;
  padding: 0;
}
.im-vrow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--aita-line-2, #eef0f4);
}
.im-vrow:last-child { border-bottom: 0; }

.im-vrow__main {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.im-vrow__thumb {
  width: 84px;
  height: 64px;
  flex: none;
  border-radius: 14px;
  border: 1px solid var(--aita-line, rgba(0, 0, 0, 0.07));
  background: var(--aita-bg-soft, #f7f8fa);
  color: var(--aita-muted-2, #9ca3af);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.im-vrow__thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.im-vrow__thumb svg { width: 30px; height: 30px; }

.im-vrow__info { min-width: 0; }
.im-vrow__title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 4px;
  overflow-wrap: anywhere;
}
.im-vrow__year {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--aita-muted, #6b7280);
  font-feature-settings: "tnum";
  margin-inline-start: 4px;
}
.im-vrow__desc {
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--aita-muted, #6b7280);
  margin: 0 0 10px;
}
.im-vrow__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 10px 0 0;
}
.im-vfact {
  font-size: 12.5px;
  color: var(--aita-muted, #6b7280);
  font-weight: 600;
}
.im-vfact b {
  color: var(--aita-ink, #111);
  font-weight: 700;
  font-feature-settings: "tnum";
  margin-inline-start: 3px;
}
.im-vfact--match b { color: var(--aita-accent-2, #15803d); }

/* ============================================
   LOADING SKELETON
   Placeholder blocks sized like the real row, so swapping in the fetched
   list doesn't shift anything.
   ============================================ */
.im-vlist-wrap.is-refreshing { opacity: .55; transition: opacity .15s ease; }

.im-sk {
  border-radius: 8px;
  background: var(--aita-bg-soft, #f7f8fa);
  background-image: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, .85) 50%,
    transparent 100%
  );
  background-size: 220% 100%;
  background-repeat: no-repeat;
  animation: im-sk-shimmer 1.25s ease-in-out infinite;
}
@keyframes im-sk-shimmer {
  from { background-position: -110% 0; }
  to   { background-position: 110% 0; }
}
.im-sk--thumb {
  width: 84px;
  height: 64px;
  flex: none;
  border-radius: 14px;
}
.im-sk--title { width: 180px; height: 15px; margin-bottom: 9px; }
.im-sk--desc  { width: 240px; height: 12px; margin-bottom: 14px; max-width: 100%; }
.im-sk--plate { width: 148px; height: 34px; border-radius: 8px; }
.im-sk--badge { width: 104px; height: 26px; border-radius: 999px; }
.im-sk--btn   { width: 148px; height: 38px; border-radius: 10px; }

.im-vlist__status {
  margin: 0;
  padding: 0 24px 20px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--aita-muted, #6b7280);
}

@media (prefers-reduced-motion: reduce) {
  .im-sk { animation: none; }
}

/* ============================================
   LICENSE PLATE
   ============================================ */
.im-plate {
  display: inline-flex;
  align-items: stretch;
  height: 34px;
  margin: 10px 0 0;
  background: #fff;
  border: 1.5px solid var(--aita-ink, #111);
  border-radius: 8px;
  overflow: hidden;
  direction: ltr;
  box-shadow: var(--aita-shadow-1, 0 1px 2px rgba(16, 24, 40, 0.05));
  font-feature-settings: "tnum";
  user-select: none;
}
.im-plate__flag {
  width: 22px;
  flex: none;
  background: #003399;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 3px 0;
}
.im-plate__flag i {
  width: 13px;
  height: 6px;
  display: block;
  background: linear-gradient(to bottom, #22c55e 33%, #fff 33%, #fff 66%, #ef4444 66%);
}
.im-plate__flag span {
  font-size: 5.5px;
  font-weight: 700;
  letter-spacing: -0.2px;
  font-style: normal;
}
.im-plate__num {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  font-size: 16px;
  font-weight: 800;
  color: var(--aita-ink, #111);
}
.im-plate__city {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  border-inline-start: 1.5px solid var(--aita-ink, #111);
  line-height: 1.15;
}
.im-plate__city span {
  font-size: 7px;
  font-weight: 700;
  color: var(--aita-muted, #6b7280);
}
.im-plate__city b {
  font-size: 13px;
  font-weight: 800;
  color: var(--aita-ink, #111);
}
.im-plate--plain {
  align-items: center;
  padding-inline-end: 10px;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--aita-ink, #111);
  direction: rtl;
}
.im-plate--plain .im-plate__flag { margin-inline-end: 2px; }
.im-plate--none {
  display: inline-flex;
  align-items: center;
  margin: 10px 0 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--aita-bg-soft, #f7f8fa);
  color: var(--aita-muted, #6b7280);
  font-size: 11.5px;
  font-weight: 700;
}

/* ============================================
   BUTTONS
   Small actions reuse the theme's .aita-orow__btn.
   This is the modal's full-width CTA — the .aita-submit look, which the
   theme scopes to .aita-formcard and is therefore not reusable here.
   ============================================ */
.im-btn-primary {
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 13px;
  background: var(--aita-primary, #1e2a78);
  color: #fff;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 700;
  line-height: normal;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: background .2s, transform .15s, box-shadow .2s;
}
.im-btn-primary:hover:not(:disabled) {
  background: var(--aita-primary-2, #2a3a8c);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 16px 30px -12px rgba(30, 42, 120, 0.65);
}
.im-btn-primary:active:not(:disabled) { transform: translateY(1px); }
.im-btn-primary:disabled { opacity: .6; cursor: default; }
.im-btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(30, 42, 120, 0.25);
}
.im-btn-primary svg { width: 18px; height: 18px; }

/* ============================================
   CONFIG MODAL — mirrors .aita-order-modal
   ============================================ */
/* Scroll lock. `body { overflow: hidden }` alone is not enough here: the parent
   theme sets `body { overflow-x: hidden }` and iOS Safari ignores it outright,
   so the page keeps scrolling behind the overlay. Freezing the body with
   `position: fixed` is the only lock that holds everywhere — my-vehicles.js
   stores the offset in `top` and restores the scroll position on close. */
/* The theme scopes `box-sizing: border-box` to `.aita-page *`, but the modal is
   moved to <body> on open and so falls outside it — restate it here or every
   `width: 100%` field inside picks up its padding on top. */
.im-vmodal,
.im-vmodal *,
.im-combo,
.im-combo * { box-sizing: border-box; }

html.im-vmodal-open { overflow: hidden; }
body.im-vmodal-open {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
}
.im-vmodal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  overscroll-behavior: contain;
  display: grid;
  place-items: center;
  padding: 22px;
  direction: rtl;
  font-family: inherit;
  opacity: 0;
  visibility: hidden;
  transition: opacity .18s ease, visibility .18s ease;
}
.im-vmodal[aria-hidden="false"] {
  opacity: 1;
  visibility: visible;
}
.im-vmodal__shade {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, .58);
  backdrop-filter: blur(2px);
}
.im-vmodal__panel {
  position: relative;
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 44px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--aita-line, rgba(0, 0, 0, 0.07));
  border-radius: 18px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, .24);
  color: var(--aita-ink, #111);
  transform: translateY(10px);
  transition: transform .18s ease;
}
.im-vmodal[aria-hidden="false"] .im-vmodal__panel { transform: translateY(0); }
.im-vmodal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--aita-line, rgba(0, 0, 0, 0.07));
}
.im-vmodal__head h3 {
  margin: 0;
  color: var(--aita-primary, #1e2a78);
  font-size: 18px;
  font-weight: 800;
}
.im-vmodal__close {
  width: 40px;
  height: 40px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--aita-muted, #6b7280);
  font-family: inherit;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}
.im-vmodal__close:hover {
  background: var(--aita-primary-soft, rgba(30, 42, 120, 0.07));
  color: var(--aita-primary, #1e2a78);
  border-color: var(--aita-line-2, #eef0f4);
}
.im-vmodal__close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(30, 42, 120, 0.12);
}
.im-vmodal__body {
  overflow: auto;
  overscroll-behavior: contain;
  padding: 22px 24px;
}
.im-vmodal__foot {
  padding: 18px 24px;
  border-top: 1px solid var(--aita-line, rgba(0, 0, 0, 0.07));
  background: var(--aita-bg-soft, #f7f8fa);
}

/* ============================================
   SEARCHABLE SELECT
   Same class contract as the panels' .im-searchable (see vendor-panel.css),
   restyled on the account page's tokens. The native <select> stays in the DOM
   and still carries the submitted value.
   ============================================ */
.im-combo { position: relative; }
.im-combo__native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.im-combo__search { cursor: text; }
/* Fixed, not absolute: the field sits inside .im-vmodal__body, which scrolls
   (overflow: auto) and would otherwise clip the list. JS anchors it to the
   input's viewport rect and flips it above the field when space runs out. */
.im-combo__list {
  position: fixed;
  z-index: 100000;
  max-height: 240px;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 5px;
  list-style: none;
  background: #fff;
  border: 1px solid var(--aita-line, rgba(0, 0, 0, 0.07));
  border-radius: var(--aita-radius-sm, 12px);
  box-shadow: var(--aita-shadow-2, 0 22px 50px -22px rgba(16, 24, 40, .22));
}
.im-combo__list[hidden] { display: none; }
.im-combo__opt {
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 13.5px;
  line-height: 1.7;
  cursor: pointer;
}
.im-combo__opt.is-cursor { background: var(--aita-primary-soft, rgba(30, 42, 120, 0.07)); }
.im-combo__opt.is-active {
  background: var(--aita-primary, #1e2a78);
  color: #fff;
}
.im-combo__empty {
  padding: 12px 11px;
  font-size: 13px;
  color: var(--aita-muted, #6b7280);
  text-align: center;
}

/* the theme's .aita-input has no unit affordance */
.im-suffix-wrap { position: relative; }
.im-suffix-wrap .aita-input { padding-inline-end: 74px; }
.im-suffix {
  position: absolute;
  inset-inline-end: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  font-weight: 600;
  color: var(--aita-muted, #6b7280);
  pointer-events: none;
}

/* inline feedback inside the modal */
.im-vmodal__notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.7;
  background: #fef2f2;
  color: #b91c1c;
}
.im-vmodal__notice[hidden] { display: none; }

/* ============================================
   RESPONSIVE — matches the theme's breakpoints
   ============================================ */
@media (max-width: 900px) {
  .im-vrow {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px 18px;
  }
  .im-vrow__main { grid-column: 1 / -1; }
  /* the badge lands in the 1fr track once wrapped — keep it pill-sized */
  .im-vrow .aita-badge { justify-self: start; }
  .im-vrow__actions { justify-self: end; }
}
@media (max-width: 560px) {
  .im-vrow { padding: 16px; }
  .im-vrow__main {
    align-items: flex-start;
    gap: 12px;
  }
  .im-vrow__thumb { width: 64px; height: 50px; }
  .im-vrow__thumb svg { width: 24px; height: 24px; }
  .im-vrow__actions,
  .im-vrow__actions .aita-orow__btn {
    width: 100%;
    justify-content: center;
  }
  .im-vmodal { padding: 12px; }
  .im-vmodal__panel {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    border-radius: 14px;
  }
  .im-vmodal__head { padding: 16px; }
  .im-vmodal__head h3 { font-size: 16px; }
  .im-vmodal__body { padding: 16px; }
  .im-vmodal__foot { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .im-vmodal,
  .im-vmodal__panel,
  .im-btn-primary { transition: none; }
}
