/* Autopost — dashboard. Visual limpo, claro, em portugues. */
:root {
  --bg: #0f1115;
  --sidebar: #171c2f;
  --sidebar-2: #1f2740;
  --card: #ffffff;
  --content-bg: #f4f6fb;
  --text: #1a1f2b;
  --muted: #6b7280;
  --line: #e5e8ef;
  --brand: #4f46e5;
  --brand-2: #2563eb;
  --green: #16a34a;
  --amber: #d97706;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--content-bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-2); }
.loading { padding: 40px; color: var(--muted); }

/* ---------- Telas de auth (login / setup) ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #243056 0%, var(--bg) 60%);
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  padding: 32px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 22px; text-align: center; }
.auth-card .sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; text-align: center; }
.auth-logo { display: block; height: 44px; width: auto; margin: 4px auto 20px; }
.auth-foot { text-align: center; margin: 16px 0 0; font-size: 14px; color: var(--muted); }
.auth-foot a { color: var(--brand); cursor: pointer; font-weight: 600; }
.auth-foot a:hover { text-decoration: underline; }
.auth-brand { text-align: center; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12px; color: #9aa3b2; }
.brand-badge {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 18px; margin-bottom: 18px;
}
.brand-badge .dot { width: 12px; height: 12px; border-radius: 4px; background: var(--brand); }

/* ---------- Layout principal ---------- */
.shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar);
  color: #cdd5ec;
  padding: 18px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.sidebar .logo {
  display: flex; align-items: center; gap: 10px;
  color: #fff; font-weight: 700; font-size: 18px; padding: 8px 8px 16px;
}
.sidebar .logo { padding-bottom: 4px; }
.sidebar .logo .dot { width: 12px; height: 12px; border-radius: 4px; background: var(--brand); }
.logo-sub { font-size: 11px; color: #7c87a8; letter-spacing: .04em; padding: 0 0 14px 30px; }
.side-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7c87a8; padding: 14px 10px 6px; }
.acct-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 10px; cursor: pointer; color: #cdd5ec;
  border: 1px solid transparent;
}
.acct-item:hover { background: var(--sidebar-2); }
.acct-item.active { background: var(--sidebar-2); color: #fff; border-color: #33406b; }
.acct-item .avatar {
  width: 30px; height: 30px; border-radius: 8px; background: #33406b;
  display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff;
  overflow: hidden;
}
.acct-item .avatar img { width: 100%; height: 100%; object-fit: cover; }
.acct-item .meta { overflow: hidden; }
.acct-item .meta .name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-item .meta .sub { font-size: 12px; color: #8b96ba; }
.sidebar .spacer { flex: 1; }
.sidebar .user-row { font-size: 12px; color: #8b96ba; padding: 10px; border-top: 1px solid #2a3354; }

.content { padding: 26px 30px; overflow: auto; }
.content-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.content-head h2 { margin: 0; font-size: 22px; }
.content-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px;
}
.card h3 { margin: 0 0 4px; font-size: 16px; }
.card .hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.posts { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

/* ---------- Botoes / forms ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--text); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: .15s; text-decoration: none;
}
.btn:hover { background: #f7f8fb; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #4338ca; }
.btn.blue { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.blue:hover { filter: brightness(.95); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--brand); border-color: #f0c5c9; }
.btn.sm { padding: 7px 11px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

label.field { display: block; margin-bottom: 14px; }
label.field .lbl { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
label.field .desc { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
input, textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: 2px solid #c7d2fe; border-color: #c7d2fe; }
textarea { resize: vertical; min-height: 90px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { display: none; }
.switch .track { width: 42px; height: 24px; background: #cbd5e1; border-radius: 999px; position: relative; transition: .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* ---------- Badges de status ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.gray { background: #eef1f6; color: #4b5563; }
.badge.amber { background: #fef3c7; color: #92400e; }
.badge.blue { background: #dbeafe; color: #1e40af; }
.badge.green { background: #dcfce7; color: #166534; }
.badge.red { background: #fee2e2; color: #991b1b; }

/* ---------- Cards de post ---------- */
.post-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.post-card .thumb { aspect-ratio: 1/1; background: #eef1f6 center/cover no-repeat; display: grid; place-items: center; color: #9aa3b2; font-size: 13px; }
.post-card .body { padding: 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.post-card .cap { font-size: 13px; color: #374151; line-height: 1.4; max-height: 76px; overflow: hidden; white-space: pre-wrap; }
.post-card .foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }

/* ---------- Perfil de marca ---------- */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.profile-grid .kv { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.profile-grid .kv .k { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.profile-grid .kv .v { font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #eef2ff; color: #3730a3; border-radius: 999px; padding: 3px 10px; font-size: 12px; }
.angle { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 8px; }
.angle .nome { font-weight: 700; font-size: 13px; color: var(--brand); }
.angle .brief { font-size: 13px; color: #374151; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 17, 21, .55); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,.4); }
.modal.lg { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: #fff; }
.x { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }

.composer { display: grid; grid-template-columns: 280px 1fr; gap: 18px; }
.composer .img-col .preview { aspect-ratio: 1/1; background: #eef1f6 center/cover no-repeat; border-radius: 12px; display: grid; place-items: center; color: #9aa3b2; border: 1px dashed #cbd5e1; }

/* ---------- Toast ---------- */
#toast { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast-item { background: #111827; color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.3); max-width: 360px; }
.toast-item.err { background: #991b1b; }
.toast-item.ok { background: #166534; }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.spin { display: inline-block; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .composer { grid-template-columns: 1fr; }
  .profile-grid, .row-2, .grid.cols-2 { grid-template-columns: 1fr; }
}
