/* Camadas sobre a página (prefixo c-): modal, painel lateral, popover com
   menu, botão de fechar e aviso flutuante.

   <div class="c-backdrop" hidden></div>
   <div class="c-modal" hidden>
     <div class="c-modal__head"><div><h2>…</h2><p class="meta">…</p></div><button class="c-close">×</button></div>
     <div class="c-modal__body">…</div>
     <div class="c-modal__foot"><div class="c-actions c-actions--end">…</div></div>
   </div>

   Camadas (z-index): popover 1200 > modal 951 > painel 901. */

.c-backdrop {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: rgba(20, 18, 14, 0.4);
}

.c-backdrop--drawer {
  z-index: 900;
  background: rgba(20, 18, 14, 0.35);
}

.c-backdrop[hidden] {
  display: none !important;
}

/* ── Modal ─────────────────────────────────────────────────────────── */
.c-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 951;
  display: flex;
  flex-direction: column;
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface-strong);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.18);
  transform: translate(-50%, -50%);
}

.c-modal[hidden],
.c-modal [hidden] {
  display: none !important;
}

.c-modal > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 32px);
}

.c-modal--wide {
  width: min(560px, calc(100vw - 32px));
}

.c-modal--xl {
  width: min(860px, calc(100vw - 32px));
}

.c-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 22px 14px;
  border-bottom: 1px solid var(--line);
}

.c-modal__head h2 {
  margin: 0 0 2px;
  font-family: "Syne", sans-serif;
  font-size: 17px;
}

.c-modal__head .meta {
  margin: 0;
}

.c-modal__body {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 22px;
  overflow-y: auto;
}

.c-modal__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 22px;
  border-top: 1px solid var(--line);
  background: var(--fill-hover);
}

/* Botões do rodapé um pouco maiores que os da página. */
.c-modal__foot .c-btn:not(.c-btn--link) {
  height: 36px;
  padding: 0 16px;
}

/* ── Painel lateral ────────────────────────────────────────────────── */
.c-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 901;
  display: flex;
  flex-direction: column;
  width: min(640px, 100vw);
  border-left: 1px solid var(--line-strong);
  background: var(--fill-hover);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.12);
}

.c-drawer[hidden] {
  display: none !important;
}

.c-drawer--narrow {
  width: min(560px, 100vw);
}

.c-drawer__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px 14px;
  background: #fff;
}

.c-drawer__head h2 {
  margin: 0 0 2px;
  font-family: "Syne", sans-serif;
  font-size: 19px;
}

.c-drawer__head .meta {
  margin: 0;
}

/* Abas do painel, entre o cabeçalho e o conteúdo. */
.c-drawer__tabs {
  padding: 0 16px;
  background: #fff;
}

.c-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 22px 24px;
}

/* ── Fechar (×) ────────────────────────────────────────────────────── */
.c-close {
  appearance: none;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--ctl-h-sm);
  height: var(--ctl-h-sm);
  padding: 0;
  border: 0;
  border-radius: calc(var(--r-ctl) - 2px);
  background: none;
  font-family: inherit;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.c-close svg {
  width: var(--ico-only);
  height: var(--ico-only);
}

.c-close:hover {
  background: var(--fill);
  color: var(--text);
}

.c-close:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* ── Popover e menu ────────────────────────────────────────────────── */
.c-pop {
  position: absolute;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  min-width: 220px;
  max-width: calc(100vw - 24px);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-card);
  background: #fff;
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-ctl);
  overflow: hidden;
}

.c-pop[hidden] {
  display: none !important;
}

/* Popover que não precisa de JS para abrir: só aparece com .open. */
.c-pop--toggle {
  display: none;
}

.c-pop--toggle.open {
  display: flex;
}

.c-pop__head {
  padding: 12px 14px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--subtle);
}

.c-pop__body {
  padding: 12px 14px 14px;
  overflow-y: auto;
}

.c-pop__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  background: var(--fill-hover);
}

.c-menu {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 320px;
  padding: 6px;
  overflow-y: auto;
}

.c-menu__item {
  appearance: none;
  display: flex;
  align-items: center;
  gap: var(--gap-ico-lg);
  width: 100%;
  min-height: 32px;
  padding: 6px 8px;
  border: 0;
  border-radius: calc(var(--r-ctl) - 1px);
  background: none;
  font-family: inherit;
  font-size: var(--fs-ctl);
  text-align: left;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.c-menu__item svg {
  width: var(--ico);
  height: var(--ico);
  flex: none;
  color: var(--muted);
}

.c-menu__item:hover,
.c-menu__item:focus-visible {
  background: #f6f3ee;
  outline: none;
}

.c-menu__item.on {
  font-weight: 600;
}

.c-menu__item--danger {
  color: var(--error);
}

.c-menu__item--danger svg {
  color: currentColor;
}

.c-menu__item small {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
}

.c-menu__item input[type="checkbox"] {
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.c-menu__item label {
  flex: 1;
  margin: 0;
  font-size: inherit;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  color: inherit;
  cursor: pointer;
}

.c-menu__divider {
  height: 1px;
  margin: 4px 2px;
  background: var(--line);
}

/* ── Aviso flutuante ───────────────────────────────────────────────── */
.c-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 1300;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  min-height: var(--ctl-h);
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: #1d1b17;
  box-shadow: 0 10px 28px rgba(20, 24, 29, 0.22);
  font-size: 12.5px;
  font-weight: 600;
  color: #fff;
  transform: translateX(-50%);
}

.c-toast[hidden] {
  display: none !important;
}

.c-toast--error {
  background: var(--error);
}

.c-toast--ok::before {
  content: "✓";
  color: #8fd18a;
}
