/* ══ Мобильная адаптация UzLogistics (грузится после main.css) ══ */

.chat-back-btn { display: none; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%; background: #f3f4f6;
  color: #111; text-decoration: none; margin-right: 10px; flex-shrink: 0; font-size: 16px; }

@media (max-width: 860px) {
  .page-content, .content { padding: 12px !important; }
  img, svg, video, canvas { max-width: 100%; height: auto; }

  .page-header { flex-wrap: wrap !important; gap: 10px; }
  .page-header-actions { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
  .page-header h1 { font-size: 20px !important; }

  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .table-wrap table { min-width: 640px; }
  table th, table td { white-space: nowrap; }
  .table-toolbar { flex-wrap: wrap; gap: 8px; }
  .order-route .route-from, .order-route .route-to { white-space: normal; min-width: 120px; }

  .admin-dashboard-grid, .reports-grid, .ctrl-grid-2 { display: block !important; }
  .admin-dashboard-grid > *, .reports-grid > * { margin-bottom: 14px; }

  input, select, textarea { max-width: 100%; }
  .complaint-modal { max-width: 94vw; margin: 10px; padding: 18px; }

  /* ── Чаты ── */
  .chats-grid, .chats-layout { display: block !important; height: auto !important; }
  .chats-sidebar-left, .chats-sidebar { width: 100% !important; min-width: 0 !important;
    max-width: none !important; border-right: none !important; height: auto !important; }
  .chats-grid:has(.chat-main-header) .chats-sidebar-left,
  .chats-layout:has(.chat-main-header) .chats-sidebar { display: none !important; }
  .chats-grid:not(:has(.chat-main-header)) .chat-main,
  .chats-layout:not(:has(.chat-main-header)) .chat-main { display: none !important; }
  .chat-main { height: calc(100dvh - 120px) !important; display: flex !important; }
  .chat-messages { min-height: 0; }
  .msg-bubble { max-width: 82vw; }
  .chat-preview { max-width: 52vw; }
  .chat-back-btn { display: inline-flex !important; }
  .chat-main-header { padding-right: 70px !important; }

  /* ── Карта: фильтры-гармошка ── */
  .fleet-wrapper { display: block !important; height: auto !important; }
  .fleet-map-container { height: 54dvh !important; min-height: 320px; position: relative; }
  .fleet-map-container #map, .leaflet-container { height: 100% !important; }

  .smart-filters { position: absolute; top: 10px; left: 10px; z-index: 1000;
    display: flex; flex-direction: column; gap: 6px; width: auto; max-width: 78vw;
    background: #fff; border-radius: 12px; padding: 6px;
    box-shadow: 0 4px 14px rgba(0,0,0,.18); }
  .smart-filters:not(.open) .filter-btn:not(.active) { display: none !important; }
  .smart-filters:not(.open) .v-divider,
  .smart-filters:not(.open) .city-search-box { display: none !important; }
  .smart-filters:not(.open) .filter-btn.active::after { content: " ▾"; opacity: .6; }
  .smart-filters.open { max-height: 62dvh; overflow-y: auto; }
  .smart-filters .filter-btn { width: 100%; justify-content: flex-start;
    font-size: 13px; padding: 8px 10px; white-space: nowrap; }
  .smart-filters .v-divider { width: 100%; height: 1px; background: #e5e7eb; }
  .smart-filters .city-search-box { display: flex; flex-wrap: wrap; gap: 6px; }
  .smart-filters .city-search-box input { flex: 1 1 100%; }

  .doc-legend { display: none !important; }

  .fleet-sidebar { width: 100% !important; max-height: 40dvh; overflow-y: auto;
    border-left: none !important; border-top: 1px solid #e2e8f0; }
}

/* sidebar-above-map: боковое меню всегда выше карты Leaflet */
.sidebar { z-index: 3000 !important; }
.sidebar-overlay { z-index: 2900 !important; }
.topbar { z-index: 2000; }

/* ── uz-cards: любые таблицы карточками на мобильном ── */
@media (max-width: 860px) {
  table.uz-cards { display: block; min-width: 0 !important; }
  table.uz-cards thead { display: none; }
  table.uz-cards tbody { display: block; width: 100%; }
  table.uz-cards tr { display: block; background: #fff; border: 1px solid #e5e7eb;
    border-radius: 12px; padding: 12px 14px; margin: 0 0 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05); }
  table.uz-cards td { display: block; border: none !important;
    padding: 4px 0 !important; white-space: normal !important; font-size: 13px; }
  table.uz-cards td::before { content: attr(data-label) ": "; color: #9ca3af; font-size: 12px; }
  table.uz-cards td:not([data-label])::before,
  table.uz-cards td[data-label=""]::before { content: none; }
  table.uz-cards td:empty { display: none; }
  table.uz-cards td .d-flex { flex-wrap: wrap; gap: 8px; margin-top: 4px; }
  table.uz-cards td .btn { justify-content: center; }
  table.uz-cards tr td:first-child { font-weight: 700; font-size: 14px; }
}

/* ── detail-stack: страницы деталей в одну колонку на мобильном ── */
@media (max-width: 860px) {
  .content [class*="-grid"]:not(.stats-grid):not(.chats-grid),
  .grid-2, .grid-3, .detail-grid, .doc-grid, .docs-grid {
    display: block !important; grid-template-columns: none !important; }
  .content [class*="-grid"]:not(.stats-grid):not(.chats-grid) > *,
  .grid-2 > *, .grid-3 > * { margin-bottom: 14px; max-width: 100%; }

  .card { max-width: 100% !important; overflow: hidden; }

  input[type="file"] { width: 100% !important; font-size: 12px; margin-top: 2px; }
  .form-row, .form-row.cols-2, .form-row.cols-3 { display: block !important; }
  .form-row > * { margin-bottom: 10px; }
  label { font-size: 12px; }
}

select::-ms-expand { display: none; }

.password-toggle, .toggle-password, .input-eye,
.input-wrap .bi-eye, .input-wrap .bi-eye-slash {
  top: 50% !important;
  transform: translateY(-50%) !important;
  bottom: auto !important;
  display: inline-flex; align-items: center;
}


/* ── ui-polish-v3 ── */
select, .form-select, .filter-select {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
}
select::-ms-expand { display: none; }

/* Строка поля с иконками: всегда одна линия, на любой ширине */
.input-wrap, .input-group, .field-row, .input-with-icon {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  position: relative;
  width: 100%;
}
.input-wrap input, .input-group input, .field-row input, .input-with-icon input {
  flex: 1 1 auto; min-width: 0;
}
.input-icon-left, .input-icon-right {
  position: absolute !important;
  top: 0 !important; bottom: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  height: 100% !important;
  transform: none !important;
  z-index: 2;
}
.input-icon-left { left: 12px; }
.input-icon-right { right: 12px; }
.form-group label { display: block; margin-bottom: 6px; }
