/* ============================================================
   LIBRARY-TEAM — Team-Manager Inline-Panel
   Sections, Mitglieder-Rows, Playbook-Rows, Avatar, Toggle-Switch.
   Status-Pill und Responsive in library-team-status.css.
   ============================================================ */

.lib-team-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.lib-team-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background:
    radial-gradient(circle at top right, rgba(249,115,22,.14), transparent 32%),
    linear-gradient(180deg, var(--bg-surface), var(--bg-elevated));
}

.lib-team-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 8px;
}

.lib-team-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.05;
  color: var(--text-primary);
}

.lib-team-subtitle {
  margin: 10px 0 0;
  max-width: 700px;
  color: var(--text-secondary);
  font-size: 14px;
}

.lib-team-role-chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: center;
}

.lib-team-role-chip {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-base);
  font-size: 12px;
  line-height: 1.4;
  max-width: 340px;
}

.lib-team-role-icon {
  flex-shrink: 0;
  margin-top: 1px;
  font-size: 13px;
}

.lib-team-role-chip.is-editor,
.lib-team-role-chip.is-viewer {
  border-color: rgba(249,115,22,.35);
}
.lib-team-role-chip.is-editor .lib-team-role-icon,
.lib-team-role-chip.is-editor strong,
.lib-team-role-chip.is-viewer .lib-team-role-icon,
.lib-team-role-chip.is-viewer strong {
  color: #f97316;
}

.lib-team-inline-root {
  min-height: 360px;
  position: relative;
}
.lib-team-loading,
.lib-team-empty-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg-surface);
  color: var(--text-muted);
}

.lib-team-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.lib-team-overview-card {
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--border);
  border-top-width: 2px;
  background: var(--bg-surface);
  transition: border-color .15s, transform .15s, box-shadow .15s;
  cursor: default;
}
.lib-team-overview-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
}
.lib-team-overview-card.accent-orange  { border-top-color: var(--brand, #f97316); }
.lib-team-overview-card.accent-green   { border-top-color: #22c55e; }
.lib-team-overview-card.accent-blue    { border-top-color: #3b82f6; }
.lib-team-overview-card.accent-neutral { border-top-color: var(--text-muted); }

.lib-team-overview-value {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.lib-team-overview-label {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.lib-team-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 14px;
  align-items: stretch;
}

.lib-team-section-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  box-shadow: 0 4px 18px rgba(0,0,0,.06);
  transition: border-color .18s, box-shadow .18s;
}
.lib-team-section-card:hover {
  border-color: var(--brand-glow);
  box-shadow: 0 8px 28px rgba(0,0,0,.14);
}

.lib-team-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.lib-team-section-head.compact { margin-bottom: 0; }
.lib-team-studio-link { flex: 0 0 auto; color: var(--brand); font-weight: 700; white-space: nowrap; }

.lib-team-section-title {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 800;
  color: var(--text-primary);
}

.lib-team-section-subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.lib-team-topbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.lib-team-topbar .input-text {
  min-width: 170px;
  flex: 1 1 170px;
}

.lib-team-capacity-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.lib-team-capacity-badge.is-full {
  color: var(--danger);
  border-color: rgba(239,68,68,.35);
  background: rgba(239,68,68,.08);
}

.lib-team-brand-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}

.lib-team-avatar-wrap { flex-shrink: 0; }

.lib-team-avatar-img,
.lib-team-avatar-fallback {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  border: 1px solid var(--border);
}

.lib-team-avatar-img { object-fit: cover; display: block; }

.lib-team-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand), #fb923c);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
}

.lib-team-brand-copy {
  flex: 1;
  min-width: 0;
}

.lib-team-brand-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.lib-team-brand-hint,
.lib-team-muted-note {
  font-size: 12px;
  color: var(--text-muted);
}

.lib-team-info-strip {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.5;
}

.lib-team-add-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 8px;
  flex-shrink: 0;
}

.lib-team-scroll-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  padding-right: 4px;
  /* scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.lib-team-member-row,
.lib-team-pb-row {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--bg-base);
  padding: 12px;
  transition: border-color .15s, background .15s;
}
.lib-team-member-row:hover,
.lib-team-pb-row:hover {
  border-color: var(--brand-glow);
  background: var(--bg-surface);
}

.lib-team-member-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  gap: 8px;
  align-items: center;
}

.lib-team-member-main { min-width: 0; }

.lib-team-member-name {
  width: 100%;
  margin-bottom: 4px;
}

.lib-team-member-email {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lib-team-member-role-select,
.lib-team-pb-select {
  width: auto;
  min-width: 124px;
}

.lib-team-member-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

.lib-team-member-pill.is-active {
  color: #16a34a;
  border-color: rgba(74,222,128,.35);
}

.lib-team-member-pill.is-pending {
  color: #f59e0b;
  border-color: rgba(245,158,11,.35);
}

.lib-team-mini-btn {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.lib-team-mini-btn.danger { color: var(--danger); }

/* Shared-Playbook (Trainer-Sicht: vom Team-Owner geteilt) */
.lib-team-pb-row.is-shared {
  background: linear-gradient(180deg, rgba(99,102,241,.05), transparent), var(--bg-base);
  border-color: rgba(99,102,241,.28);
}
.lib-team-pb-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(99,102,241,.14);
  color: #818cf8;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  vertical-align: middle;
}

.lib-team-pb-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.lib-team-pb-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.lib-team-pb-meta {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.lib-team-pb-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Remove-Button (× neben zugeordnetem Playbook) ----------------- */
.lib-team-pb-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.lib-team-pb-remove:hover {
  background: rgba(239,68,68,.12);
  border-color: rgba(239,68,68,.4);
  color: #f87171;
}

/* "Playbook hinzufügen"-Button + Inline-Picker ------------------ */
.lib-team-pb-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.lib-team-pb-add-btn svg { transition: transform .2s; }
.lib-team-pb-add-btn.is-open svg { transform: rotate(45deg); }

.lib-team-pb-picker {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 4px 0 14px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-base);
  animation: libTeamPickerIn .22s cubic-bezier(.2,.85,.25,1);
  max-height: 260px;
  overflow: auto;
}
.lib-team-pb-picker.hidden { display: none; }

.lib-team-pb-pick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .12s;
  text-align: left;
}
.lib-team-pb-pick-row:hover {
  border-color: var(--brand);
  background: var(--brand-subtle);
}
.lib-team-pb-pick-row:active { transform: scale(.99); }

.lib-team-pb-pick-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lib-team-pb-pick-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--brand);
  font-weight: 700;
}

@keyframes libTeamPickerIn { from { opacity: 0; transform: translateY(-4px); max-height: 0; } to { opacity: 1; transform: translateY(0); max-height: 260px; } }

/* Toggle Switch ------------------------------------------------- */
.lib-tm-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex-shrink: 0;
}
.lib-tm-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.lib-tm-switch-track {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: background .2s, border-color .2s;
  position: relative;
  flex-shrink: 0;
}
.lib-tm-switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform .2s, background .2s;
}
.lib-tm-switch input:checked ~ .lib-tm-switch-track {
  background: var(--brand);
  border-color: var(--brand);
}
.lib-tm-switch input:checked ~ .lib-tm-switch-track::after {
  transform: translateX(16px);
  background: #fff;
}
.lib-tm-switch input:disabled ~ .lib-tm-switch-track {
  opacity: .4;
  cursor: not-allowed;
}

/* lib-select-sm — kompakter Stil für Selects in engen Rows ---- */
.lib-select-sm {
  height: 36px;
  min-width: auto;
  padding: 0 32px 0 10px;
  font-size: 13px;
  background-position: right 10px center;
}

/* (Busy-Bar entfernt — durch optimistische UI nicht mehr nötig)
   Falls noch alte Markup-Reste irgendwo gerendert würden, blenden wir sie aus.        */
.lib-team-busy-bar { display: none !important; }

.lib-team-player-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.lib-team-player-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elevated);
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.lib-team-player-chip:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-subtle);
  color: var(--brand);
}
.lib-team-player-chip input {
  accent-color: var(--brand);
  cursor: pointer;
}

/* Team-Manager (Owner) read-only Zeile in der Mitgliederliste */
.lib-team-member-row--owner { background: var(--brand-subtle); border: 1px solid var(--brand); }
.lib-team-member-owner-name { font-weight: 700; color: var(--text-primary); }
.lib-team-member-pill.is-owner { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Animierter Lade-Indikator (Team-Manager) */
.tm-loading { display: flex; align-items: center; justify-content: center; padding: 60px 20px; }
.tm-spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--brand);
  animation: tm-spin .7s linear infinite;
}
@keyframes tm-spin { to { transform: rotate(360deg); } }
