:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f6fa;
  --bg-card: #ffffff;
  --bg-sidebar: #1b2a4a;
  --bg-sidebar-hover: rgba(255, 255, 255, 0.08);
  --text-primary: #1a1a2e;
  --text-secondary: #5a6478;
  --text-muted: #8b95a5;
  --border: #e8ecf1;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: rgba(37, 99, 235, 0.08);
  --success: #0d9f6e;
  --success-light: rgba(13, 159, 110, 0.1);
  --danger: #dc3545;
  --danger-light: rgba(220, 53, 69, 0.1);
  --warning: #e67e22;
  --warning-light: rgba(230, 126, 34, 0.1);
  --purple: #7c3aed;
  --purple-light: rgba(124, 58, 237, 0.1);
  --pink: #ec4899;
  --pink-light: rgba(236, 72, 153, 0.1);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 260px;
}

[data-theme="dark"] {
  --bg-primary: #1e2433;
  --bg-secondary: #161b27;
  --bg-card: #242b3d;
  --bg-sidebar: #111520;
  --bg-sidebar-hover: rgba(255, 255, 255, 0.05);
  --text-primary: #e4e7ed;
  --text-secondary: #9aa3b5;
  --text-muted: #6b7588;
  --border: #2e3648;
  --accent-light: rgba(37, 99, 235, 0.18);
  --success-light: rgba(13, 159, 110, 0.18);
  --danger-light: rgba(220, 53, 69, 0.18);
  --warning-light: rgba(230, 126, 34, 0.18);
  --purple-light: rgba(124, 58, 237, 0.18);
  --pink-light: rgba(236, 72, 153, 0.18);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition:
    background 0.2s,
    color 0.2s;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

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

/* === Login === */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #6366f1 0%, #ec4899 100%);
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 18px;
  background: linear-gradient(
    135deg,
    #f09433,
    #e6683c,
    #dc2743,
    #cc2366,
    #bc1888
  );
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.login-logo svg {
  width: 36px;
  height: 36px;
}

.login-brand h1 {
  font-size: 24px;
  font-weight: 700;
}

.login-sub {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.login-form label {
  display: block;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.login-form input {
  display: block;
  width: 100%;
  padding: 12px 14px;
  margin-top: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition:
    border 0.15s,
    background 0.15s;
}

.login-form input:focus {
  outline: 0;
  border-color: var(--accent);
  background: var(--bg-card);
}

.login-error {
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  text-align: center;
}

/* === Layout === */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f09433, #dc2743, #bc1888);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.brand-icon svg {
  width: 22px;
  height: 22px;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
}

.brand-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
}

.nav {
  padding: 16px 12px;
  flex: 1;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  transition:
    background 0.12s,
    color 0.12s;
  margin-bottom: 2px;
}

.nav a:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}

.nav a.active {
  background: var(--accent);
  color: #fff;
}

.nav a svg {
  width: 18px;
  height: 18px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.back-admin {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.55);
  transition: background 0.12s;
}

.back-admin:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}

.back-admin svg {
  width: 16px;
  height: 16px;
}

/* === Main === */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

#page-title {
  font-size: 20px;
  font-weight: 700;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition:
    background 0.12s,
    color 0.12s;
}

.btn-icon:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.btn-icon svg {
  width: 18px;
  height: 18px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f09433, #dc2743);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

#btn-sidebar-toggle {
  display: none;
}

.page {
  padding: 28px;
  flex: 1;
}

/* === Botões === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition:
    background 0.12s,
    transform 0.12s,
    box-shadow 0.12s;
  border: 1px solid transparent;
}

.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: var(--bg-secondary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  filter: brightness(0.95);
}

.btn-block {
  width: 100%;
}
.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
}
.btn-lg {
  padding: 14px 24px;
  font-size: 15px;
}

.btn svg {
  width: 16px;
  height: 16px;
}

/* === Cards === */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}
.card:hover {
  box-shadow: var(--shadow-md);
}

.card-pad {
  padding: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.card-body {
  padding: 24px;
}

/* === Stat cards === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  gap: 16px;
  align-items: center;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 22px;
  height: 22px;
}

.stat-icon.blue {
  background: var(--accent-light);
  color: var(--accent);
}
.stat-icon.green {
  background: var(--success-light);
  color: var(--success);
}
.stat-icon.orange {
  background: var(--warning-light);
  color: var(--warning);
}
.stat-icon.red {
  background: var(--danger-light);
  color: var(--danger);
}
.stat-icon.purple {
  background: var(--purple-light);
  color: var(--purple);
}
.stat-icon.pink {
  background: var(--pink-light);
  color: var(--pink);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 2px;
}

.stat-trend {
  font-size: 11px;
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.stat-trend.up {
  color: var(--success);
}
.stat-trend.down {
  color: var(--danger);
}

/* === Grid === */
.grid {
  display: grid;
  gap: 20px;
}

.grid-2 {
  grid-template-columns: 2fr 1fr;
}
.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 1100px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* === Tabela === */
.table-wrap {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 18px;
  text-align: left;
  font-size: 14px;
}

thead {
  background: var(--bg-secondary);
}

th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

tbody tr {
  border-top: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:hover {
  background: var(--accent-light);
}

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

/* === Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}
.badge-danger {
  background: var(--danger-light);
  color: var(--danger);
}
.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
}
.badge-muted {
  background: var(--bg-secondary);
  color: var(--text-muted);
}
.badge-info {
  background: var(--accent-light);
  color: var(--accent);
}

/* === Form === */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
  display: block;
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: border 0.12s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: 0;
  border-color: var(--accent);
  background: var(--bg-card);
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

.form-help {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 700px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* === Toggle === */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--text-muted);
  border-radius: 999px;
  transition: 0.2s;
  cursor: pointer;
}

.switch-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.switch input:checked + .switch-slider {
  background: var(--accent);
}
.switch input:checked + .switch-slider::before {
  transform: translateX(20px);
}

/* === Posts grid === */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.post-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition:
    transform 0.12s,
    box-shadow 0.12s;
  position: relative;
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.post-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.post-thumb {
  aspect-ratio: 1;
  background: var(--bg-secondary);
  background-size: cover;
  background-position: center;
  position: relative;
}

.post-type-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
}

.post-info {
  padding: 12px;
}

.post-caption {
  font-size: 12px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

/* === Empty / loading === */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.empty-icon svg {
  width: 28px;
  height: 28px;
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* === Toast === */
#toast-stack {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border-left: 4px solid var(--accent);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  min-width: 280px;
  animation: toast-in 0.25s ease;
}

.toast.success {
  border-color: var(--success);
}
.toast.error {
  border-color: var(--danger);
}
.toast.warning {
  border-color: var(--warning);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* === Page header === */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 700;
}

.page-header p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* === Mobile === */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    transition: transform 0.2s;
    z-index: 100;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  #btn-sidebar-toggle {
    display: flex;
  }
  .page {
    padding: 16px;
  }
  .topbar {
    padding: 12px 16px;
  }
}

/* === Chips === */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  border-radius: 999px;
  font-weight: 600;
  margin: 2px 4px 2px 0;
}

.chip button {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  font-size: 10px;
  color: inherit;
}

/* === Input com chip === */
.chip-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 40px;
}

.chip-input input {
  border: 0;
  background: transparent;
  outline: 0;
  flex: 1;
  min-width: 100px;
  padding: 4px;
  font-size: 14px;
}

/* === DM preview === */
.dm-preview {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
}

.dm-bubble {
  background: linear-gradient(135deg, #6366f1, #ec4899);
  color: #fff;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  font-size: 13px;
  align-self: flex-end;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.dm-bubble img {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 6px;
}

.dm-bubble .dm-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  font-weight: 600;
  font-size: 12px;
}

/* === Step indicator === */
.steps {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.step {
  flex: 1;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.step.active {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

.step.done {
  background: var(--success-light);
  color: var(--success);
  border-color: var(--success);
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
}

.step.active .step-num,
.step.done .step-num {
  background: currentColor;
  color: #fff;
}
