/* ============================================================
   Teams — named groups you can share a page with in one click.
   Scoped to .team-* (modal) and .teams-sb* (sidebar list).
   Uses css/style.css design tokens (light + dark) with fallbacks.
   The sidebar list is mounted inside #sidebar, which re-scopes the
   text/bg vars to a light-on-dark rail — so it relies only on those
   inherited vars, never hardcoded light/dark colors.
   ============================================================ */

/* ------------------------------ shared avatar ------------------------------ */
.team-avatar {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font, sans-serif);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  user-select: none;
}

/* ================================ modal ================================ */
.team-overlay {
  position: fixed;
  inset: 0;
  z-index: 460;
  background: rgba(8, 9, 22, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 20px 20px;
}
.team-modal {
  width: 440px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  max-height: 76vh;
  background: var(--bg-modal, #fff);
  color: var(--text, #1f2335);
  border: 1px solid var(--border, #e7e8f1);
  border-radius: var(--radius-card, 10px);
  box-shadow: var(--shadow-pane, 0 10px 40px rgba(8, 9, 22, 0.35));
  overflow: hidden;
  animation: team-in 0.13s ease;
}
@keyframes team-in { from { opacity: 0; transform: translateY(-6px); } }

.team-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px 12px 18px;
  border-bottom: 1px solid var(--border, #e7e8f1);
}
.team-title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display, sans-serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.1px;
}
.team-x {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-light, #676d89);
  transition: background 0.12s, color 0.12s;
}
.team-x:hover { background: var(--bg-hover, rgba(35, 39, 74, 0.055)); color: var(--text, #1f2335); }

.team-body {
  padding: 16px 18px 8px;
  overflow-y: auto;
}

.team-field-label,
.team-section-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-faint, #989db6);
  margin: 0 0 8px;
}
.team-section-label { margin: 18px 0 10px; }

.team-name-input,
.team-email-input {
  width: 100%;
  min-width: 0;
  padding: 9px 11px;
  font-size: 14px;
  font-family: var(--font, sans-serif);
  color: var(--text, #1f2335);
  background: var(--bg-input, #fff);
  border: 1px solid var(--border, #e7e8f1);
  border-radius: var(--radius-ctl, 8px);
  outline: none;
  transition: border-color 0.12s;
}
.team-name-input::placeholder,
.team-email-input::placeholder { color: var(--text-placeholder, rgba(31, 35, 53, 0.34)); }
.team-name-input:focus,
.team-email-input:focus { border-color: var(--accent, #5b5bd6); }

.team-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.team-email-input { flex: 1; }

/* ---- members list ---- */
.team-members-list {
  margin-top: 10px;
}
.team-member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.team-member + .team-member { border-top: 1px solid var(--border, #e7e8f1); }
.team-member-info { flex: 1; min-width: 0; }
.team-member-name {
  font-size: 13.5px;
  color: var(--text, #1f2335);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.team-member-email {
  font-size: 12px;
  color: var(--text-faint, #989db6);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.team-member-role {
  flex: 0 0 auto;
  padding: 6px 8px;
  font-size: 12.5px;
  font-family: var(--font, sans-serif);
  color: var(--text, #1f2335);
  background: var(--bg-input, #fff);
  border: 1px solid var(--border, #e7e8f1);
  border-radius: var(--radius-ctl, 8px);
  outline: none;
  cursor: pointer;
  transition: border-color 0.12s;
}
.team-member-role:focus { border-color: var(--accent, #5b5bd6); }
.team-member-x {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-light, #676d89);
  transition: background 0.12s, color 0.12s;
}
.team-member-x:hover { background: var(--bg-hover, rgba(35, 39, 74, 0.055)); color: var(--danger, #e5534b); }

.team-owner-tag {
  flex: 0 0 auto;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--text-light, #676d89);
  background: var(--bg-hover, rgba(35, 39, 74, 0.055));
}

/* ---- footer ---- */
.team-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border, #e7e8f1);
}
.team-foot-spacer { flex: 1; }
.team-btn {
  font-family: var(--font, sans-serif);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-ctl, 8px);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.12s, color 0.12s, opacity 0.12s;
}
.team-btn:disabled { opacity: 0.55; cursor: default; }
.team-btn-primary { background: var(--accent, #5b5bd6); color: #fff; }
.team-btn-primary:hover:not(:disabled) { background: var(--accent-hover, #4a4ac8); }
.team-btn-ghost { background: transparent; color: var(--text-light, #676d89); }
.team-btn-ghost:hover { background: var(--bg-hover, rgba(35, 39, 74, 0.055)); color: var(--text, #1f2335); }
.team-btn-danger { background: transparent; color: var(--danger, #d4453f); }
.team-btn-danger:hover:not(:disabled) { background: var(--danger-bg, rgba(212, 69, 63, 0.1)); }
.team-btn-danger.confirm { background: var(--danger, #d4453f); color: #fff; }
.team-add-btn {
  background: var(--bg-hover, rgba(35, 39, 74, 0.055));
  color: var(--text, #1f2335);
}
.team-add-btn:hover:not(:disabled) { background: var(--bg-active, rgba(35, 39, 74, 0.1)); }

/* ============================== sidebar ============================== */
/* Inherits #sidebar's re-scoped vars (light-on-dark). */
.teams-sb { display: flex; flex-direction: column; gap: 1px; }

.teams-sb-empty {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-faint);
  padding: 3px 8px 6px;
}

.teams-sb-row {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: 7px;
  transition: background 0.12s;
}
.teams-sb-row:hover { background: var(--bg-hover); }

.teams-sb-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 6px 5px 8px;
  text-align: left;
  color: var(--text-light);
  border-radius: 7px;
  transition: color 0.12s;
}
.teams-sb-row:hover .teams-sb-main { color: var(--text); }

.teams-sb-avatar {
  width: 22px;
  height: 22px;
  font-size: 10px;
}
.teams-sb-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.teams-sb-name {
  font-size: 13.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.teams-sb-count {
  font-size: 11px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.teams-sb-actions {
  display: none;
  align-items: center;
  gap: 1px;
  padding-right: 4px;
}
.teams-sb-row:hover .teams-sb-actions { display: flex; }
.teams-sb-share,
.teams-sb-edit {
  width: 24px;
  height: 24px;
  font-size: 13px;
}

.teams-sb-new {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 5px 8px;
  margin-top: 2px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-faint);
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.teams-sb-new:hover { background: var(--bg-hover); color: var(--text); }
.teams-sb-new-ic {
  width: 22px;
  text-align: center;
  font-size: 14px;
  flex-shrink: 0;
}

/* ------------------------------ responsive ------------------------------ */
@media (max-width: 720px) {
  .team-overlay { padding: 8vh 14px 14px; }
  .team-modal { max-height: 84vh; }
}

/* ------------------------------ reduced motion ------------------------------ */
@media (prefers-reduced-motion: reduce) {
  .team-modal { animation: none; }
  .team-x,
  .team-member-x,
  .team-btn,
  .team-name-input,
  .team-email-input,
  .team-member-role,
  .teams-sb-row,
  .teams-sb-main,
  .teams-sb-new { transition: none; }
}

/* ------------------------------ shared pages (edit mode) ------------------------------ */
.team-pages-list { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.team-pages-empty {
  font-size: 12.5px;
  color: var(--text-faint, #9b9a97);
  padding: 6px 2px;
  line-height: 1.4;
}
.team-page-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 6px;
  border-radius: 8px;
}
.team-page-row:hover { background: var(--bg-hover); }
.team-page-ic { font-size: 15px; line-height: 1; flex: 0 0 auto; }
.team-page-title {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.team-page-x {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
}
.team-page-x:hover { background: var(--bg-hover); color: var(--danger); }
