/* ============================================================
   PiqoGIZ Teams page — layered on slim5.css
   ============================================================ */

/* ---- Page layout ---- */
body { background: #f0f0ea }

/* Back-to-Field arrow in header */
.crew-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.28);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  text-decoration: none;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.crew-back-btn:active { background: rgba(255,255,255,0.35) }

.teams-wrap {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  overflow-x: hidden;
}

.teams-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

/* ---- Sticky topbar ---- */
.teams-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  background: #fff;
  border-bottom: 1px solid #eaeae0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.teams-topbar > div { flex: 1; min-width: 0 }

.teams-title {
  font-size: 17px;
  font-weight: 900;
  color: #1a2a1a;
}

.teams-sub {
  font-size: 12px;
  color: #999;
  margin-top: 3px;
  line-height: 1.4;
}

.teams-add {
  background: #2d5a2d;
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.teams-add:active { background: #1a3a1a }
.teams-add:disabled { opacity: 0.4; cursor: not-allowed }

/* ---- Role pill ---- */
.teams-role-pill {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #4a7c4e;
  background: #eef5ee;
  border-radius: 999px;
  padding: 5px 14px;
  margin: 12px 16px 0;
  align-self: flex-start;
}
.teams-role-pill:empty { display: none }

/* ---- Content sections ---- */
.teams-section {
  margin-top: 16px;
  background: #fff;
  border-top: 1px solid #eaeae0;
  border-bottom: 1px solid #eaeae0;
}

.teams-h {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #aaa;
  padding: 10px 16px 8px;
  border-bottom: 1px solid #f4f4ec;
}

.teams-empty {
  padding: 28px 16px;
  text-align: center;
  color: #bbb;
  font-size: 14px;
}

.teams-foot {
  padding: 8px 16px;
  font-size: 12px;
  color: #ccc;
}

/* Generic hint (used in invite list) */
.hint {
  padding: 14px 16px;
  font-size: 13px;
  color: #bbb;
  font-style: italic;
}

/* ---- Member card (override slim5's .card{display:flex}) ---- */
.card {
  display: block;
  padding: 14px 16px;
  background: #fff;
  border-bottom: 1px solid #f0f0e8;
  cursor: default;
  transition: none;
}

.cardTop {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #2d5a2d;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -0.5px;
  user-select: none;
}

.cardMid { flex: 1; min-width: 0 }

.cardName {
  font-size: 15px;
  font-weight: 800;
  color: #1a2a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ownerBadge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: #2d5a2d;
  color: #fff;
  border-radius: 999px;
  padding: 1px 7px;
  vertical-align: middle;
  margin-left: 6px;
}

.cardSub {
  font-size: 12px;
  color: #aaa;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cardActions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.btnIcon {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  color: #ccc;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
}
.btnIcon:hover { color: #c0392b; background: #fef0f0 }
.btnIcon:active { color: #c0392b; background: #fdd8d8 }
.btnIcon:disabled { opacity: 0.3; cursor: not-allowed; pointer-events: none }

/* ---- Role / permission grid ---- */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: 8px 12px;
  align-items: center;
  padding-bottom: 12px;
}

/* Every grid child must not overflow its cell */
.grid > * { min-width: 0 }

.lbl {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #aaa;
}

.sel {
  display: block;
  padding: 8px 10px;
  border: 1.5px solid #e8e8e0;
  border-radius: 10px;
  font-size: 13px;
  background: #fff;
  color: #1a2a1a;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.sel:focus { outline: none; border-color: #2d5a2d }
.sel:disabled { background: #f8f8f4; color: #bbb }

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  grid-column: 1 / -1;
}
.toggle input { width: 16px; height: 16px; cursor: pointer; flex-shrink: 0 }

/* ---- Quick preset chips per member ---- */
.chips {
  border-top: 1px solid #f4f4ec;
  padding: 10px 0 8px;
}

.chipsTitle {
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #bbb;
  margin-bottom: 8px;
}

.chipRow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border: 1.5px solid #c8e8a8;
  background: #f0f7f0;
  color: #2d5a2d;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip:active { background: #e0f0e0; transform: scale(0.97) }
.chip:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none }

/* ---- Save / action row ---- */
.row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn {
  flex: 1;
  padding: 11px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  border: 1.5px solid #c8e8a8;
  background: #f0f7f0;
  color: #2d5a2d;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { background: #e0f0e0 }
.btn:disabled { opacity: 0.4; cursor: not-allowed }

.btnGhost {
  background: #fff;
  color: #666;
  border-color: #e8e8e0;
}
.btnGhost:active:not(:disabled) { background: #f5f5f0 }

/* Per-card status line */
.status[data-role="status"] {
  font-size: 12px;
  min-height: 16px;
  margin-top: 8px;
  color: #4a7c4e;
  font-weight: 700;
}
.status[data-role="status"].err { color: #c0392b }

/* ---- Pending invites list ---- */
.inviteRow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0e8;
  background: #fff;
}

.inviteMain { flex: 1; min-width: 0 }

.inviteEmail {
  font-size: 14px;
  font-weight: 700;
  color: #1a2a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inviteMeta {
  font-size: 11px;
  color: #aaa;
  margin-top: 3px;
  line-height: 1.4;
}

.btnSmall {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid #c8e8a8;
  background: #f0f7f0;
  color: #2d5a2d;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.btnSmall:active { background: #e0f0e0 }

.btnDanger {
  border-color: #fcc;
  background: #fef0f0;
  color: #c0392b;
}
.btnDanger:active { background: #fdd8d8 }

/* ---- Invite sheet form ---- */
.teams-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.teams-label {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #888;
  margin-bottom: -4px;
}

.teams-input {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid #e8e8e0;
  border-radius: 12px;
  font-size: 15px;
  background: #fff;
  color: #1a2a1a;
}
.teams-input:focus { outline: none; border-color: #2d5a2d }
.teams-input::placeholder { color: #ccc }
.teams-input[readonly] { background: #f8f8f4; color: #555 }

.teams-select {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid #e8e8e0;
  border-radius: 12px;
  font-size: 15px;
  background: #fff;
  color: #1a2a1a;
  appearance: none;
  -webkit-appearance: none;
}
.teams-select:focus { outline: none; border-color: #2d5a2d }

.teams-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.teams-btn {
  flex: 1;
  padding: 13px 12px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  border: none;
  -webkit-tap-highlight-color: transparent;
}
.teams-btn.primary { background: #2d5a2d; color: #fff }
.teams-btn.primary:active { background: #1a3a1a }
.teams-btn.secondary { background: #f0f0ea; color: #555; border: 1.5px solid #e0e0d8 }
.teams-btn.secondary:active { background: #e8e8e0 }
.teams-btn:disabled { opacity: 0.4; cursor: not-allowed }

.teams-msg {
  font-size: 13px;
  min-height: 16px;
  color: #4a7c4e;
  font-weight: 700;
  text-align: center;
}
.teams-msg.err { color: #c0392b }

/* ---- Permission grid in invite sheet ---- */
#invitePermGrid { display: flex; flex-direction: column; gap: 8px }

.permRow {
  display: flex;
  align-items: center;
  gap: 10px;
}

.permLabel {
  flex: 1;
  font-size: 12px;
  color: #888;
  font-weight: 700;
}

.permRow .teams-select { flex: 1.2; width: auto }

/* ---- Advanced ABAC editor ---- */
.abac-wrap {
  margin-top: 12px;
  border: 1px solid #f0f0e8;
  border-radius: 12px;
  background: #fafaf7;
  padding: 10px 12px;
}
.abac-title {
  font-size: 11px;
  font-weight: 900;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}
.abac-help {
  font-size: 11px;
  color: #999;
  line-height: 1.4;
  margin-bottom: 10px;
}
.abac-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px }
.abac-tag {
  font-size: 11px;
  background: #eef5ee;
  color: #2d5a2d;
  border-radius: 999px;
  padding: 2px 8px;
}
