/* Compatibility layer for the stable Abu Sahiy cabinet bundle.
   Loaded last so legacy enhancement files cannot collapse core layouts. */

/* Let operational pages use the available desktop width. */
@media (min-width: 768px) {
  .cabinet-route-home .home-main,
  .cabinet-route-address .address-main {
    width: 100%;
    max-width: none !important;
    margin-inline: 0 !important;
  }

  .cabinet-route-address .address-countries {
    width: clamp(250px, 18vw, 300px) !important;
    flex: 0 0 clamp(250px, 18vw, 300px);
  }

  .cabinet-route-address .address-results {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    grid-auto-rows: max-content !important;
    align-content: start !important;
    align-items: start !important;
    gap: 20px !important;
    width: 100% !important;
    padding: 24px !important;
  }

  .cabinet-route-address .address-results > div {
    min-width: 0;
    height: auto !important;
    align-self: start !important;
  }

  .cabinet-route-address .address-results > div > .bg-white {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    min-width: 0;
    margin: 0 !important;
    overflow: visible !important;
  }
}

@media (min-width: 1280px) and (max-width: 1799px) {
  .cabinet-route-address .address-results {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* Country flags replaced the original globe icons, so they need explicit
   dimensions. Without these rules Tailwind padding squeezes them into dots. */
.country-flag-icon {
  display: inline-grid !important;
  place-items: center !important;
  width: 42px !important;
  height: 34px !important;
  min-width: 42px !important;
  padding: 6px !important;
  overflow: hidden;
  border: 1px solid #dbe2eb;
  border-radius: 10px !important;
  background: #f8fafc !important;
}

.country-flag-image {
  display: block !important;
  width: 30px !important;
  height: 18px !important;
  max-width: none !important;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(42, 49, 60, .12);
}

.side-item.active .country-flag-icon {
  border-color: #ffc4c7 !important;
  background: #fff !important;
}

/* Address comments use a 20px status icon. In a flex row it previously
   shrank to a thin mark next to long text. */
.cabinet-route-address .address-results > div > .bg-white > .flex:last-child:not(.border) {
  align-items: flex-start !important;
  gap: 10px;
  margin-top: 16px;
}

.cabinet-route-address .address-results > div > .bg-white > .flex:last-child:not(.border) > div:first-child {
  display: inline-grid !important;
  place-items: center !important;
  flex: 0 0 20px !important;
  width: 20px !important;
  min-width: 20px !important;
  height: 20px !important;
  margin: 1px 0 0 !important;
}

.cabinet-route-address .address-results > div > .bg-white > .flex:last-child:not(.border) > p {
  min-width: 0;
  margin: 0 !important;
  line-height: 1.5 !important;
  overflow-wrap: anywhere;
}

.cabinet-route-address .address-results h4 {
  min-width: 0;
  line-height: 1.3 !important;
  overflow-wrap: anywhere;
}

.cabinet-route-address .address-results .border.rounded-xl {
  display: flex !important;
  flex: 0 0 auto !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
  min-width: 0;
  overflow: visible !important;
}

.cabinet-route-address .address-results .border.rounded-xl > div {
  width: 100% !important;
  min-width: 0;
  height: auto !important;
  margin-top: 0 !important;
}

.cabinet-route-address .address-results .border.rounded-xl p,
.cabinet-route-address .address-results .border.rounded-xl div {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.cabinet-route-address .address-results .border.rounded-xl p {
  display: block !important;
  width: 100%;
  line-height: 1.45 !important;
}

/* Keep the emphasized liquids warning readable inside every card size. */
.liquid-warning-v1__headline {
  align-items: flex-start !important;
}

.liquid-warning-v1__headline > span:last-child,
.liquid-warning-v1__details {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 1279px) and (min-width: 768px) {
  .cabinet-route-address .address-main {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
  }

  .cabinet-route-address .address-countries {
    width: 100% !important;
    min-height: 0 !important;
  }

  .cabinet-route-address .address-countries > .sticky {
    position: static !important;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    height: auto !important;
    gap: 12px;
  }

  .cabinet-route-address .address-results {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 1023px) {
  .cabinet-route-address .address-results {
    grid-template-columns: minmax(0, 1fr) !important;
  }
}

@media (max-width: 767px) {
  .country-flag-icon {
    width: 42px !important;
    height: 34px !important;
    min-width: 42px !important;
    padding: 6px !important;
  }

  .cabinet-route-address .address-results {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .cabinet-route-address .address-results > div > .bg-white {
    width: 100% !important;
    min-width: 0;
  }
}

/* Keep internal directory IDs out of the UI while async reference data loads. */
.v-select.cabinet-select-resolving .vs__selected {
  visibility: hidden !important;
}

.v-select.cabinet-select-resolving .vs__selected-options::before {
  content: "Загрузка…";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  color: #98a2b3;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  pointer-events: none;
}

.v-select.cabinet-select-resolving .vs__selected-options {
  position: relative;
}

/* Recipient editor: keep every address field reachable and make the scroll
   area visually obvious instead of letting the fixed action row cover it. */
.cabinet-route-recipients .overlay {
  background: rgba(27, 34, 47, .32) !important;
  background-color: rgba(27, 34, 47, .32) !important;
  backdrop-filter: blur(5px) !important;
}

.cabinet-route-recipients .overlay .popup[role="dialog"]:has(.input-groups.grid-cols-3) {
  position: relative !important;
  display: flex !important;
  flex-direction: column !important;
  width: min(980px, calc(100vw - 64px)) !important;
  max-width: 980px !important;
  max-height: calc(100vh - 48px) !important;
  padding-bottom: 0 !important;
  overflow: hidden !important;
}

.cabinet-route-recipients .overlay .popup.recipient-editor-loading[role="dialog"]:has(.input-groups.grid-cols-3) {
  min-height: 360px;
}

.cabinet-route-recipients .overlay .popup.recipient-editor-loading[role="dialog"]:has(.input-groups.grid-cols-3) > * {
  visibility: hidden;
}

.cabinet-route-recipients .overlay .popup.recipient-editor-loading[role="dialog"]:has(.input-groups.grid-cols-3)::after {
  content: 'Загрузка данных получателя…';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  visibility: visible;
  color: #475569;
  font-size: 15px;
  font-weight: 600;
}

.cabinet-route-recipients .overlay .popup[role="dialog"]:has(.input-groups.grid-cols-3) > div:first-child {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: none !important;
  margin-bottom: 0 !important;
  padding-right: 12px !important;
  padding-bottom: 24px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  scrollbar-gutter: stable;
}

.cabinet-route-recipients .overlay .popup[role="dialog"]:has(.input-groups.grid-cols-3) > .buttons {
  position: relative;
  z-index: 2;
  flex: 0 0 auto !important;
  min-height: 76px;
  padding: 14px 24px 16px !important;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.cabinet-route-recipients .overlay .popup[role="dialog"]:has(.input-groups.grid-cols-3) > div:first-child::-webkit-scrollbar {
  width: 8px;
}

.cabinet-route-recipients .overlay .popup[role="dialog"]:has(.input-groups.grid-cols-3) > div:first-child::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #cbd5e1;
}

@media (max-width: 767px) {
  .cabinet-route-recipients .overlay .popup[role="dialog"]:has(.input-groups.grid-cols-3) {
    width: calc(100vw - 16px) !important;
    max-height: calc(100vh - 16px) !important;
    margin: 8px !important;
  }
}

/* Cargo history base styles were previously embedded in index.html. When the
   stable shell was restored, the enhancer still ran but its dimensions were
   lost, which made the inline SVG fill most of the page. */
.cabinet-route-details .grid.grid-cols-3:has(.client-history-list) {
  display: block !important;
  width: auto !important;
  min-width: 0;
  margin: 20px !important;
  padding: 20px !important;
  border: 1px solid #dce3ec;
  border-radius: 16px;
  background: #fff !important;
  box-shadow: 0 2px 10px rgba(32, 36, 61, .025);
}

.cabinet-route-details .client-history-shell {
  display: block !important;
  width: auto !important;
  min-width: 0;
  margin: 20px !important;
  padding: 20px !important;
  border: 1px solid #dce3ec;
  border-radius: 16px;
  background: #fff !important;
  box-shadow: 0 2px 10px rgba(32, 36, 61, .025);
  overflow: visible !important;
}

.cabinet-route-details .client-history-panel {
  display: contents !important;
}

.cabinet-route-details .client-history-shell > .client-history-panel > .border-b {
  display: block !important;
  margin: 0 0 8px !important;
  border-bottom: 1px solid #d8e3f8 !important;
}

.cabinet-route-details .client-history-list {
  display: grid !important;
  position: static !important;
  width: 100%;
  height: auto !important;
  max-height: none !important;
  min-width: 0;
  margin: 0 !important;
  padding: 18px 0 4px !important;
  overflow: visible !important;
  font-variant-numeric: tabular-nums;
}

.cabinet-route-details .client-history-item {
  display: grid !important;
  grid-template-columns: 132px 28px minmax(0, 1fr) !important;
  align-items: start;
  width: 100%;
  min-width: 0;
  padding: 0 0 16px !important;
}

.cabinet-route-details .client-history-item > p:first-child {
  display: flex !important;
  flex-direction: column;
  gap: 2px;
  padding: 13px 16px 0 0 !important;
  color: #455468 !important;
  font-size: 12px !important;
  line-height: 1.3;
  text-align: right !important;
  white-space: nowrap;
}

.cabinet-route-details .client-history-date { font-weight: 700; }
.cabinet-route-details .client-history-time { color: #7c8ba0; font-weight: 500; }

.cabinet-route-details .client-history-item > div {
  position: relative;
  min-height: 100%;
}

.cabinet-route-details .client-history-list .client-history-item .items-st::after {
  display: none !important;
}

.cabinet-route-details .client-history-item > div::after {
  content: '';
  position: absolute;
  top: 20px;
  bottom: -16px;
  left: 50%;
  width: 2px;
  background: #e4e9f0;
  transform: translateX(-50%);
}

.cabinet-route-details .client-history-item:last-child > div::after,
.cabinet-route-details .client-history-item.client-history-visible-last > div::after {
  display: none;
}

.cabinet-route-details .client-history-hidden { display: none !important; }

.cabinet-route-details .client-history-item > p:last-child {
  position: relative;
  inset: auto !important;
  width: 100% !important;
  min-width: 0;
  display: flex !important;
  gap: 12px;
  min-height: 70px;
  margin: 0 !important;
  padding: 14px 16px !important;
  border: 1px solid #dfe5ee;
  border-radius: 12px;
  background: #fff;
  color: #2a313c;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.cabinet-route-details .client-history-icon {
  display: inline-flex !important;
  flex: 0 0 36px !important;
  align-items: center;
  justify-content: center;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px;
  max-width: 36px;
  border-radius: 10px;
  background: #f2f4f7;
  color: #667085;
}

.cabinet-route-details .client-history-icon svg {
  display: block;
  width: 20px !important;
  height: 20px !important;
  max-width: 20px !important;
}

.cabinet-route-details .client-history-icon--created { background: #eef2ff; color: #5b6ee1; }
.cabinet-route-details .client-history-icon--package,
.cabinet-route-details .client-history-icon--pallet,
.cabinet-route-details .client-history-icon--container { background: #fff3e6; color: #e67e22; }
.cabinet-route-details .client-history-icon--warehouse { background: #eaf7f1; color: #168a62; }
.cabinet-route-details .client-history-icon--ready { background: #f0f9e8; color: #559b24; }
.cabinet-route-details .client-history-icon--truck { background: #fff0f0; color: #dc4c58; }
.cabinet-route-details .client-history-icon--plane { background: #eaf4ff; color: #2878c8; }
.cabinet-route-details .client-history-icon--arrival { background: #e9f8ff; color: #0786ad; }
.cabinet-route-details .client-history-icon--payment { background: #edf8ee; color: #238636; }
.cabinet-route-details .client-history-icon--delivered,
.cabinet-route-details .client-history-icon--completed { background: #f1edff; color: #7048c8; }
.cabinet-route-details .client-history-icon--info { background: #f2f4f7; color: #667085; }

.cabinet-route-details .client-history-content {
  display: block;
  min-width: 0;
  padding-top: 1px;
}

.cabinet-route-details .client-history-description {
  display: block;
  margin-top: 5px;
  color: #58677c !important;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
}

.cabinet-route-details .client-history-current > p:last-child {
  border-color: #ef3940;
  background: #fffafa;
  box-shadow: 0 8px 24px rgba(32, 36, 61, .07);
}

.cabinet-route-details .client-history-current .items-st { background: transparent !important; }
.cabinet-route-details .client-history-current .circle { background: #ef3940 !important; }
.cabinet-route-details .client-history-current .client-history-icon { background: #ef3940; color: #fff; }

.cabinet-route-details .client-history-current-badge {
  display: inline-flex;
  margin-top: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(239, 57, 64, .1);
  color: #ef3940;
  font-size: 11px;
  font-weight: 700;
}

.cabinet-route-details .client-history-cargo {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.cabinet-route-details .client-history-cargo-item {
  display: block;
  width: fit-content;
  max-width: 100%;
  padding: 5px 9px;
  border-radius: 8px;
  background: #f2f6fb;
  color: #52637a;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.cabinet-route-details .client-history-more {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 160px;
  min-height: 42px;
  margin: 4px auto 8px;
  padding: 10px 20px;
  border: 1px solid #ef3940;
  border-radius: 10px;
  background: #fff;
  color: #ef3940;
  font-size: 13px;
  font-weight: 700;
}

.cabinet-route-details .client-history-more[hidden] { display: none; }

@media (max-width: 767px) {
  .cabinet-route-details .client-history-list {
    max-width: 100% !important;
    padding: 16px 0 8px !important;
    overflow: hidden !important;
  }

  .cabinet-route-details .client-history-item {
    grid-template-columns: 32px minmax(0, 1fr) !important;
    column-gap: 10px !important;
    row-gap: 8px !important;
    max-width: 100% !important;
    overflow: hidden;
  }

  .cabinet-route-details .client-history-item > p:first-child {
    grid-column: 2 !important;
    grid-row: 1 !important;
    flex-direction: row;
    gap: 6px;
    min-width: 0;
    min-height: 18px;
    padding: 0 0 8px 2px !important;
    text-align: left !important;
    white-space: normal;
  }

  .cabinet-route-details .client-history-item > div {
    grid-column: 1 !important;
    grid-row: 1 / span 2 !important;
    width: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    background: transparent !important;
  }

  .cabinet-route-details .client-history-item > p:last-child {
    grid-column: 2 !important;
    grid-row: 2 !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 12px !important;
    overflow: hidden;
    white-space: normal !important;
  }

  .cabinet-route-details .client-history-content,
  .cabinet-route-details .client-history-description,
  .cabinet-route-details .client-history-cargo-item {
    min-width: 0;
    white-space: normal !important;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .cabinet-route-details .client-history-icon {
    flex-basis: 32px !important;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px;
    max-width: 32px;
  }
}
