/* =========================================================
   Quadro — folha de estilo única
   Referência visual: parede de quadro branco em sala de reunião.
   Cores de caneta, post-its com sombra dura, superfície com grade.
   ========================================================= */

:root {
  --ink: #16202b;
  --ink-soft: #5b6771;
  --ink-faint: #8b959d;
  --paper: #ecefe9;
  --sheet: #ffffff;
  --line: #d2d7d2;
  --line-strong: #b6bdb6;
  --marker: #0e7c66;
  --marker-dark: #0a5d4c;
  --highlight: #f5d547;
  --alert: #c4362f;
  --radius: 4px;
  --font-display: 'Bricolage Grotesque', 'IBM Plex Sans', system-ui, sans-serif;
  --font-ui: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

/* Superfície de quadro branco: grade discreta */
.board-surface {
  background-color: var(--sheet);
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 1;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.015em; margin: 0; }
h1 { font-size: 2rem; line-height: 1.15; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1rem; max-width: 62ch; }

a { color: var(--marker-dark); }

:focus-visible {
  outline: 2px solid var(--marker);
  outline-offset: 2px;
}

/* ---------- Botões ---------- */

.btn {
  font: inherit;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.55rem 1rem;
  cursor: pointer;
  background: var(--marker);
  color: #fff;
  transition: background 120ms ease;
}
.btn:hover { background: var(--marker-dark); }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn-quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-quiet:hover { background: #f4f6f2; }

.btn-danger { background: transparent; color: var(--alert); border-color: #e3b8b5; }
.btn-danger:hover { background: #fbf1f0; }

.btn-small { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
.btn-link {
  background: none; border: none; padding: 0; font: inherit;
  color: var(--marker-dark); text-decoration: underline; cursor: pointer;
}

/* ---------- Campos ---------- */

.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 0.3rem; }
.field input, .field select {
  font: inherit;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--sheet);
  color: var(--ink);
}
.field input:focus { border-color: var(--marker); outline: none; box-shadow: 0 0 0 3px rgba(14, 124, 102, 0.15); }
.field .hint { font-size: 0.8rem; color: var(--ink-faint); margin-top: 0.3rem; }

.code-input { text-transform: uppercase; letter-spacing: 0.18em; font-weight: 600; }

.notice {
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  font-size: 0.88rem;
  margin-bottom: 1rem;
}
.notice-error { background: #fbf1f0; border: 1px solid #e3b8b5; color: #8f2620; }
.notice-ok { background: #eef7f3; border: 1px solid #b6ddcd; color: var(--marker-dark); }
.notice[hidden] { display: none; }

/* =========================================================
   Entrada
   ========================================================= */

.entrance {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  min-height: 100vh;
}

.entrance-wall {
  position: relative;
  padding: 3rem;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.wall-notes { position: relative; width: 100%; max-width: 460px; margin: 0 auto; }

.note {
  position: relative;
  display: block;
  width: 190px;
  padding: 1.1rem;
  font-family: var(--font-display);
  font-size: 1.02rem;
  line-height: 1.3;
  color: #2a2213;
  box-shadow: 5px 5px 0 rgba(22, 32, 43, 0.13);
}
.note-1 { background: var(--highlight); transform: rotate(-3deg); margin-left: 10px; }
.note-2 { background: #a8dcc6; transform: rotate(2.5deg); margin: -18px 0 0 190px; }
.note-3 { background: #f4b3bd; transform: rotate(-1.5deg); margin: 22px 0 0 60px; }

.wall-mark {
  position: absolute;
  bottom: 2.5rem;
  left: 3rem;
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.entrance-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  background: var(--paper);
}

.panel-inner { width: 100%; max-width: 360px; }
.panel-inner h1 { margin-bottom: 0.4rem; }
.panel-lead { color: var(--ink-soft); margin-bottom: 1.8rem; }

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.brand::before {
  content: '';
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--marker);
}

.switch-line { margin-top: 1.4rem; font-size: 0.9rem; color: var(--ink-soft); }

/* =========================================================
   Aplicação
   ========================================================= */

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem 1.6rem;
  background: var(--sheet);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.tabs { display: flex; gap: 0.3rem; margin-left: auto; }

.tab {
  font: inherit;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 0.35rem 0.7rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--highlight); font-weight: 500; }

.who { display: flex; align-items: center; gap: 0.6rem; }
.who-name { font-size: 0.9rem; }

.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--paper);
  border: 2px solid var(--marker);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--ink);
  flex: none;
  overflow: hidden;
}
.avatar-lg { width: 96px; height: 96px; font-size: 2rem; border-width: 3px; }

main { padding: 2rem 1.6rem 4rem; max-width: 1120px; margin: 0 auto; }

.view[hidden] { display: none; }

.view-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.4rem;
}
.view-head p { margin: 0; color: var(--ink-soft); font-size: 0.9rem; }
.view-head .btn { margin-left: auto; align-self: center; }

/* ---------- Clientes ---------- */

.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1.1rem;
}

.client-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--sheet);
  overflow: hidden;
}

.client-logo {
  display: grid;
  place-items: center;
  height: 130px;
  padding: 1.4rem;
  border-bottom: 1px solid var(--line);
}
.client-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-fallback {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--ink-faint);
}

.client-foot { padding: 0.7rem 0.9rem 0.85rem; display: flex; flex-direction: column; gap: 0.15rem; }
.client-name { font-family: var(--font-display); font-size: 1rem; color: var(--ink); text-decoration: none; }
.client-name:hover { text-decoration: underline; }
.client-count { font-size: 0.82rem; color: var(--ink-faint); }
.client-admin { display: flex; gap: 0.7rem; margin-top: 0.35rem; font-size: 0.82rem; }

.client-chip { display: inline-flex; align-items: center; height: 26px; }
.client-chip img { max-height: 26px; max-width: 110px; object-fit: contain; }

.logo-picker { display: flex; gap: 1rem; align-items: center; margin-bottom: 1.2rem; }
.logo-slot {
  width: 90px; height: 70px; flex: none;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  display: grid; place-items: center;
  padding: 0.5rem;
  font-size: 0.8rem; color: var(--ink-faint);
  background: var(--sheet);
}
.logo-slot img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- Boards do cliente ---------- */

.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.1rem;
}

.board-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--sheet);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
}
.board-card:hover { border-color: var(--line-strong); }

.board-thumb { display: block; height: 110px; border-bottom: 1px solid var(--line); }
.board-body { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.75rem 0.9rem 0.9rem; }
.board-job { font-size: 0.78rem; color: var(--marker-dark); font-weight: 500; }
.board-title { font-family: var(--font-display); font-size: 1rem; }
.board-meta { font-size: 0.8rem; color: var(--ink-faint); display: flex; align-items: center; gap: 0.4rem; }
.board-meta .avatar { width: 22px; height: 22px; border-width: 1.5px; font-size: 0.6rem; }

.board-add {
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 190px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}
.board-add:hover { border-color: var(--marker); color: var(--marker-dark); }
.board-add-plus { font-size: 2rem; line-height: 1; font-family: var(--font-display); }

/* ---------- Equipe ---------- */

.table { width: 100%; border-collapse: collapse; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); }
.table th, .table td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 0.82rem; color: var(--ink-soft); font-weight: 500; background: #f7f9f5; }
.table tr:last-child td { border-bottom: none; }
.table .person { display: flex; align-items: center; gap: 0.6rem; }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions .btn { margin-left: 0.3rem; }

.tag {
  display: inline-block;
  font-size: 0.76rem;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
}
.tag-pending { border-color: #e0c76a; background: #fdf6dd; color: #6b551a; }
.tag-off { border-color: #d9c0be; background: #fbf1f0; color: #8f2620; }
.tag-admin { border-color: #a9cfc3; background: #eef7f3; color: var(--marker-dark); }

.invite-code {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.16em;
  background: var(--highlight);
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
}

/* ---------- Perfil ---------- */

.profile { display: grid; grid-template-columns: 220px 1fr; gap: 2.5rem; align-items: start; }
.profile-photo { display: flex; flex-direction: column; align-items: center; gap: 0.7rem; text-align: center; }
.profile-photo .hint { font-size: 0.8rem; color: var(--ink-faint); }
.profile-form { max-width: 420px; }

.pens { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.pen {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.pen[aria-pressed='true'] { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--sheet); }

.cursor-preview {
  margin-top: 1.4rem;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: var(--sheet);
}
.cursor-preview .avatar { width: 30px; height: 30px; font-size: 0.75rem; }
.cursor-preview .label {
  font-size: 0.85rem;
  color: #fff;
  padding: 0.12rem 0.5rem;
  border-radius: 3px;
}

/* ---------- Vazio e diálogo ---------- */

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
  color: var(--ink-soft);
}
.empty p { margin: 0 auto 1rem; }

dialog {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 1.6rem;
  width: min(420px, 92vw);
  color: var(--ink);
  background: var(--sheet);
}
dialog::backdrop { background: rgba(22, 32, 43, 0.35); }
dialog h2 { margin-bottom: 1rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.2rem; }

.loading { color: var(--ink-faint); padding: 2rem 0; }

/* ---------- Telas estreitas ---------- */

@media (max-width: 860px) {
  .entrance { grid-template-columns: 1fr; }
  .entrance-wall { display: none; }
  .profile { grid-template-columns: 1fr; gap: 1.5rem; }
  .topbar { flex-wrap: wrap; gap: 0.8rem; }
  .tabs { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
  .who { margin-left: auto; }
  .table th:nth-child(3), .table td:nth-child(3) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* =========================================================
   Editor do board
   ========================================================= */

.board-page { overflow: hidden; }

.board-bar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.55rem 1rem;
  background: var(--sheet);
  border-bottom: 1px solid var(--line);
  height: 56px;
}

.board-job-chip {
  font-size: 0.8rem;
  color: var(--marker-dark);
  background: #eef7f3;
  border: 1px solid #c6e2d7;
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  white-space: nowrap;
}

.board-name {
  font: 500 1.05rem/1.3 var(--font-display);
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.3rem 0.5rem;
  min-width: 140px;
  max-width: 420px;
  flex: 1 1 auto;
}
.board-name:hover { border-color: var(--line); }
.board-name:focus { border-color: var(--marker); outline: none; background: var(--paper); }

.save-state { font-size: 0.8rem; color: var(--ink-faint); white-space: nowrap; }

.board-bar-actions { display: flex; gap: 0.4rem; margin-left: auto; }

.board-stage {
  position: relative;
  height: calc(100vh - 56px);
  overflow: hidden;
  background-color: var(--sheet);
  background-image:
    radial-gradient(var(--line) 1px, transparent 1px);
  background-size: 26px 26px;
}

#canvas { position: absolute; inset: 0; }
#canvas[data-tool='hand'] { cursor: grab; }
#canvas[data-tool='note'],
#canvas[data-tool='text'],
#canvas[data-tool='rect'],
#canvas[data-tool='ellipse'],
#canvas[data-tool='arrow'],
#canvas[data-tool='pen'] { cursor: crosshair; }

.toolbar {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.4rem;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(22, 32, 43, 0.08);
}

.tool {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  color: var(--ink);
}
.tool:hover { background: var(--paper); }
.tool[aria-pressed='true'] { background: #eef7f3; border-color: #c6e2d7; color: var(--marker-dark); }
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.tool-divider { width: 22px; height: 1px; background: var(--line); margin: 0.3rem 0; }

.tool-colors { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 2px 0; }
.swatch {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(22, 32, 43, 0.18);
  cursor: pointer;
  padding: 0;
}
.swatch[aria-pressed='true'] { box-shadow: 0 0 0 2px var(--sheet), 0 0 0 3.5px var(--ink); }

.zoom-bar {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  display: flex;
  gap: 0.3rem;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.3rem;
  box-shadow: 0 2px 10px rgba(22, 32, 43, 0.08);
}

.text-editor {
  position: absolute;
  z-index: 4;
  border: none;
  outline: 2px solid var(--marker);
  resize: none;
  overflow: hidden;
  font-family: 'IBM Plex Sans', sans-serif;
  line-height: 1.3;
  margin: 0;
}
.text-editor[hidden] { display: none; }

@media (max-width: 860px) {
  .toolbar { flex-direction: row; top: auto; bottom: 16px; left: 50%; transform: translateX(-50%); flex-wrap: wrap; max-width: 92vw; }
  .tool-colors { grid-template-columns: repeat(4, 1fr); }
  .tool-divider { width: 1px; height: 22px; margin: 0 0.3rem; }
  .board-name { max-width: none; }
}
