:root {
  --admin-bg: #f4f6f9;
  --admin-surface: #ffffff;
  --admin-border: #e2e8f0;
  --admin-text: #0f172a;
  --admin-muted: #64748b;
  --admin-primary: #15803d;
  --admin-primary-dark: #0f5c2c;
  --admin-danger: #dc2626;
  --admin-radius: 10px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--admin-bg);
  color: var(--admin-text);
}

a { color: var(--admin-primary); text-decoration: none; }

.admin-shell { min-height: 100vh; display: flex; flex-direction: column; }
.admin-body { flex: 1; display: flex; min-height: 0; }

/* ---------- Sidebar ---------- */
.admin-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  background: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}
.admin-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 240px;
  background: #fff;
  border-right: 1px solid var(--admin-border);
  padding: 76px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transform: translateX(-100%);
  transition: transform 0.2s ease;
  z-index: 20;
  overflow-y: auto;
}
.admin-sidebar.is-open { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(15,23,42,0.35); }
.admin-sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  color: var(--admin-text);
  font-weight: 600;
  font-size: 0.95rem;
}
.admin-sidebar__link:hover { background: #f1f5f9; }
.admin-sidebar__link.is-active { background: #dcfce7; color: var(--admin-primary-dark); }
.admin-sidebar__icon { font-size: 1.1rem; width: 22px; text-align: center; }

@media (min-width: 900px) {
  .admin-sidebar-toggle { display: none; }
  .admin-sidebar {
    position: sticky;
    top: 61px;
    height: calc(100vh - 61px);
    transform: none;
    padding: 20px 12px;
    box-shadow: none !important;
    flex-shrink: 0;
  }
  .admin-body { position: relative; }
}

/* ---------- Topbar ---------- */
.admin-topbar {
  background: var(--admin-surface);
  border-bottom: 1px solid var(--admin-border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.admin-topbar__brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; }
.admin-topbar__brand img { height: 32px; width: auto; }
.admin-topbar__user { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; color: var(--admin-muted); }

/* ---------- Layout ---------- */
.admin-main { flex: 1; padding: 16px; max-width: 1100px; width: 100%; margin: 0 auto; }

.admin-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 16px;
  margin-bottom: 16px;
}

.admin-page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.admin-page-head h1 { font-size: 1.3rem; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  min-height: 44px;
}
.btn-primary { background: var(--admin-primary); color: #fff; }
.btn-primary:hover { background: var(--admin-primary-dark); }
.btn-secondary { background: #fff; color: var(--admin-text); border-color: var(--admin-border); }
.btn-danger { background: #fff; color: var(--admin-danger); border-color: #fecaca; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 6px; color: var(--admin-text); }
.field { margin-bottom: 16px; }
.field-hint { font-size: 0.8rem; color: var(--admin-muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=datetime-local], textarea, select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--admin-text);
}
textarea { resize: vertical; min-height: 160px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--admin-primary); outline-offset: 1px; }

.field-row { display: flex; flex-wrap: wrap; gap: 16px; }
.field-row > .field { flex: 1 1 220px; }

.image-preview { max-width: 220px; border-radius: 8px; border: 1px solid var(--admin-border); margin-bottom: 10px; display: block; }

/* ---------- Login ---------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #0f5c2c 0%, #15803d 100%);
}
.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.25);
  text-align: center;
}
.login-card img { max-height: 64px; max-width: 220px; margin: 0 auto 20px; display: block; }
.login-card h1 { font-size: 1.2rem; margin: 0 0 24px; text-align: center; }
.login-card form { text-align: left; }
.login-error { background: #fef2f2; color: #b91c1c; padding: 10px 12px; border-radius: 8px; font-size: 0.88rem; margin-bottom: 16px; }

/* ---------- Table / list (mobile: cards) ---------- */
.post-list { display: flex; flex-direction: column; gap: 10px; }
.post-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--admin-border);
  border-radius: 10px;
  background: #fff;
  align-items: center;
}
.post-item__thumb {
  width: 64px; height: 64px; border-radius: 8px; background: #f1f5f9 center/cover no-repeat; flex-shrink: 0;
}
.post-item__body { flex: 1; min-width: 0; }
.post-item__title { font-weight: 700; font-size: 0.98rem; margin: 0 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.post-item__meta { font-size: 0.8rem; color: var(--admin-muted); display: flex; gap: 8px; flex-wrap: wrap; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.72rem; font-weight: 700; }
.badge-publicado { background: #dcfce7; color: #166534; }
.badge-rascunho { background: #fef3c7; color: #92400e; }
.post-item__actions { display: flex; gap: 6px; }
.post-item__actions .btn { padding: 8px 10px; min-height: 36px; font-size: 0.85rem; }

.empty-state { text-align: center; padding: 40px 16px; color: var(--admin-muted); }

.toast { padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 0.9rem; }
.toast-success { background: #dcfce7; color: #166534; }
.toast-error { background: #fef2f2; color: #b91c1c; }

.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar input { flex: 1; }

/* ---------- Módulos (toggles) ---------- */
.modulos-list { display: flex; flex-direction: column; gap: 4px; }
.modulo-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px;
  border-bottom: 1px solid var(--admin-border);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}
.modulo-toggle:last-child { border-bottom: none; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch__track {
  position: absolute; inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background 0.15s ease;
}
.switch__track::before {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked + .switch__track { background: var(--admin-primary); }
.switch input:checked + .switch__track::before { transform: translateX(20px); }

/* ---------- Dashboard ---------- */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.dash-stat {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--admin-muted);
}
.dash-stat span { font-size: 1.6rem; font-weight: 800; color: var(--admin-text); }

.admin-card__title { font-size: 1rem; margin: 0 0 16px; }

.dash-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 160px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.dash-chart__col {
  flex: 1 0 28px;
  min-width: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
}
.dash-chart__bar {
  width: 100%;
  max-width: 22px;
  background: var(--admin-primary);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
}
.dash-chart__value { font-size: 0.7rem; font-weight: 700; color: var(--admin-text); }
.dash-chart__label { font-size: 0.68rem; color: var(--admin-muted); }

.dash-top-list { display: flex; flex-direction: column; gap: 10px; }
.dash-top-item {
  position: relative;
  display: block;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  padding: 10px 12px;
  overflow: hidden;
  color: var(--admin-text);
}
.dash-top-item__bar {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: #dcfce7;
  z-index: 0;
}
.dash-top-item__info { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 10px; }
.dash-top-item__title { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-top-item__count { font-size: 0.8rem; color: var(--admin-muted); flex-shrink: 0; }

@media (min-width: 640px) {
  .dash-stats { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 720px) {
  .admin-main { padding: 24px; }
  .post-item__thumb { width: 84px; height: 84px; }
}
