*, *::before, *::after { box-sizing: border-box; }

:root {
  color-scheme: dark;
  --bg: #050507;
  --panel: #0d0d10;
  --panel-2: #131317;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f1f1ef;
  --muted: rgba(241, 241, 239, 0.66);
  --faint: rgba(241, 241, 239, 0.42);
  --gold: #c9a24f;
  --gold-soft: rgba(201, 162, 79, 0.14);
  --green: #6fc784;
  --red: #e07d7d;
  --amber: #f3b454;
  --blue: #75a7ff;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

html, body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 520px at 30% -20%, rgba(201, 162, 79, 0.08), transparent 62%),
    linear-gradient(180deg, #070708 0%, var(--bg) 58%);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.pub-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.pub-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.panel-kicker {
  display: inline-flex;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1, h2, p {
  margin: 0;
}

h1 {
  margin-top: 8px;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

.pub-head p {
  max-width: 680px;
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.55;
}

.head-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Acoes do formulario: 'Agendar' (CTA principal) ocupa a linha inteira no
   topo; 'Salvar rascunho' e 'Publicar agora' dividem a linha de baixo. */
.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

#schedule-btn {
  grid-column: 1 / -1;
}

.primary-btn,
.secondary-btn,
.publish-now-btn {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.primary-btn {
  color: #08080a;
  background: linear-gradient(135deg, #e0bd71, var(--gold) 60%, #a77d31);
  box-shadow: 0 14px 36px -18px rgba(201, 162, 79, 0.9);
}

.secondary-btn {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
  border-color: var(--line);
}

.publish-now-btn {
  color: #0a0a0c;
  background: linear-gradient(135deg, #8fdca1, var(--green));
  border-color: rgba(111, 199, 132, 0.42);
}

.secondary-btn:hover,
.primary-btn:hover,
.publish-now-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:disabled,
.secondary-btn:disabled,
.publish-now-btn:disabled {
  opacity: 0.58;
  cursor: wait;
  transform: none;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--amber);
}

.status-strip[data-state="ok"] .status-dot { background: var(--green); }
.status-strip[data-state="error"] .status-dot { background: var(--red); }

.pub-grid {
  display: grid;
  grid-template-columns: minmax(360px, 520px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.composer,
.queue-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0.01)), var(--panel);
}

.composer {
  padding: 18px;
}

.queue-panel {
  padding: 18px;
  min-height: 620px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin-top: 4px;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.counter {
  color: var(--faint);
  font-size: 12px;
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.segmented label {
  display: block;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 34px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}

.segmented input:checked + span {
  color: #08080a;
  background: var(--gold);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
}

.field label {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.field small,
.form-status {
  color: var(--faint);
  font-size: 12px;
  line-height: 1.45;
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
input[type="file"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #09090b;
  color: var(--text);
  outline: none;
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
select {
  min-height: 40px;
  padding: 0 12px;
}

input[type="file"] {
  padding: 10px;
}

textarea {
  resize: vertical;
  min-height: 150px;
  padding: 12px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(201, 162, 79, 0.55);
  box-shadow: 0 0 0 3px rgba(201, 162, 79, 0.12);
}

.two-cols,
.advanced-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Data/hora e texto alternativo: mais respiro entre as colunas e inputs
   alinhados pela base, mesmo que um dos rotulos quebre em duas linhas. */
.two-cols {
  gap: 16px;
  align-items: end;
  margin-bottom: 14px;
}

.two-cols .field {
  margin-bottom: 0;
}

.advanced-grid {
  gap: 12px;
}

.advanced {
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.advanced summary {
  padding: 12px;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.advanced-grid {
  padding: 0 12px 12px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  color: var(--muted);
  font-weight: 700;
}

.channel-panel {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.channel-head,
.label-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.channel-head h3 {
  margin: 4px 0 0;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.channel-head small {
  color: var(--faint);
  font-size: 11px;
  line-height: 1.35;
  text-align: right;
}

.channel-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.018);
}

.channel-option input {
  margin-top: 3px;
}

.channel-option strong,
.channel-option small {
  display: block;
}

.channel-option strong {
  color: var(--text);
  font-size: 12px;
}

.channel-option small {
  margin-top: 3px;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.35;
}

.channel-option:has(input:disabled) {
  opacity: 0.52;
}

.preview-card {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 12px 0 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.preview-card.is-carousel {
  align-items: stretch;
  flex-direction: column;
}

.preview-media {
  width: 74px;
  height: 74px;
  border-radius: 6px;
  overflow: hidden;
  background: #050507;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}

.preview-media img,
.preview-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-media.preview-carousel {
  width: 100%;
  height: auto;
  min-height: 74px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
  padding: 8px;
}

.preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 5px;
  overflow: hidden;
  background: #050507;
}

.preview-item b {
  position: absolute;
  right: 4px;
  top: 4px;
  display: grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 10px;
}

.preview-meta {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.preview-meta strong,
.preview-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-meta span {
  color: var(--faint);
  font-size: 12px;
}

.carousel-order {
  display: grid;
  gap: 8px;
}

.carousel-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.022);
}

.carousel-row strong,
.carousel-row span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.carousel-row strong {
  color: var(--text);
  font-size: 12px;
}

.carousel-row span {
  margin-top: 3px;
  color: var(--faint);
  font-size: 11px;
}

.carousel-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.carousel-actions button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.carousel-actions button:hover {
  color: var(--gold);
  border-color: rgba(201, 162, 79, 0.38);
}

.carousel-actions button:disabled {
  opacity: 0.34;
  cursor: default;
}

.form-status {
  min-height: 20px;
  margin-bottom: 14px;
}

.form-status[data-state="error"] { color: var(--red); }
.form-status[data-state="ok"] { color: var(--green); }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.summary-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,0.018);
}

.summary-grid span {
  display: block;
  color: var(--faint);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.summary-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 1.45rem;
}

.post-list {
  display: grid;
  gap: 10px;
}

.empty-state {
  padding: 34px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--faint);
  text-align: center;
}

.post-card {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.post-thumb {
  width: 86px;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  background: #070708;
  border: 1px solid var(--line);
}

.post-thumb img,
.post-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-deleted {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 10px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  text-transform: uppercase;
}

.post-body {
  min-width: 0;
}

.post-top,
.post-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.post-top {
  justify-content: space-between;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.badge[data-status="scheduled"] { color: var(--blue); background: rgba(117, 167, 255, 0.12); }
.badge[data-status="published"] { color: var(--green); background: rgba(111, 199, 132, 0.13); }
.badge[data-status="error"] { color: var(--red); background: rgba(224, 125, 125, 0.13); }
.badge[data-status="publishing"] { color: var(--amber); background: rgba(243, 180, 84, 0.13); }

.post-caption {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 9px 0;
  color: var(--text);
  line-height: 1.45;
}

.post-meta,
.post-error {
  color: var(--faint);
  font-size: 12px;
}

.post-error {
  margin-top: 8px;
  color: var(--red);
}

.mini-btn {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255,255,255,0.025);
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mini-btn:hover {
  color: var(--gold);
  border-color: rgba(201, 162, 79, 0.38);
}

.mini-btn-publish {
  color: #0a0a0c;
  background: var(--green);
  border-color: rgba(111, 199, 132, 0.58);
}

.mini-btn-publish:hover {
  color: #0a0a0c;
  border-color: rgba(111, 199, 132, 0.8);
}

/* ─── Tablet (<=980px): empilha grid principal ────────────────── */
@media (max-width: 980px) {
  .pub-head,
  .post-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .pub-grid {
    grid-template-columns: 1fr;
  }

  .queue-panel {
    min-height: 0;
  }
}

/* ─── Mobile (<=720px): reestrutura para telas estreitas ────────── */
@media (max-width: 720px) {
  .pub-shell {
    width: min(100% - 24px, 1480px);
    padding: 20px 0 32px;
  }

  .pub-head {
    padding-bottom: 18px;
  }

  .composer,
  .queue-panel {
    padding: 16px;
  }

  .panel-head {
    margin-bottom: 14px;
  }

  /* Acoes do cabecalho viram um par full-width, lado a lado. */
  .head-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  /* Campos pareados e opcoes empilham; o resumo da fila continua
     em 3 colunas (numeros sao escaneados melhor lado a lado). */
  .two-cols,
  .advanced-grid,
  .carousel-row {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    gap: 8px;
  }

  .summary-grid div {
    padding: 12px 8px;
  }

  .carousel-actions {
    justify-content: flex-start;
  }

  /* Cabecalho da fila empilha o titulo e o filtro de status,
     deixando o select com largura total (alvo de toque maior). */
  .queue-panel .panel-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  /* Card da fila: miniatura quadrada compacta ao lado das infos,
     em vez de empilhar uma imagem grande recortada no topo. */
  .post-card {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .post-thumb {
    width: 76px;
    aspect-ratio: 1;
  }

  /* Acoes do card ocupam a largura do corpo, com alvos de toque
     maiores e botoes que dividem a linha igualmente. */
  .post-actions {
    width: 100%;
  }

  .post-actions .mini-btn {
    flex: 1 1 auto;
    min-height: 36px;
  }

  .carousel-actions button {
    min-height: 32px;
  }

  /* Inputs >= 16px pra evitar zoom automatico no iOS Safari */
  input[type="text"],
  input[type="number"],
  input[type="datetime-local"],
  input[type="file"],
  select,
  textarea {
    font-size: 16px;
  }
}

/* ─── Mobile extra-pequeno (<=420px) ───────────────────────────── */
@media (max-width: 420px) {
  .pub-shell {
    width: min(100% - 16px, 1480px);
    padding-top: 16px;
  }

  .composer,
  .queue-panel {
    padding: 14px;
  }

  .panel-head h2 {
    font-size: 1.15rem;
  }

  /* Botoes do form empilhados, cada um ocupando a linha inteira */
  .form-actions {
    grid-template-columns: 1fr;
  }
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 16px 0 8px;
}
.page-btn {
  min-width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font: 500 0.85rem/1 var(--font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.page-btn:hover:not(:disabled) { background: var(--line-strong); color: var(--text); }
.page-btn.active { background: var(--gold-soft); color: var(--gold); border-color: var(--gold); }
.page-btn:disabled { opacity: 0.35; cursor: default; }
