/* ==========================================================================
   HAVE A SEAT — Component library
   ========================================================================== */

/* ---- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  font-family: var(--font-body); font-weight: 600; font-size: var(--fs-sm);
  line-height: 1; padding: 0.72em 1.2em; border-radius: var(--r-pill);
  border: 1px solid transparent; white-space: nowrap; cursor: pointer;
  transition: transform var(--t-fast) var(--ease-out),
              box-shadow var(--t-med) var(--ease-out),
              background var(--t-fast) var(--ease-out), border-color var(--t-fast);
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn svg { width: 1.05em; height: 1.05em; }
.btn:disabled, .btn[disabled] { opacity: 0.4; cursor: not-allowed; box-shadow: none; pointer-events: none; }

.btn-primary { background: var(--seat-accent); color: #fff; box-shadow: var(--sh-accent); }
.btn-primary:hover { background: var(--seat-accent-deep); transform: translateY(-1px); box-shadow: 0 14px 32px rgba(0,0,0,0.18); }

.btn-ink { background: var(--c-ink); color: var(--c-cream); }
.btn-ink:hover { background: #372c22; transform: translateY(-1px); box-shadow: var(--sh-md); }

.btn-ghost { background: var(--c-paper); color: var(--c-ink); border-color: var(--c-line-strong); box-shadow: var(--sh-xs); }
.btn-ghost:hover { border-color: var(--seat-accent); color: var(--seat-accent-deep); transform: translateY(-1px); box-shadow: var(--sh-sm); }

.btn-soft { background: var(--seat-accent-soft); color: var(--seat-accent-deep); }
.btn-soft:hover { background: var(--seat-accent-wash); }

.btn-quiet { background: transparent; color: var(--c-ink-soft); }
.btn-quiet:hover { background: var(--c-cream-deep); color: var(--c-ink); }

.btn-sm { padding: 0.5em 0.9em; font-size: var(--fs-xs); }
.btn-lg { padding: 0.9em 1.7em; font-size: var(--fs-base); }
.btn-block { width: 100%; }
.btn-icon { padding: 0.55em; border-radius: var(--r-pill); aspect-ratio: 1; }

/* ---- Chips / tags / badges --------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 0.4em;
  font-size: var(--fs-2xs); font-weight: 600; line-height: 1;
  padding: 0.5em 0.75em; border-radius: var(--r-pill);
  background: var(--c-cream-deep); color: var(--c-ink-soft);
  border: 1px solid var(--c-line);
}
.chip-accent { background: var(--seat-accent-soft); color: var(--seat-accent-deep); border-color: transparent; }
.chip-green { background: var(--c-green-soft); color: var(--c-green-deep); border-color: transparent; }
.chip-commons { background: var(--c-commons-soft); color: var(--c-commons-deep); border-color: transparent; }
.chip-heart { background: var(--c-heart-soft); color: var(--c-heart); border-color: transparent; }
.chip-gold { background: var(--c-gold-soft); color: var(--c-honey-deep); border-color: transparent; }
.chip-maroon { background: var(--c-maroon-soft); color: var(--c-maroon); border-color: transparent; }
.chip-clay { background: var(--c-clay-soft); color: var(--c-clay-deep); border-color: transparent; }
.chip-honey { background: var(--c-honey-soft); color: var(--c-honey-deep); border-color: transparent; }
.chip-sage { background: var(--c-sage-soft); color: var(--c-sage-deep); border-color: transparent; }
.chip-plum { background: var(--c-plum-soft); color: var(--c-plum); border-color: transparent; }
.chip-teal { background: var(--c-teal-soft); color: var(--c-teal); border-color: transparent; }
.chip-outline { background: transparent; }
.chip button { display: inline-flex; opacity: 0.6; }
.chip button:hover { opacity: 1; }

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.35em; height: 1.35em; padding: 0 0.4em; border-radius: var(--r-pill);
  font-size: var(--fs-3xs); font-weight: 700; background: var(--c-clay); color: #fff;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c-sage); display: inline-block; }
.dot-live { background: var(--c-clay); box-shadow: 0 0 0 0 rgba(193,95,60,0.5); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(193,95,60,0); } 100% { box-shadow: 0 0 0 0 rgba(193,95,60,0); } }

/* ---- Cards ------------------------------------------------------------- */
.card {
  background: var(--c-paper); border: 1px solid var(--c-line);
  border-radius: var(--r-lg); box-shadow: var(--sh-sm);
  transition: transform var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out), border-color var(--t-med);
}
.card-pad { padding: var(--s-5); }
.card-pad-lg { padding: var(--s-6); }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--sh-lg); border-color: var(--c-line-strong); }
.card-link { display: block; cursor: pointer; }
.card-accent-top { border-top: 3px solid var(--seat-accent); }
.panel { background: var(--c-paper); border: 1px solid var(--c-line); border-radius: var(--r-lg); }
.tint { background: var(--seat-accent-wash); border: 1px solid var(--seat-accent-soft); border-radius: var(--r-lg); }
.tint-cream { background: var(--c-cream-deep); border-radius: var(--r-lg); }

/* ---- Avatars ----------------------------------------------------------- */
.avatar {
  --sz: 40px; width: var(--sz); height: var(--sz); border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  font-family: var(--font-display); font-weight: 600; font-size: calc(var(--sz) * 0.4);
  color: #fff; background: var(--c-clay); overflow: hidden; user-select: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.xs { --sz: 26px; } .avatar.sm { --sz: 32px; }
.avatar.lg { --sz: 56px; } .avatar.xl { --sz: 84px; }
.av-clay { background: var(--c-clay); } .av-honey { background: var(--c-honey-deep); }
.av-sage { background: var(--c-sage); } .av-plum { background: var(--c-plum); }
.av-teal { background: var(--c-teal); } .av-ink { background: var(--c-ink-soft); }
.av-green { background: var(--c-green); }

.avstack { display: inline-flex; }
.avstack .avatar { border: 2.5px solid var(--c-paper); margin-left: -12px; }
.avstack .avatar:first-child { margin-left: 0; }
.avstack .more {
  margin-left: -12px; border: 2.5px solid var(--c-paper);
  background: var(--c-cream-deep); color: var(--c-ink-soft);
}

/* ---- Forms ------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: var(--s-2); }
.label { font-size: var(--fs-xs); font-weight: 700; letter-spacing: var(--tracking-wide); color: var(--c-ink-soft); }
.input, .textarea, .select {
  width: 100%; background: var(--c-paper); border: 1.5px solid var(--c-line-strong);
  border-radius: var(--r-sm); padding: 0.7em 0.9em; font-size: var(--fs-sm);
  color: var(--c-ink); transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--c-ink-muted); }
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--seat-accent);
  box-shadow: 0 0 0 4px var(--seat-accent-soft); background: var(--c-paper);
}
.textarea { resize: vertical; min-height: 90px; line-height: var(--lh-base); }
.input-lg { padding: 0.9em 1.1em; font-size: var(--fs-base); }
.search { position: relative; }
.search .input { padding-left: 2.5em; }
.search svg { position: absolute; left: 0.85em; top: 50%; transform: translateY(-50%); width: 1.1em; height: 1.1em; color: var(--c-ink-muted); }

/* ---- Toggle switch ----------------------------------------------------- */
.switch { position: relative; width: 40px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border-radius: var(--r-pill);
  background: var(--c-line-strong); transition: background var(--t-fast) var(--ease-out);
}
.switch .thumb {
  position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: var(--sh-sm); transition: transform var(--t-med) var(--ease-back);
}
.switch input:checked ~ .track { background: var(--seat-accent); }
.switch input:checked ~ .thumb { transform: translateX(16px); }
.switch input:focus-visible ~ .track { box-shadow: 0 0 0 4px var(--seat-accent-soft); }

/* Segmented control ------------------------------------------------------ */
.segment { display: inline-flex; background: var(--c-cream-deep); border-radius: var(--r-pill); padding: 4px; gap: 2px; }
.segment button {
  padding: 0.5em 1em; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600;
  color: var(--c-ink-muted); transition: all var(--t-fast) var(--ease-out);
}
.segment button.is-active { background: var(--c-paper); color: var(--c-ink); box-shadow: var(--sh-xs); }

/* ---- Tabs -------------------------------------------------------------- */
.tabs { display: flex; gap: var(--s-2); border-bottom: 1px solid var(--c-line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; padding: 0.85em 0.2em; margin-right: var(--s-4); font-size: var(--fs-sm); font-weight: 600;
  color: var(--c-ink-muted); white-space: nowrap; transition: color var(--t-fast);
}
.tab:hover { color: var(--c-ink); }
.tab.is-active { color: var(--seat-accent-deep); }
.tab.is-active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2.5px;
  background: var(--seat-accent); border-radius: 2px;
}
.tab .badge { margin-left: 0.5em; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: fadeUp var(--t-med) var(--ease-out); }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Permission row (Bubbles centerpiece) ------------------------------ */
.perm-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--s-4);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  transition: background var(--t-fast);
}
.perm-row:hover { background: var(--c-cream-deep); }
.perm-toggles { display: flex; gap: var(--s-5); align-items: center; }
.perm-toggle { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.perm-toggle .label { font-size: var(--fs-3xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
@media (max-width: 720px) { .perm-toggles { gap: var(--s-4); } }

/* ---- Chat / message thread --------------------------------------------- */
.thread { display: flex; flex-direction: column; gap: var(--s-4); }
.msg { display: flex; gap: var(--s-3); max-width: 78%; }
.msg-body { background: var(--c-paper); border: 1px solid var(--c-line); border-radius: 4px var(--r-md) var(--r-md) var(--r-md); padding: var(--s-3) var(--s-4); box-shadow: var(--sh-xs); }
.msg-name { font-size: var(--fs-xs); font-weight: 700; color: var(--c-ink); }
.msg-time { font-size: var(--fs-3xs); color: var(--c-ink-muted); }
.msg-text { font-size: var(--fs-sm); color: var(--c-ink-soft); margin-top: 3px; line-height: var(--lh-base); }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg.me .msg-body { background: var(--seat-accent); border-color: transparent; border-radius: var(--r-md) 4px var(--r-md) var(--r-md); }
.msg.me .msg-name, .msg.me .msg-text { color: #fff; }
.msg.me .msg-time { color: rgba(255,255,255,0.75); }
.composer { display: flex; gap: var(--s-3); align-items: flex-end; padding-top: var(--s-4); border-top: 1px solid var(--c-line); }

/* ---- Tables (data) ----------------------------------------------------- */
.dtable { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.dtable th { text-align: left; font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: var(--tracking-wide); color: var(--c-ink-muted); font-weight: 700; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--c-line); }
.dtable td { padding: var(--s-4); border-bottom: 1px solid var(--c-line); vertical-align: middle; }
.dtable tr:last-child td { border-bottom: none; }
.dtable tbody tr { transition: background var(--t-fast); }
.dtable tbody tr:hover { background: var(--c-cream-deep); }

/* ---- Empty state ------------------------------------------------------- */
.empty { text-align: center; padding: var(--s-8) var(--s-5); }
.empty .icon { width: 56px; height: 56px; margin: 0 auto var(--s-4); color: var(--c-ink-muted); opacity: 0.7; }

/* ---- Stat tile --------------------------------------------------------- */
.stat { padding: var(--s-5); }
.stat .num { font-family: var(--font-display); font-size: var(--fs-2xl); line-height: 1; color: var(--c-ink); }
.stat .cap { font-size: var(--fs-xs); color: var(--c-ink-muted); margin-top: var(--s-2); font-weight: 600; }
.stat .delta { font-size: var(--fs-2xs); font-weight: 700; }
.delta.up { color: var(--c-success); } .delta.down { color: var(--c-danger); }

/* ---- Progress ---------------------------------------------------------- */
.progress { height: 8px; background: var(--c-cream-deep); border-radius: var(--r-pill); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--seat-accent); border-radius: var(--r-pill); transition: width var(--t-slow) var(--ease-out); }

/* ---- Modal ------------------------------------------------------------- */
.modal-scrim {
  position: fixed; inset: 0; z-index: var(--z-modal); display: none;
  align-items: center; justify-content: center; padding: var(--s-5);
  background: rgba(36, 28, 21, 0.42); backdrop-filter: blur(4px);
}
.modal-scrim.is-open { display: flex; animation: scrim var(--t-med) var(--ease-out); }
@keyframes scrim { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--c-paper); border-radius: var(--r-xl); box-shadow: var(--sh-xl);
  width: 100%; max-width: 540px; max-height: 88vh; overflow: auto;
  animation: modalIn var(--t-slow) var(--ease-back);
}
.modal-lg { max-width: 720px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(24px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal-head { padding: var(--s-6) var(--s-6) var(--s-4); }
.modal-body { padding: 0 var(--s-6) var(--s-5); }
.modal-foot { padding: var(--s-4) var(--s-6) var(--s-6); display: flex; gap: var(--s-3); justify-content: flex-end; border-top: 1px solid var(--c-line); margin-top: var(--s-2); }

/* ---- Toast ------------------------------------------------------------- */
.toast-host { position: fixed; bottom: var(--s-6); left: 50%; transform: translateX(-50%); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--s-3); align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: var(--s-3); pointer-events: auto;
  background: var(--c-ink); color: var(--c-cream); padding: 0.85em 1.2em;
  border-radius: var(--r-pill); box-shadow: var(--sh-lg); font-size: var(--fs-sm); font-weight: 500;
  animation: toastIn var(--t-slow) var(--ease-back);
}
.toast svg { width: 1.2em; height: 1.2em; color: var(--c-honey); }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(0.95); } to { opacity: 1; transform: none; } }
.toast.out { animation: toastOut var(--t-med) var(--ease-out) forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }
