/*
  FieldBase Account Team Mobile Compact
  Version: 1.6.8.3.138

  Purpose:
  - Mobile-first compacting for Account/Billing Team Seats controls.
  - Keeps existing team/invite logic untouched.
  - Makes Pro-10, Pro-25, and Enterprise user lists easier to manage on phones.
*/

.account-team-card {
  overflow: hidden;
}

.account-team-mgmt-list {
  min-width: 0;
}

.account-team-mgmt-row,
.account-team-mgmt-main,
.account-team-mgmt-actions {
  min-width: 0;
}

.account-team-mgmt-main strong,
.account-team-mgmt-main span,
.account-team-mgmt-muted {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.account-team-mgmt-section .account-team-mgmt-list {
  max-height: 520px;
  overflow-y: auto;
  overscroll-behavior-y: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
}

.account-team-mgmt-section .account-team-mgmt-list::-webkit-scrollbar {
  width: 8px;
}

.account-team-mgmt-section .account-team-mgmt-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.34);
  border-radius: 999px;
}

.account-team-mgmt-row {
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.account-team-mgmt-row:hover {
  transform: translateY(-1px);
}

@media (max-width: 760px) {
  .account-team-card .account-section-head {
    gap: 10px;
  }

  .account-team-card .account-section-head p {
    font-size: 0.9rem;
    line-height: 1.45;
  }

  .account-team-mgmt {
    margin-top: 4px;
  }

  .account-team-mgmt-topline {
    align-items: stretch;
    gap: 12px;
    padding: 14px;
    border-radius: 18px;
  }

  .account-team-mgmt-topline h3 {
    font-size: 1rem;
  }

  .account-team-mgmt-topline p {
    font-size: 0.86rem;
    line-height: 1.4;
  }

  .account-team-mgmt-dev-pill,
  .account-team-mgmt-invite-btn {
    align-self: stretch;
    text-align: center;
  }

  .account-team-mgmt-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
  }

  .account-team-mgmt-summary-card {
    padding: 11px;
    border-radius: 15px;
  }

  .account-team-mgmt-summary-card span {
    font-size: 0.7rem;
    letter-spacing: 0.08em;
  }

  .account-team-mgmt-summary-card strong {
    font-size: 1.05rem;
    line-height: 1.15;
    overflow-wrap: anywhere;
  }

  .account-team-mgmt-summary-card small {
    font-size: 0.76rem;
    line-height: 1.35;
  }

  .account-team-mgmt-section {
    padding: 12px;
    border-radius: 18px;
  }

  .account-team-mgmt-section-head {
    flex-direction: row !important;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 4px 0 10px;
    backdrop-filter: blur(8px);
  }

  .account-team-mgmt-section-head h3 {
    font-size: 0.96rem;
    margin: 0;
  }

  .account-team-mgmt-section-head span {
    white-space: nowrap;
    font-size: 0.78rem;
  }

  .account-team-mgmt-section .account-team-mgmt-list {
    max-height: 360px;
    padding-right: 2px;
  }

  .account-team-mgmt-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "main status"
      "role role"
      "actions actions";
    gap: 8px;
    padding: 11px;
    border-radius: 16px;
  }

  .account-team-mgmt-row.invite {
    grid-template-areas:
      "main status"
      "role role"
      "actions actions";
  }

  .account-team-mgmt-main {
    grid-area: main;
    min-width: 0;
  }

  .account-team-mgmt-main strong {
    display: block;
    max-width: 100%;
    font-size: 0.92rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .account-team-mgmt-main span {
    display: block;
    max-width: 100%;
    font-size: 0.76rem;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .account-team-mgmt-pill {
    font-size: 0.72rem;
    line-height: 1;
    padding: 6px 8px;
    white-space: nowrap;
    max-width: 100%;
  }

  .account-team-mgmt-row > .account-team-mgmt-pill:first-of-type {
    grid-area: role;
    justify-self: start;
  }

  .account-team-mgmt-row > .account-team-mgmt-pill:nth-of-type(2) {
    grid-area: status;
    justify-self: end;
    align-self: start;
  }

  .account-team-mgmt-select-wrap {
    grid-area: role;
    width: 100% !important;
  }

  .account-team-mgmt-select-wrap select {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 34px;
    padding: 7px 9px;
    font-size: 0.82rem;
  }

  .account-team-mgmt-actions {
    grid-area: actions;
    display: flex !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    gap: 7px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }

  .account-team-mgmt-actions button {
    width: auto !important;
    min-width: max-content;
    min-height: 34px;
    padding: 7px 10px;
    border-radius: 10px;
    font-size: 0.78rem;
  }

  .account-team-mgmt-muted {
    font-size: 0.78rem;
  }

  .account-team-mgmt-alert,
  .account-team-mgmt-status {
    font-size: 0.86rem;
    line-height: 1.42;
    border-radius: 14px;
  }
}

@media (max-width: 430px) {
  .account-team-mgmt-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px;
  }

  .account-team-mgmt-section .account-team-mgmt-list {
    max-height: 330px;
  }

  .account-team-mgmt-main strong {
    font-size: 0.86rem;
  }

  .account-team-mgmt-main span {
    font-size: 0.72rem;
  }

  .account-team-mgmt-row {
    padding: 10px;
  }
}


/* Patch 1.6.8.3.136: prevent nested Team Seats lists from trapping page scroll. */
.account-team-mgmt-section .account-team-mgmt-list {
  touch-action: pan-y;
  scroll-behavior: auto;
}

@media (hover: hover) and (pointer: fine) {
  .account-team-mgmt-row:hover {
    transform: none;
  }
}

@media (max-width: 760px) {
  .account-team-mgmt-section .account-team-mgmt-list {
    max-height: min(52vh, 360px);
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .account-team-mgmt-actions {
    overscroll-behavior-x: contain;
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* FieldBase 1.6.8.3.137 - Enterprise Team Seats List Manager */
.account-team-enterprise-tools {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(120px, auto) minmax(120px, auto) auto;
  gap: 10px;
  align-items: center;
  margin: 4px 0 8px;
}

.account-team-enterprise-search,
.account-team-enterprise-filter {
  min-width: 0;
}

.account-team-enterprise-tools input,
.account-team-enterprise-tools select,
.account-team-load-more {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.55);
  color: var(--team-strong, #f8fafc);
  padding: 9px 11px;
  font-weight: 800;
  box-sizing: border-box;
}

.account-team-enterprise-tools input::placeholder {
  color: rgba(148, 163, 184, 0.8);
}

.account-team-load-more {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.34);
  cursor: pointer;
  white-space: nowrap;
}

.account-team-load-more[hidden] {
  display: none !important;
}

.account-team-mgmt-row[hidden] {
  display: none !important;
}

.account-team-mgmt-row {
  cursor: pointer;
}

.account-team-mgmt-row:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.5);
  outline-offset: 2px;
}

body.light-mode .account-team-enterprise-tools input,
body.light-mode .account-team-enterprise-tools select,
body.light-theme .account-team-enterprise-tools input,
body.light-theme .account-team-enterprise-tools select,
html.light .account-team-enterprise-tools input,
html.light .account-team-enterprise-tools select,
html.fb-light-preload .account-team-enterprise-tools input,
html.fb-light-preload .account-team-enterprise-tools select {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(148, 163, 184, 0.42);
}

body.light-mode .account-team-load-more,
body.light-theme .account-team-load-more,
html.light .account-team-load-more,
html.fb-light-preload .account-team-load-more {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.28);
}

@media (max-width: 760px) {
  .account-team-enterprise-tools {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .account-team-enterprise-search {
    grid-column: 1 / -1;
  }

  .account-team-load-more {
    grid-column: 1 / -1;
  }

  .account-team-mgmt-row .account-team-mgmt-actions {
    display: none;
  }

  .account-team-mgmt-row.is-expanded .account-team-mgmt-actions,
  .account-team-mgmt-row:focus-within .account-team-mgmt-actions {
    display: flex;
  }

  .account-team-mgmt-row:not(.is-expanded)::after {
    content: "Tap to manage";
    grid-column: 1 / -1;
    color: rgba(148, 163, 184, 0.9);
    font-size: 0.72rem;
    font-weight: 850;
  }

  .account-team-mgmt-row.invite:not(.is-expanded)::after {
    content: "Tap for invite actions";
  }
}


/* Patch 1.6.8.3.138 - true compact rows on mobile.
   Collapsed rows hide management controls until the selected row is expanded. */
@media (max-width: 760px) {
  .account-team-mgmt-row[data-team-list-row] {
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-areas:
      "main manage"
      "meta manage" !important;
    align-items: center;
    min-height: 58px;
    padding: 10px 11px !important;
    cursor: pointer;
  }

  .account-team-mgmt-row[data-team-list-row]::before {
    grid-area: meta;
    content: attr(data-team-role) " • " attr(data-team-status);
    display: inline-flex;
    width: fit-content;
    max-width: 100%;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    line-height: 1;
    font-weight: 800;
    letter-spacing: 0.055em;
    text-transform: uppercase;
    color: var(--fieldbase-text, #e5eef9);
    background: rgba(148, 163, 184, 0.16);
    border: 1px solid rgba(148, 163, 184, 0.24);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .account-team-mgmt-row[data-team-list-row]::after {
    grid-area: manage;
    content: "Tap to manage";
    align-self: center;
    justify-self: end;
    padding: 6px 8px;
    border-radius: 999px;
    font-size: 0.68rem;
    line-height: 1;
    font-weight: 800;
    color: #93c5fd;
    background: rgba(37, 99, 235, 0.12);
    border: 1px solid rgba(96, 165, 250, 0.28);
    white-space: nowrap;
  }

  .account-team-mgmt-row[data-team-list-row]:not(.is-expanded) .account-team-mgmt-role,
  .account-team-mgmt-row[data-team-list-row]:not(.is-expanded) .account-team-mgmt-select-wrap,
  .account-team-mgmt-row[data-team-list-row]:not(.is-expanded) .account-team-mgmt-actions,
  .account-team-mgmt-row[data-team-list-row]:not(.is-expanded) > .account-team-mgmt-pill,
  .account-team-mgmt-row[data-team-list-row]:not(.is-expanded) > .account-team-mgmt-muted {
    display: none !important;
  }

  .account-team-mgmt-row[data-team-list-row].is-expanded {
    grid-template-areas:
      "main status"
      "role role"
      "actions actions" !important;
    align-items: start;
    min-height: 0;
    padding: 12px !important;
  }

  .account-team-mgmt-row[data-team-list-row].is-expanded::before,
  .account-team-mgmt-row[data-team-list-row].is-expanded::after {
    display: none !important;
    content: none !important;
  }

  .account-team-mgmt-row[data-team-list-row].is-expanded .account-team-mgmt-role,
  .account-team-mgmt-row[data-team-list-row].is-expanded .account-team-mgmt-actions,
  .account-team-mgmt-row[data-team-list-row].is-expanded > .account-team-mgmt-pill,
  .account-team-mgmt-row[data-team-list-row].is-expanded > .account-team-mgmt-muted {
    display: flex !important;
  }

  .account-team-mgmt-row[data-team-list-row].is-expanded .account-team-mgmt-select-wrap {
    display: block !important;
  }

  .account-team-mgmt-row[data-team-list-row].is-expanded .account-team-mgmt-actions {
    flex-wrap: wrap !important;
    overflow-x: visible;
    padding-top: 4px;
  }

  .account-team-mgmt-row[data-team-list-row].is-expanded .account-team-mgmt-actions button,
  .account-team-mgmt-row[data-team-list-row].is-expanded .account-team-mgmt-select-wrap select {
    min-height: 38px;
  }

  .account-team-mgmt-main strong,
  .account-team-mgmt-main span {
    padding-right: 4px;
  }
}
