/* ChatFox profiles screen cleanup */

.top-bar {
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 18px !important;
  min-width: 0 !important;
  padding: 11px 16px !important;
  min-height: 58px !important;
  border-bottom: 1px solid #252a33 !important;
  background: #151820 !important;
}

.top-bar-left {
  flex: 0 0 auto !important;
  min-width: max-content !important;
}

/* Actions start from the left, immediately after the folder title. */
.top-bar-right {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  flex-wrap: nowrap !important;
  gap: 10px !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
  margin-left: 0 !important;
  padding-right: 168px !important; /* reserve space for fixed "Сменить раздел" */
  overflow: visible !important;
}

.top-bar-right > * {
  flex: 0 0 auto !important;
}

.top-bar-right .action-btn,
#mpc-open-btn,
#mpr-open-btn {
  height: 36px !important;
  min-height: 36px !important;
  padding: 7px 14px !important;
  font-size: 12.5px !important;
  line-height: 1 !important;
  margin-right: 0 !important;
  border-radius: 8px !important;
  box-shadow: none !important;
}

.top-bar-right .action-btn svg,
#mpc-open-btn svg,
#mpr-open-btn svg {
  width: 14px !important;
  height: 14px !important;
}

/* Search occupies the free space on the right, but never under the hub switch. */
.top-bar-right .search-box {
  margin-left: auto !important;
  min-width: 160px !important;
  width: 185px !important;
  max-width: 185px !important;
  height: 36px !important;
  flex: 0 0 185px !important;
}

/* Hub switch stays on the far right and no longer overlaps search. */
#chatfox-switch-app {
  top: 11px !important;
  right: 12px !important;
  height: 36px !important;
  padding: 7px 12px !important;
  box-sizing: border-box !important;
  z-index: 9990 !important;
}

/* Keep only the bulk actions actually used in this workflow. */
[data-testid="mass-launch-btn"],
[data-testid="mass-stop-btn"] {
  display: none !important;
}

/* When profiles are selected, hide only actions the user asked to remove. */
body:has([data-testid="mass-move-btn"]) [data-testid="create-profile-btn"],
body:has([data-testid="mass-move-btn"]) [data-testid="quick-profile-btn"] {
  display: none !important;
}

/* Keep folder title readable. */
.folder-title {
  white-space: nowrap !important;
}

/* Table/header span the full content width with no side gaps. */
.content-area {
  padding: 0 0 16px !important;
}

.profile-table {
  width: 100% !important;
  margin: 0 !important;
  border-collapse: collapse !important;
}

/* Entire table header row is white from edge to edge. */
.profile-table thead,
.profile-table thead tr,
.profile-table thead th {
  background: #ffffff !important;
}

.profile-table thead th {
  color: #111827 !important;
  font-size: 11.5px !important;
  font-weight: 700 !important;
  padding: 6px 10px !important;
  height: 30px !important;
  line-height: 18px !important;
  top: 0 !important;
  vertical-align: middle !important;
  border-top: 0 !important;
  border-bottom: 1px solid #d7dbe1 !important;
}

/* Keep comfortable inset for the first/last header cells. */
.profile-table thead th:first-child {
  padding-left: 22px !important;
}
.profile-table thead th:last-child {
  padding-right: 22px !important;
}

/* Header checkbox remains visible on white background. */
.profile-table thead .custom-checkbox {
  border-color: #6b7280 !important;
  background: #ffffff !important;
}

/* Hide per-profile Cashinout button. */
[data-testid^="support-btn-"] {
  display: none !important;
}

/* Hide per-profile Dolphin Scenario button. */
[data-testid^="dolphin-scenario-btn-"] {
  display: none !important;
}

/* Proper visual spacing between toolbar actions. */
#mpr-open-btn,
#mpc-open-btn {
  margin-right: 10px !important;
}

.top-bar-right > a {
  margin-right: 10px !important;
}

.top-bar-right > .action-btn,
.top-bar-right > button {
  margin-right: 10px !important;
}

/* Do not add extra space after search/utility controls. */
.top-bar-right .search-box,
.top-bar-right [data-testid="refresh-btn"],
.top-bar-right [data-testid="filter-btn"] {
  margin-right: 0 !important;
}


/* Compact profile table: reserve real space for quick-action icons and
   reclaim the oversized empty area from the Name column. */
@media (min-width: 1200px) {
  .profile-table {
    table-layout: fixed !important;
  }

  .profile-table th:nth-child(1),
  .profile-table td:nth-child(1) {
    width: 52px !important;
  }

  .profile-table th:nth-child(2),
  .profile-table td:nth-child(2) {
    width: 168px !important;
    min-width: 168px !important;
    max-width: 168px !important;
  }

  .profile-table th:nth-child(3),
  .profile-table td:nth-child(3) {
    width: 320px !important;
    max-width: 320px !important;
  }

  .profile-table th:nth-child(4),
  .profile-table td:nth-child(4) {
    width: 112px !important;
  }

  .profile-table th:nth-child(5),
  .profile-table td:nth-child(5) {
    width: 180px !important;
  }

  .profile-table th:nth-child(6),
  .profile-table td:nth-child(6) {
    width: 150px !important;
  }

  .profile-table th:nth-child(8),
  .profile-table td:nth-child(8) {
    width: 52px !important;
  }

  /* Actions must never shrink or get clipped. */
  .profile-table td:nth-child(2) {
    overflow: visible !important;
    text-overflow: clip !important;
    padding-left: 8px !important;
    padding-right: 6px !important;
  }

  .profile-table td:nth-child(2) > div {
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 4px !important;
    min-width: 154px !important;
  }

  .profile-table td:nth-child(2) button,
  .profile-table td:nth-child(2) a,
  .profile-table td:nth-child(2) .ck-up-wrap,
  .profile-table td:nth-child(2) .ck-up-btn,
  .profile-table td:nth-child(2) .ck-dl-btn {
    flex: 0 0 24px !important;
    width: 24px !important;
    min-width: 24px !important;
    max-width: 24px !important;
    height: 24px !important;
    min-height: 24px !important;
    max-height: 24px !important;
    padding: 0 !important;
  }

  /* Name keeps only useful space; menu icon stays visible. */
  .profile-table td:nth-child(3) {
    overflow: hidden !important;
  }
  .profile-table td:nth-child(3) > div {
    width: 100% !important;
    min-width: 0 !important;
  }
  .profile-table td:nth-child(3) [data-testid^="menu-btn-"] {
    flex: 0 0 24px !important;
    width: 24px !important;
    height: 24px !important;
  }
}


/* Move only the platform/web icon away from the profile number.
   transform does not affect the number or any other column geometry. */
.profile-table td:nth-child(3) > div > svg:first-child {
  transform: translateX(-5px) !important;
}


/* Reserve enough room for the maximum action set (running profile adds
   Stop + View). Keep the rest of the table aligned by taking the same
   width only from the Name column. */
@media (min-width: 1200px) {
  .profile-table th:nth-child(2),
  .profile-table td:nth-child(2) {
    width: 192px !important;
    min-width: 192px !important;
    max-width: 192px !important;
  }

  .profile-table th:nth-child(3),
  .profile-table td:nth-child(3) {
    width: 296px !important;
    max-width: 296px !important;
  }

  .profile-table td:nth-child(2) > div {
    min-width: 178px !important;
  }

  /* Web/platform icon stays in its natural place once enough action space
     is reserved. */
  .profile-table td:nth-child(3) > div > svg:first-child {
    transform: none !important;
  }
}


/* Center the profile name block inside the Name column without moving
   any neighboring columns. Keep the row menu pinned to the right edge. */
@media (min-width: 1200px) {
  .profile-table th:nth-child(3) {
    text-align: center !important;
  }

  .profile-table td:nth-child(3) {
    position: relative !important;
  }

  .profile-table td:nth-child(3) > div {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    padding-right: 30px !important;
    padding-left: 30px !important;
  }

  .profile-table td:nth-child(3) [data-testid^="menu-btn-"] {
    position: absolute !important;
    right: 2px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    margin-left: 0 !important;
  }
}


/* Keep a safe gap between the last quick-action icon and the movable/table
   boundary without shifting any columns to the right. */
@media (min-width: 1200px) {
  .profile-table td:nth-child(2) {
    padding-right: 14px !important;
  }

  .profile-table td:nth-child(2) > div {
    padding-right: 8px !important;
    box-sizing: border-box !important;
  }
}
