/* ── Distributors tab ──────────────────────────────────────────────────────── */

.dist-view {
  padding: 20px 28px 60px;
  max-width: 1600px;
  margin: 0 auto;
}

/* Toolbar */
.dist-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
.dist-toolbar-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.dist-view-toggle {
  position: relative;
  display: inline-flex;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 3px;
  gap: 0;
}
/* Sliding active pill — animates between the two toggle buttons via data-view. */
.dist-view-toggle::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  background: #fff;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(15,23,42,.10);
  pointer-events: none;
  z-index: 0;
}
@media (prefers-reduced-motion: no-preference) {
  .dist-view-toggle::before {
    transition: transform 260ms cubic-bezier(0.4, 0, 0.2, 1);
  }
}
.dist-view-toggle[data-view="map"]::before {
  transform: translateX(100%);
}
.dist-toggle-btn {
  position: relative;
  z-index: 1;
  border: 0;
  background: transparent;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  flex: 1;
  text-align: center;
  transition: color .15s ease;
}
.dist-toggle-btn:hover  { color: #0f172a; }
.dist-toggle-btn.active { color: #0f172a; }

.dist-filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.dist-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: #334155;
  cursor: pointer;
  font-family: inherit;
}
.dist-chip:hover      { border-color: #cbd5e1; background: #f8fafc; }
.dist-chip.active-chip{ border-color: #258acb; color: #258acb; background: #eff6ff; }
.dist-chip .chip-caret{ color: #94a3b8; font-size: 10px; }
.dist-chip-toggle { cursor: pointer; }
.dist-chip-toggle input { margin: 0; }

.dist-toolbar-right { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.dist-search-wrap   { position: relative; }
.dist-search {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  width: 240px;
  font-family: inherit;
  background: #fff;
}
.dist-search:focus { outline: none; border-color: #258acb; box-shadow: 0 0 0 3px rgba(37,138,203,.12); }
.dist-icon-btn {
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 16px;
  cursor: pointer;
  color: #475569;
}
.dist-icon-btn:hover { background: #f8fafc; }

.dist-summary { color: #64748b; font-size: 13px; }

/* Chip popover — fixed positioning floats it above the table without stacking-context issues. */
.dist-chip-menu {
  position: fixed;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(15,23,42,.10);
  padding: 8px;
  z-index: var(--z-modal);
  max-height: 320px;
  overflow-y: auto;
  min-width: 200px;
  max-width: calc(100vw - 16px);
}
.dist-chip-menu label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.dist-chip-menu label:hover { background: #f1f5f9; }
.dist-chip-menu .menu-clear {
  display: block;
  border: 0;
  background: transparent;
  color: #258acb;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 8px;
  font-family: inherit;
}

/* Table */
.dist-table-wrap {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  /* Let wide tables scroll inside their own box rather than pushing the
     page sideways (or being clipped) on small screens. */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.dist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.dist-table thead th {
  text-align: left;
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.dist-table thead th .sort-arrow {
  color: #94a3b8;
  font-size: 10px;
  margin-left: 4px;
}
.dist-table thead th.sort-active { color: #0f172a; }
.dist-table thead th.sort-active .sort-arrow { color: #258acb; }
.dist-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.dist-table tbody tr { cursor: pointer; transition: background .08s; }
.dist-table tbody tr:hover { background: #f8fafc; }
.dist-table tbody tr.row-active td { box-shadow: inset 4px 0 0 #22c55e; }
.dist-table .col-secondary { color: #64748b; }
.dist-table .col-numeric   { text-align: right; font-variant-numeric: tabular-nums; }
.dist-table .badge-active {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  background: #dcfce7;
  color: #166534;
  border-radius: 999px;
  padding: 2px 8px;
}
.dist-table .badge-active::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #22c55e;
  border-radius: 50%;
}

.dist-empty { padding: 60px 20px; text-align: center; color: #94a3b8; }
.dist-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid #f1f5f9;
  font-size: 12.5px;
  color: #64748b;
  background: #fafbfc;
}
.dist-pagination button {
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  color: #334155;
}
.dist-pagination button:disabled { opacity: .4; cursor: not-allowed; }
.dist-pagination .pg-group { display: flex; gap: 6px; align-items: center; }

/* Map */
.dist-map-wrap {
  position: relative;
  height: calc(100vh - 240px);
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
}
.dist-map { width: 100%; height: 100%; }
.dist-map-legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(255,255,255,.94);
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: #475569;
  z-index: 500;
  pointer-events: none;
}
.dist-map-legend .legend-item { display: flex; align-items: center; gap: 6px; }
.dist-map-legend .legend-dot  { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dist-map-legend .legend-dot.legend-active   { background: #22c55e; }
.dist-map-legend .legend-dot.legend-inactive { background: #94a3b8; }
.dist-map-legend .legend-attribution { color: #94a3b8; font-size: 11px; }
.dist-map-status {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: #64748b;
  z-index: 500;
  box-shadow: 0 2px 6px rgba(15,23,42,.06);
}

/* Pin marker icons (Leaflet divIcon) */
.dist-pin {
  width: 22px;
  height: 30px;
  margin-left: -11px;
  margin-top: -30px;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(15,23,42,.35));
}
.dist-pin svg { width: 100%; height: 100%; display: block; }
.dist-pin.dist-pin-active   svg path { fill: #22c55e; }
.dist-pin.dist-pin-inactive svg path { fill: #94a3b8; }

.leaflet-popup-content { font-family: inherit; min-width: 220px; }
.leaflet-popup-content .pop-title  { font-weight: 700; font-size: 14px; margin-bottom: 4px; color: #0f172a; }
.leaflet-popup-content .pop-sub    { color: #64748b; font-size: 12px; margin-bottom: 8px; }
.leaflet-popup-content .pop-meta   { font-size: 12.5px; margin: 4px 0; }
.leaflet-popup-content .pop-meta strong { color: #475569; margin-right: 4px; }
.leaflet-popup-content .pop-contacts { margin-top: 6px; font-size: 12px; color: #334155; }
.leaflet-popup-content .pop-contacts ul { margin: 4px 0 0 0; padding-left: 16px; }
.leaflet-popup-content .pop-open {
  margin-top: 10px;
  background: #258acb;
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.leaflet-popup-content .pop-open:hover { background: #1e6fa3; }

/* Detail drawer */
.dist-detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 540px;
  max-width: 92vw;
  height: 100vh;
  background: #fff;
  box-shadow: -8px 0 32px rgba(15,23,42,.12);
  display: none;
  flex-direction: column;
  z-index: 1000;
}
.dist-detail-drawer.visible { display: flex; animation: drawerIn .22s ease-out; }
.dist-detail-drawer .drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
}
.dist-detail-drawer .drawer-title { font-weight: 700; font-size: 17px; color: #0f172a; }
.dist-detail-drawer .drawer-close {
  background: transparent;
  border: 0;
  font-size: 18px;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px 8px;
}
.dist-detail-drawer .drawer-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
  font-size: 13.5px;
}
.dist-detail-drawer .drawer-footer {
  padding: 14px 20px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: #fafbfc;
}

.dist-form-row { display: flex; gap: 12px; margin-bottom: 12px; }
.dist-form-row > div { flex: 1; }
.dist-form-row.row-3 > div { flex: 1; }
.dist-form-label {
  display: block;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 4px;
}
.dist-form-input, .dist-form-select, .dist-form-textarea {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: #0f172a;
  box-sizing: border-box;
}
.dist-form-input:read-only { background: #f8fafc; color: #475569; }
.dist-form-input:focus, .dist-form-select:focus, .dist-form-textarea:focus {
  outline: none;
  border-color: #258acb;
  box-shadow: 0 0 0 3px rgba(37,138,203,.12);
}
.dist-form-textarea { min-height: 60px; resize: vertical; }

.dist-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #475569;
  margin: 22px 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.dist-section-title button {
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #258acb;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.dist-section-title button:hover { background: #eff6ff; }

.dist-contact-row {
  border: 1px solid #f1f5f9;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fafbfc;
}
.dist-contact-row .contact-line { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.dist-contact-row .contact-name input { font-weight: 600; }
.dist-contact-row .contact-row-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}
.dist-contact-row .contact-source-tag {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #64748b;
}
.dist-contact-row .contact-source-tag.source-po     { color: #15803d; }
.dist-contact-row .contact-source-tag.source-csv    { color: #6b7280; }
.dist-contact-row .contact-source-tag.source-manual { color: #b45309; }
.dist-contact-delete {
  background: transparent;
  border: 0;
  color: #ef4444;
  font-size: 12px;
  cursor: pointer;
}

.dist-linked-po {
  border: 1px solid #f1f5f9;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 6px;
  font-size: 12.5px;
  display: flex;
  justify-content: space-between;
  background: #fff;
  cursor: pointer;
}
.dist-linked-po:hover { background: #f8fafc; }

/* Mobile */
@media (max-width: 720px) {
  .dist-view { padding: 14px 14px 60px; }
  .dist-toolbar-top { flex-direction: column; align-items: stretch; }
  .dist-toolbar-right { margin-left: 0; }
  .dist-search { width: 100%; }
  .dist-table th.col-hide-mobile,
  .dist-table td.col-hide-mobile { display: none; }
  .dist-detail-drawer { width: 100vw; }
  .dist-map-wrap { height: calc(100vh - 280px); }
}
