/* usefulweb Teamspaces client UI (public/teams.js): dialogs, avatars, presence chip, account-page bits.
   Prefixed .uwt-/.teams- so app and platform styles do not collide; light + dark (data-theme and system). */
:root {
  --uwt-bg: #ffffff;
  --uwt-ink: #1b1f27;
  --uwt-muted: #4f5868;
  --uwt-line: #c9d0dc;
  --uwt-soft: #f2f5fa;
  --uwt-accent: #2f5bd3;
  --uwt-accent-ink: #ffffff;
  --uwt-danger: #b3261e;
  --uwt-ok: #0b7a52;
  --uwt-focus: #1a56db;
}
:root[data-theme="dark"] {
  --uwt-bg: #1b1f27;
  --uwt-ink: #eef1f6;
  --uwt-muted: #b7bfcc;
  --uwt-line: #475063;
  --uwt-soft: #262c37;
  --uwt-accent: #8fb0ff;
  --uwt-accent-ink: #10131a;
  --uwt-danger: #ffb4ab;
  --uwt-ok: #7fdcb3;
  --uwt-focus: #a8c1ff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --uwt-bg: #1b1f27;
    --uwt-ink: #eef1f6;
    --uwt-muted: #b7bfcc;
    --uwt-line: #475063;
    --uwt-soft: #262c37;
    --uwt-accent: #8fb0ff;
    --uwt-accent-ink: #10131a;
    --uwt-danger: #ffb4ab;
    --uwt-ok: #7fdcb3;
    --uwt-focus: #a8c1ff;
  }
}

.uwt-dialog {
  width: min(34rem, calc(100vw - 1.5rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 1px solid var(--uwt-line);
  border-radius: 12px;
  background: var(--uwt-bg);
  color: var(--uwt-ink);
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.35);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  text-align: start;
}
.uwt-dialog.uwt-wide { width: min(46rem, calc(100vw - 1.5rem)); }
.uwt-dialog::backdrop { background: rgb(10 14 20 / 0.55); }
.uwt-dialog [hidden] { display: none !important; }
.uwt-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.9rem 1rem 0.4rem; position: sticky; top: 0; background: var(--uwt-bg); z-index: 1; }
.uwt-head h2 { margin: 0; font-size: 1.15rem; flex: 1; color: var(--uwt-ink); }
.uwt-body { padding: 0.2rem 1rem 0.6rem; }
.uwt-body h3 { font-size: 1rem; margin: 1.1rem 0 0.4rem; color: var(--uwt-ink); }
.uwt-status { margin: 0; padding: 0 1rem 0.9rem; min-height: 1.2em; color: var(--uwt-muted); }
.uwt-status[data-kind="error"], .teams-status[data-kind="error"] { color: var(--uwt-danger); font-weight: 600; }

:where(.uwt-dialog) button, :where(.uwt-dialog) select, :where(.uwt-dialog) input {
  font: inherit;
  width: auto;
  min-height: 2.25rem;
  margin: 0;
  color: var(--uwt-ink);
  background: var(--uwt-soft);
  border: 1px solid var(--uwt-line);
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
}
:where(.uwt-dialog) input { background: var(--uwt-bg); max-width: 100%; }
:where(.uwt-dialog) textarea { font: inherit; width: 100%; box-sizing: border-box; margin: 0; padding: 0.4rem 0.6rem; color: var(--uwt-ink); background: var(--uwt-bg); border: 1px solid var(--uwt-line); border-radius: 8px; resize: vertical; }
.uwt-dialog textarea:focus-visible { outline: 3px solid var(--uwt-focus); outline-offset: 2px; }
.uwt-dialog button { cursor: pointer; }
.uwt-dialog button:hover { border-color: var(--uwt-accent); }
.uwt-dialog :is(button, input, select, a, summary):focus-visible { outline: 3px solid var(--uwt-focus); outline-offset: 2px; }
.uwt-dialog button:disabled, .uwt-dialog select:disabled { opacity: 0.6; cursor: not-allowed; }
.uwt-dialog .uwt-primary, .uwt-dialog button[type="submit"] { background: var(--uwt-accent); color: var(--uwt-accent-ink); border-color: var(--uwt-accent); font-weight: 600; }
.uwt-dialog button[type="submit"]:hover { background: var(--uwt-accent); color: var(--uwt-accent-ink); filter: brightness(1.08); }
.uwt-dialog .uwt-close { min-height: 2.25rem; min-width: 2.25rem; padding: 0; font-size: 1.4rem; line-height: 1; background: transparent; border-color: transparent; }
.uwt-dialog .uwt-link { background: transparent; border-color: transparent; color: var(--uwt-accent); text-decoration: underline; padding: 0.2rem 0.4rem; min-height: 2rem; }
.uwt-dialog .uwt-danger-btn, .uwt-dialog button[type="submit"].uwt-danger-btn { background: var(--uwt-danger); color: var(--uwt-bg); border-color: var(--uwt-danger); }
.uwt-dialog a { color: var(--uwt-accent); }
.uwt-field { display: flex; flex-direction: column; gap: 0.25rem; margin: 0.5rem 0; }
.uwt-field label { font-weight: 600; }
.uwt-hint, .uwt-note, .uwt-pick-meta { color: var(--uwt-muted); font-size: 0.9rem; }
.uwt-or { text-align: center; color: var(--uwt-muted); margin: 0.4rem 0; }
.uwt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0 0.8rem; align-items: end; }
.uwt-inline { display: flex; flex-wrap: wrap; gap: 0 0.8rem; align-items: end; }
.uwt-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.uwt-details summary { cursor: pointer; padding: 0.3rem 0; color: var(--uwt-accent); }
.uwt-pick, .uwt-members, .uwt-audit { list-style: none; margin: 0.4rem 0; padding: 0; display: grid; gap: 0.35rem; }
.uwt-pick-item { display: grid !important; grid-template-columns: auto 1fr; grid-template-areas: "av name" "av meta"; align-items: center; gap: 0 0.6rem; width: 100% !important; text-align: start; padding: 0.5rem 0.7rem !important; }
.uwt-pick-item > .uwt-avatar { grid-area: av; }
.uwt-pick-item > .uwt-pick-name { grid-area: name; font-weight: 600; }
.uwt-pick-item > .uwt-pick-meta { grid-area: meta; }
.uwt-pick-item:not(:has(.uwt-avatar)) { grid-template-areas: "name name" "meta meta"; }
.uwt-members li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; padding: 0.3rem 0; border-bottom: 1px solid var(--uwt-line); }
.uwt-member-name { flex: 1 1 8rem; min-width: 0; overflow-wrap: anywhere; }
.uwt-audit li { font-size: 0.9rem; border-bottom: 1px solid var(--uwt-line); padding: 0.25rem 0; }
.uwt-audit time { color: var(--uwt-muted); }
.uwt-rules { display: grid; gap: 0.3rem; }
.uwt-rule { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.4rem; align-items: center; margin: 0; padding: 0.25rem 0; border-bottom: 1px solid var(--uwt-line); }
.uwt-rule > span { flex: 1 1 10rem; }
.uwt-danger { margin-top: 1rem; border-top: 2px solid var(--uwt-line); }
.uwt-link-out { width: 100%; }

.uwt-avatar, .teams-avatar {
  display: inline-grid; place-items: center; flex: none;
  border-radius: 50%; color: #fff; background: #2f5bd3; font-weight: 700; letter-spacing: 0.02em;
  width: 2rem; height: 2rem; font-size: 0.8rem; line-height: 1; vertical-align: middle;
}
.uwt-avatar-s { width: 1.5rem; height: 1.5rem; font-size: 0.65rem; }
.uwt-avatar-m { width: 2.1rem; height: 2.1rem; }
.teams-ws-icon, .uwt-pick-item .uwt-avatar { border-radius: 8px; }
/* palette fallback without JS (all pass 4.5:1 with white text) */
[data-color="#2f5bd3"] { background: #2f5bd3; } [data-color="#0b7a52"] { background: #0b7a52; } [data-color="#9c4512"] { background: #9c4512; } [data-color="#8a35a3"] { background: #8a35a3; }
[data-color="#b0164f"] { background: #b0164f; } [data-color="#00695f"] { background: #00695f; } [data-color="#4e40c4"] { background: #4e40c4; } [data-color="#6f5900"] { background: #6f5900; }

.uwt-chip { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.85rem; max-width: 100%; }
.uwt-chip:empty { display: none; }
.uwt-chip-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.uwt-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.uwt-readonly { margin: 0; padding: 0.45rem 0.8rem; background: #fff4d6; color: #4a3500; border-bottom: 1px solid #e3c770; font-size: 0.9rem; }
:root[data-theme="dark"] .uwt-readonly { background: #3a3013; color: #ffe7a6; border-color: #6b5a20; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .uwt-readonly { background: #3a3013; color: #ffe7a6; border-color: #6b5a20; } }

/* account / login page */
.teams-login { margin: 1rem 0; }
.teams-create summary { cursor: pointer; }
.teams-form p { margin: 0.5rem 0; }
.teams-form label { display: inline-block; margin-inline-end: 0.4rem; }
.teams-colors { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; border: 1px solid var(--uwt-line); border-radius: 8px; padding: 0.5rem 0.8rem; }
.teams-color { display: inline-flex; align-items: center; gap: 0.3rem; }
.teams-swatch { display: inline-block; width: 1.1rem; height: 1.1rem; border-radius: 50%; }
.teams-list { list-style: none; padding: 0; display: grid; gap: 0.4rem; }
.teams-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.7rem; }
.teams-list .inline-form { display: inline-flex; gap: 0.3rem; align-items: center; }
.teams-list input { width: auto; max-width: 12rem; }
.teams-badge { padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--uwt-soft); border: 1px solid var(--uwt-line); font-size: 0.8rem; }
.teams-avatar-row { display: flex; align-items: center; gap: 0.6rem; }
.teams-delete-ws { border: 1px solid var(--uwt-line); border-radius: 8px; margin: 0.8rem 0; }
.teams-delete-ws select { width: auto; max-width: 100%; }

@media (max-width: 480px) {
  .uwt-dialog { width: calc(100vw - 0.5rem); max-height: calc(100vh - 0.5rem); border-radius: 10px; }
  .uwt-rule { flex-direction: column; align-items: stretch; }
  .uwt-rule select, .uwt-field select, .uwt-field input { width: 100%; }
}
/* Comments dialog of the generic app binding (public/apps/<id>/workspace.js) */
.uwt-ws-clist { list-style: none; margin: 0 0 0.75rem; padding: 0; display: grid; gap: 0.6rem; max-height: 45vh; overflow: auto; }
.uwt-ws-clist:focus-visible { outline: 3px solid var(--uwt-focus); outline-offset: 2px; }
.uwt-ws-citem p { margin: 0; }
.uwt-ws-cbody { white-space: pre-wrap; overflow-wrap: anywhere; }
