/* =========================================================================
   Arca Lançamentos — Dashboard / Central de Campanhas
   Identidade visual oficial da Arca (Deep Navy + Antique Gold + Parchment).
   Self-hosted, sem CDN de CSS. Layout: sidebar fixa + área de conteúdo.
   ========================================================================= */

:root {
  /* ⭐ Cores oficiais da marca Arca ⭐ */
  --navy: #1B2A41;
  --navy-700: #223450;
  --navy-600: #2c425f;
  --gold: #C59D5F;
  --gold-700: #b08a4d;
  --parchment: #F2EFE9;
  --terracotta: #A05C45;

  --brand-gradient: linear-gradient(135deg, var(--gold), var(--terracotta));
  --navy-gradient: linear-gradient(180deg, #1B2A41 0%, #16223a 100%);

  --ink: #1B2A41;
  --muted: #6B7280;
  --line: #e7e2d8;
  --surface: #ffffff;
  --bg: var(--parchment);

  /* Estados — alinhados aos tokens oficiais da plataforma Arca */
  --ok: #10B981;
  --ok-bg: #D1FAE5;
  --warn: #F59E0B;
  --warn-bg: #FEF3C7;
  --danger: #EF4444;
  --danger-bg: #FEE2E2;
  --info: #C59D5F;         /* info = dourado da marca (era azul) */
  --info-bg: #f5ecd7;

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --shadow-sm: 0 4px 14px rgba(27, 42, 65, .07);
  --shadow-md: 0 12px 36px rgba(27, 42, 65, .12);
  --shadow-gold: 0 6px 18px rgba(197, 157, 95, .35);

  --sidebar-w: 256px;
  /* Tipografia oficial da marca Arca: Lato (corpo) + Playfair Display (títulos) */
  --font: 'Lato', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: 'Playfair Display', Georgia, 'Times New Roman', serif;

  /* Escala tipográfica modular — 16px base, razão 1.25 (Major Third) */
  --text-xs: 0.75rem;  --text-sm: 0.875rem; --text-base: 1rem;  --text-lg: 1.125rem;
  --text-xl: 1.25rem;  --text-2xl: 1.563rem; --text-3xl: 1.953rem; --text-4xl: 2.441rem;
  --text-5xl: 3.052rem; --text-6xl: 3.815rem;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: var(--text-sm, 0.875rem);
  line-height: 1.55;
}

a { color: var(--terracotta); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-family: var(--font-serif); color: var(--navy); margin: 0 0 .4em; font-weight: 700; letter-spacing: -.01em; }

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

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--navy-gradient);
  color: #cdd6e4;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  border-right: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 22px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.sidebar-brand .mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--brand-gradient);
  display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: var(--text-lg, 1.125rem);
  box-shadow: var(--shadow-gold);
  flex: 0 0 auto;
}
.sidebar-brand .name { color: #fff; font-weight: 700; font-size: var(--text-base, 1.0rem); line-height: 1.1; }
.sidebar-brand .name small { display: block; color: var(--gold); font-weight: 600; font-size: var(--text-xs, 0.75rem); letter-spacing: .14em; text-transform: uppercase; margin-top: 3px; }

.sidebar-nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.sidebar-nav .group-label {
  color: #67758e; font-size: var(--text-xs, 0.75rem); font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; padding: 14px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin: 2px 0;
  border-radius: 11px; color: #c2cbdb; font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--brand-gradient); color: #fff; box-shadow: var(--shadow-gold); }
.nav-item .ico { width: 20px; height: 20px; flex: 0 0 auto; opacity: .9; }
.nav-item.active .ico { opacity: 1; }

.sidebar-foot { padding: 14px 18px; border-top: 1px solid rgba(255, 255, 255, .07); font-size: var(--text-xs, 0.75rem); color: #8595ad; }
.sidebar-foot a { color: var(--gold); }

.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: rgba(255, 255, 255, .8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 16px 30px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 30;
}
.topbar .crumbs { color: var(--muted); font-size: var(--text-sm, 0.875rem); }
.topbar .crumbs a { color: var(--muted); }
.topbar h1 { font-size: var(--text-xl, 1.25rem); margin: 2px 0 0; }
.topbar .actions { display: flex; gap: 10px; align-items: center; }

.content { padding: 28px 30px 56px; max-width: 1240px; width: 100%; }

.dashboard-panels {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 1fr);
  gap: 20px;
  margin-top: 30px;
  align-items: stretch;
}
.dashboard-panels .table-card { height: 100%; display: flex; flex-direction: column; }
.dashboard-panels .data { flex: 1; }

/* ========================= Buttons ========================= */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid transparent; cursor: pointer;
  padding: 10px 18px; border-radius: 11px; font-weight: 600; font-size: var(--text-sm, 0.875rem);
  font-family: inherit; transition: all .15s ease; text-decoration: none; line-height: 1;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--brand-gradient); color: #fff; box-shadow: var(--shadow-gold); }
.btn-primary:hover { color: #fff; filter: brightness(1.04); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { color: #fff; background: var(--navy-600); }
.btn-outline { background: #fff; border-color: var(--line); color: var(--navy); }
.btn-outline:hover { border-color: var(--gold); color: var(--terracotta); }
.btn-ghost { background: transparent; color: var(--navy); }
.btn-ghost:hover { background: rgba(27, 42, 65, .06); }
.btn-danger { background: #fff; border-color: #f0c9c4; color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 7px 13px; font-size: var(--text-sm, 0.875rem); border-radius: 9px; }
.btn-lg { padding: 14px 26px; font-size: var(--text-base, 1.0rem); }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

/* ========================= Cards ========================= */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px 24px; }
.card-head {
  padding: 16px 22px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h3 { margin: 0; font-size: var(--text-base, 1.0rem); }
.card-body { padding: 22px 24px; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-bottom: 26px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 20px 22px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi::after { content: ""; position: absolute; right: -28px; top: -28px; width: 90px; height: 90px; border-radius: 50%; background: var(--brand-gradient); opacity: .07; }
.kpi .kpi-label { color: var(--muted); font-size: var(--text-xs, 0.75rem); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.kpi .kpi-value { font-size: var(--text-3xl, 1.953rem); font-weight: 800; color: var(--navy); margin: 6px 0 2px; letter-spacing: -.02em; }
.kpi .kpi-sub { font-size: var(--text-sm, 0.875rem); color: var(--muted); }
.kpi .kpi-sub.up { color: var(--ok); }
.kpi .kpi-sub.down { color: var(--danger); }
.kpi .kpi-ico { position: absolute; right: 18px; top: 18px; width: 26px; height: 26px; color: var(--gold); opacity: .9; }

/* Nav/feature cards (hub) */
.hub-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.hub-card {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 24px; box-shadow: var(--shadow-sm); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.hub-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--gold); text-decoration: none; }
.hub-card .hub-ico { width: 46px; height: 46px; border-radius: 13px; background: var(--brand-gradient); display: grid; place-items: center; color: #fff; box-shadow: var(--shadow-gold); }
.hub-card .hub-ico svg { width: 24px; height: 24px; }
.hub-card h3 { margin: 4px 0 0; font-size: var(--text-base, 1.0rem); }
.hub-card p { margin: 0; color: var(--muted); font-size: var(--text-sm, 0.875rem); }
.hub-card .hub-go { margin-top: auto; color: var(--terracotta); font-weight: 600; font-size: var(--text-sm, 0.875rem); }

/* ========================= Tables ========================= */
.table-card {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
  max-width: 100%;
}
.table-card .data,
.table-card table { width: 100%; }
.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
}
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left; font-size: var(--text-xs, 0.75rem); text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 700; padding: 13px 18px; background: #faf8f3; border-bottom: 1px solid var(--line);
}
table.data td { padding: 14px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .12s ease; }
table.data tbody tr:hover { background: #faf8f3; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-strong { font-weight: 600; color: var(--navy); }
.cell-sub { color: var(--muted); font-size: var(--text-sm, 0.875rem); }
code.slug { background: #f3efe6; border: 1px solid var(--line); padding: 2px 7px; border-radius: 6px; font-size: var(--text-sm, 0.875rem); color: var(--terracotta); }

/* ========================= Badges / pills ========================= */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; border-radius: 999px; font-size: var(--text-xs, 0.75rem); font-weight: 700; line-height: 1.3;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-info { background: var(--info-bg); color: var(--info); }
.pill-muted { background: #eef0f3; color: #5b6675; }
.pill-gold { background: #f7efdf; color: var(--gold-700); }

/* ========================= Forms ========================= */
.field-group { margin-bottom: 18px; }
.field-group > label { display: block; font-weight: 600; font-size: var(--text-sm, 0.875rem); color: var(--navy); margin-bottom: 6px; }
.field-hint { color: var(--muted); font-size: var(--text-xs, 0.75rem); margin-top: 5px; }
.field-error { color: var(--danger); font-size: var(--text-xs, 0.75rem); margin-top: 5px; }
.form-grid { display: grid; gap: 0 22px; grid-template-columns: 1fr 1fr; }
.form-grid .col-full { grid-column: 1 / -1; }

input[type=text], input[type=email], input[type=url], input[type=number],
input[type=password], input[type=datetime-local], input[type=date], select, textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  font-size: var(--text-sm, 0.875rem); font-family: inherit; background: #fff; color: var(--ink); transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(197, 157, 95, .18); }
textarea { resize: vertical; min-height: 78px; }
.checklist { display: flex; flex-direction: column; gap: 8px; }
.checklist label { display: flex; align-items: center; gap: 9px; font-weight: 500; font-size: var(--text-sm, 0.875rem); cursor: pointer; }
.checklist input[type=checkbox] { width: auto; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #cfd6e0; border-radius: 999px; transition: .2s; }
.switch .slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .slider { background: var(--ok); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ========================= Alerts / messages ========================= */
.alert { padding: 13px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 500; border: 1px solid transparent; display: flex; gap: 10px; align-items: flex-start; }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: #bfe6cd; }
.alert-error, .alert-danger { background: var(--danger-bg); color: var(--danger); border-color: #f0c9c4; }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: #f3dcae; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #c9dbff; }

/* ========================= Empty state ========================= */
.empty { text-align: center; padding: 60px 24px; color: var(--muted); }
.empty .empty-ico { width: 64px; height: 64px; border-radius: 18px; background: #f3efe6; display: grid; place-items: center; margin: 0 auto 16px; color: var(--gold); }
.empty h3 { color: var(--navy); }

/* ========================= Misc ========================= */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: var(--text-sm, 0.875rem); margin-top: 2px; }
.section-title { font-size: var(--text-base, 1.0rem); margin: 30px 0 14px; color: var(--navy); }
.flex { display: flex; } .items-center { align-items: center; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; } .ml-auto { margin-left: auto; }
.text-muted { color: var(--muted); }
.divider { height: 1px; background: var(--line); margin: 22px 0; border: 0; }

/* Toast */
.toast-wrap { position: fixed; right: 22px; bottom: 22px; z-index: 90; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow-md); font-weight: 500; animation: toastin .25s ease; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Responsive */
@media (max-width: 980px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .dashboard-panels { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-flex !important; }
  .form-grid { grid-template-columns: 1fr; }
}
.menu-toggle { display: none; }

/* ============================================================
   Builder de produto (product_edit) — drag-and-drop
   ============================================================ */
.pb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.pb-fields { display: grid; gap: 12px; padding: 16px 20px 20px; }
.pb-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pb-check { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--ink); }
.pb-content { margin-top: 26px; }
.pb-content-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.pb-content-head h2 { font-family: var(--font-serif); font-size: 1.25rem; margin: 0; color: var(--navy); }

.pb-module { margin-bottom: 14px; }
.pb-module-head { display: flex; align-items: center; gap: 12px; }
.pb-module-title { flex: 1; min-width: 0; }
.pb-module-title h3 { margin: 0; font-size: 1.05rem; }
.pb-drag { cursor: grab; color: var(--muted); font-size: 1.1rem; user-select: none; line-height: 1; }
.pb-drag:active { cursor: grabbing; }
.pb-danger { color: var(--danger) !important; }

.pb-module-edit { display: none; gap: 10px; flex-wrap: wrap; align-items: end; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--parchment); }
.pb-module-edit.open { display: flex; }
.pb-grow { flex: 1; min-width: 180px; margin: 0; }

.pb-lessons { list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.pb-lesson {
  display: grid; grid-template-columns: auto auto 1fr auto auto auto; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 10px; transition: background .12s;
}
.pb-lesson:hover { background: var(--parchment); }
.pb-lesson-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--parchment); color: var(--navy); }
.pb-lesson:hover .pb-lesson-ico { background: #fff; }
.pb-lesson-name { font-weight: 600; color: var(--ink); text-decoration: none; }
.pb-lesson-name:hover { color: var(--terracotta); }
.pb-lesson-meta { white-space: nowrap; }
.pb-lesson-drip { white-space: nowrap; }
.pb-lesson-actions { display: flex; gap: 6px; align-items: center; }
.pb-lesson-actions form { margin: 0; }
.pb-mini { font-size: 10px !important; padding: 2px 6px !important; margin-left: 6px; }
.pb-empty-lessons { padding: 14px 20px; font-size: .9rem; }
.sortable-ghost { opacity: .4; }
.sortable-chosen { box-shadow: var(--shadow-md); }

@media (max-width: 980px) {
  .pb-grid { grid-template-columns: 1fr; }
  .pb-lesson { grid-template-columns: auto auto 1fr; grid-row-gap: 4px; }
  .pb-lesson-meta, .pb-lesson-drip { grid-column: 3; }
  .pb-lesson-actions { grid-column: 1 / -1; justify-content: flex-end; }
}
