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

:root {
  --orange: #FF6200;
  --orange-light: #fff3ec;
  --orange-dark: #cc4e00;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --border: #e8e6e0;
  --border-soft: #f0ede8;
  --text: #1a1a18;
  --text-2: #6b6b68;
  --text-3: #a8a8a4;
  --green: #1a9e6e;
  --green-bg: #eaf7f2;
  --red: #d63c3c;
  --red-bg: #fdf0f0;
  --sidebar-w: 220px;
  --radius: 10px;
  --radius-lg: 14px;
}

html, body { height: 100%; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── SIDEBAR ─────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border-soft);
}

.brand-icon {
  width: 36px; height: 36px;
  background: var(--orange);
  color: #fff;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 13px;
  flex-shrink: 0;
}

.brand-name {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  display: block;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-3);
  display: block;
}

.nav {
  padding: .75rem .75rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  font-family: 'DM Sans', sans-serif;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
  position: relative;
}

.nav-btn:hover { background: var(--bg); color: var(--text); }

.nav-btn.active {
  background: var(--orange-light);
  color: var(--orange);
  font-weight: 500;
}

.nav-btn.active svg { stroke: var(--orange); }

.nav-count {
  margin-left: auto;
  background: var(--orange);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
  display: none;
}

.nav-count.visible { display: inline-block; }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.automacao-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-2);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
}

.status-dot.on {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-bg);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--green-bg); }
  50% { box-shadow: 0 0 0 5px var(--green-bg); }
}

.btn-toggle-auto {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: all .15s;
}

.btn-toggle-auto:hover { background: var(--bg); }
.btn-toggle-auto.on { background: var(--green); color: #fff; border-color: var(--green); }

/* ── MAIN ────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  padding: 2rem;
}

.tab { display: none; }
.tab.active { display: block; animation: fadeIn .2s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header h1 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 22px;
  color: var(--text);
  margin-bottom: 3px;
}

.page-header p { font-size: 13.5px; color: var(--text-2); }

/* ── BUTTONS ─────────────────────────────── */
.btn-primary {
  background: var(--orange);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}

.btn-primary:hover { background: var(--orange-dark); }
.btn-primary:active { transform: scale(.98); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}

.btn-secondary:hover { background: var(--bg); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: none;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  transition: background .15s;
}

.btn-ghost:hover { background: var(--bg); }

/* ── CARDS GRID ──────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-3);
  gap: .5rem;
}

.empty-state svg { stroke: var(--text-3); margin-bottom: .5rem; }
.empty-state p { font-size: 15px; color: var(--text-2); font-weight: 500; }
.empty-state span { font-size: 13px; }

/* ── PRODUTO CARD ────────────────────────── */
.produto-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  transition: box-shadow .15s;
}

.produto-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.07); }

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .5rem;
}

.card-nome {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
}

.card-status {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.card-status.ativo { background: var(--green-bg); color: var(--green); }
.card-status.pausado { background: var(--bg); color: var(--text-3); }

.card-meta { font-size: 12px; color: var(--text-2); display: flex; flex-direction: column; gap: 3px; }
.card-meta span { display: flex; align-items: center; gap: 5px; }

.card-plats { display: flex; gap: 5px; flex-wrap: wrap; }

.ptag {
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
}

.ptag.ig-feed    { background: #fce8f3; color: #a0286e; }
.ptag.ig-reels   { background: #ede8fc; color: #5a28a0; }
.ptag.ig-stories { background: #fef3e8; color: #a06828; }
.ptag.fb         { background: #e8f0fc; color: #1a4ba0; }

.card-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: .25rem; }

.card-btn {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all .15s;
}

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

/* ── AGENDA ──────────────────────────────── */
.agenda-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.agenda-dia {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.agenda-dia-header {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
}

.agenda-dia-header .dia-nome {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.agenda-dia-header .dia-data { font-size: 12px; color: var(--text-3); }

.agenda-itens { display: flex; flex-direction: column; }

.agenda-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}

.agenda-item:last-child { border-bottom: none; }

.agenda-hora { font-weight: 500; color: var(--text); min-width: 46px; font-size: 12.5px; }
.agenda-plat { min-width: 80px; }
.agenda-prod { color: var(--text-2); flex: 1; }

/* ── HISTÓRICO ───────────────────────────── */
.stats-inline {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.stat-item { text-align: right; }
.stat-item strong { display: block; font-size: 20px; font-weight: 600; color: var(--text); }
.stat-item span { font-size: 11px; color: var(--text-3); }
.stat-item.success strong { color: var(--green); }
.stat-item.danger strong { color: var(--red); }

.hist-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.hist-row {
  display: grid;
  grid-template-columns: 140px 1fr 120px 90px;
  align-items: center;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
  gap: 1rem;
}

.hist-row:last-child { border-bottom: none; }
.hist-row.header { background: var(--bg); font-weight: 500; font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.hist-data { color: var(--text-2); font-size: 12px; }
.hist-nome { font-weight: 500; color: var(--text); }
.hist-plats { display: flex; gap: 4px; flex-wrap: wrap; }

.hist-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 20px;
}

.hist-badge.ok { background: var(--green-bg); color: var(--green); }
.hist-badge.erro { background: var(--red-bg); color: var(--red); }

/* ── CONFIG ──────────────────────────────── */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.config-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}

.config-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: .25rem;
}

.config-card-header h3 {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.config-card-header svg { stroke: var(--orange); flex-shrink: 0; }

.config-desc { font-size: 12.5px; color: var(--text-2); line-height: 1.5; }

.config-card label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-top: .25rem;
}

.config-card input[type="text"],
.config-card input[type="url"],
.config-card input[type="password"],
.config-card input[type="time"],
.config-card select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}

.config-card input:focus,
.config-card select:focus { border-color: var(--orange); background: #fff; }

.config-link {
  font-size: 12px;
  color: var(--orange);
  text-decoration: none;
  margin-top: .25rem;
}

.config-link:hover { text-decoration: underline; }

/* Horários */
.horarios { display: flex; flex-direction: column; gap: .5rem; margin-top: .25rem; }

.horario-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}

.horario-row input[type="time"] {
  width: 110px !important;
  flex-shrink: 0;
}

/* Toggles */
.toggles { display: flex; flex-direction: column; gap: 0; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border-soft);
}

.toggle-row:last-child { border-bottom: none; }

.toggle-info span { display: block; font-size: 13px; color: var(--text); }
.toggle-info small { font-size: 11.5px; color: var(--text-3); }

.toggle {
  width: 36px; height: 20px;
  border-radius: 10px;
  background: var(--border);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s;
}

.toggle::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.toggle.on { background: var(--orange); }
.toggle.on::after { left: 19px; }

.config-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.config-feedback {
  font-size: 13px;
  color: var(--green);
  opacity: 0;
  transition: opacity .3s;
}

.config-feedback.show { opacity: 1; }

/* ── MODAL ───────────────────────────────── */
.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-bg.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  animation: modalIn .2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(12px); }
  to { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.modal-header h2 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 17px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-3);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background .15s;
}

.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body { padding: 1.25rem; display: flex; flex-direction: column; gap: .85rem; }

.field-group { display: flex; flex-direction: column; gap: 5px; }

.field-group label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
}

.field-group label em { font-style: normal; color: var(--text-3); font-weight: 400; }

.field-group input[type="text"],
.field-group input[type="url"],
.field-group textarea,
.field-group select {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color .15s;
  width: 100%;
}

.field-group input:focus,
.field-group textarea:focus,
.field-group select:focus { border-color: var(--orange); background: #fff; }

.field-group textarea { resize: vertical; }
.field-group small { font-size: 11.5px; color: var(--text-3); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.check-pills { display: flex; gap: 7px; flex-wrap: wrap; }

.check-pill input { display: none; }

.check-pill span {
  display: inline-block;
  padding: 5px 13px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}

.check-pill input:checked + span {
  background: var(--orange-light);
  border-color: var(--orange);
  color: var(--orange);
  font-weight: 500;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-soft);
  position: sticky;
  bottom: 0;
  background: var(--surface);
}

/* ── TOAST ───────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: all .25s;
  z-index: 999;
  white-space: nowrap;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

/* ── RESPONSIVE ──────────────────────────── */
@media (max-width: 700px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 1rem; }
  .hist-row { grid-template-columns: 1fr 1fr; }
  .hist-row.header .hist-data,
  .hist-row .hist-data { display: none; }
}
