/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #2563eb;
  --blue-dark: #1e3a5f;
  --blue-light: #eff6ff;
  --green: #10b981;
  --purple: #8b5cf6;
  --orange: #f59e0b;
  --red: #ef4444;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --white: #ffffff;
  --sidebar-w: 256px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
}

body { font-family: 'Inter', system-ui, sans-serif; color: var(--text); background: var(--bg); }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ===== LAYOUT ===== */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 200;
  transition: transform .25s ease;
}

.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.logo {
  display: flex; align-items: center; gap: .5rem;
  font-size: 1.1rem; color: var(--text);
}
.logo i { color: var(--blue); font-size: 1.3rem; }
.logo strong { color: var(--blue); }

.sidebar-close { display: none; padding: .25rem .5rem; color: var(--text-muted); font-size: 1.1rem; }

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

.nav-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .625rem .875rem; border-radius: 8px;
  color: var(--text-muted); font-size: .875rem; font-weight: 500;
  transition: all .15s;
  position: relative;
}
.nav-item:hover { background: var(--blue-light); color: var(--blue); }
.nav-item.active { background: var(--blue-light); color: var(--blue); }
.nav-item i { width: 18px; text-align: center; font-size: .95rem; }
.nav-logout { color: var(--red); }
.nav-logout:hover { background: #fff1f2; color: var(--red); }

.badge-new {
  margin-left: auto; font-size: .65rem; font-weight: 700;
  background: var(--red); color: #fff;
  padding: 2px 7px; border-radius: 20px;
}

.sidebar-footer { padding: .75rem; border-top: 1px solid var(--border); }
.divider-label { font-size: .65rem; font-weight: 700; color: var(--text-muted); letter-spacing: .08em; padding: .5rem .875rem .25rem; }

.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 60px;
  display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 100;
}
.topbar-title { font-weight: 700; font-size: 1rem; color: var(--text); flex: 1; }
.menu-toggle { display: none; padding: .5rem; color: var(--text-muted); font-size: 1.1rem; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }

.user-chip {
  display: flex; align-items: center; gap: .5rem;
  padding: .35rem .75rem; background: var(--bg); border-radius: 100px;
  font-size: .8rem;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .75rem;
}
.user-name { font-weight: 600; }
.user-plan {
  font-size: .65rem; font-weight: 700; padding: 2px 7px; border-radius: 20px;
  text-transform: uppercase;
}
.plan-pro { background: #dbeafe; color: var(--blue); }
.plan-free { background: #f1f5f9; color: var(--text-muted); }
.plan-business { background: #d1fae5; color: #059669; }
.plan-enterprise { background: #ede9fe; color: var(--purple); }

.btn-icon { padding: .4rem .5rem; color: var(--text-muted); border-radius: 6px; transition: all .15s; }
.btn-icon:hover { background: var(--bg); color: var(--text); }

/* ===== CONTENT ===== */
.content-wrapper { padding: 1.5rem; flex: 1; }

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: .95rem; font-weight: 700; color: var(--text); }

/* ===== STATS GRID ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex; align-items: flex-start; gap: 1rem;
  box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.stat-icon {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.stat-blue .stat-icon { background: var(--blue-light); color: var(--blue); }
.stat-green .stat-icon { background: #d1fae5; color: var(--green); }
.stat-purple .stat-icon { background: #ede9fe; color: var(--purple); }
.stat-orange .stat-icon { background: #fef3c7; color: var(--orange); }

.stat-info { flex: 1; }
.stat-value { font-size: 1.5rem; font-weight: 800; color: var(--text); line-height: 1.2; }
.stat-label { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

.stat-trend {
  font-size: .7rem; font-weight: 600; padding: 3px 8px; border-radius: 100px;
  position: absolute; top: .75rem; right: .75rem;
}
.stat-trend.up { background: #d1fae5; color: #059669; }
.stat-trend.down { background: #fee2e2; color: var(--red); }
.stat-trend.neutral { background: #f1f5f9; color: var(--text-muted); }

/* ===== ROW TWO ===== */
.row-two { display: grid; grid-template-columns: 1fr 280px; gap: 1.25rem; margin-bottom: 1.25rem; }

.chart-card .card-header { border-bottom: 1px solid var(--border); }
.chart-container { padding: 1.25rem; height: 240px; }

.chart-filters { display: flex; gap: 4px; }
.filter-btn {
  padding: 4px 10px; border-radius: 6px; font-size: .75rem; font-weight: 600;
  color: var(--text-muted); background: var(--bg); border: 1px solid var(--border);
  transition: all .15s;
}
.filter-btn.active, .filter-btn:hover { background: var(--blue); color: #fff; border-color: var(--blue); }

.sub-card { display: flex; flex-direction: column; }
.sub-info { padding: 1.25rem; display: flex; flex-direction: column; gap: .75rem; }
.sub-plan-badge {
  display: inline-block; padding: .35rem .875rem;
  background: var(--blue); color: #fff;
  border-radius: 100px; font-weight: 700; font-size: .85rem; width: fit-content;
}
.sub-plan-badge.lg { font-size: 1rem; padding: .5rem 1.25rem; }

.sub-status { display: flex; align-items: center; gap: .4rem; font-size: .8rem; font-weight: 600; }
.sub-status.status-active { color: var(--green); }
.sub-status.status-inactive { color: var(--text-muted); }
.sub-status i { font-size: .5rem; }

.sub-detail { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; }
.sub-label { color: var(--text-muted); }

.sub-empty { padding: 2rem; text-align: center; }
.sub-empty i { font-size: 2.5rem; color: #cbd5e1; margin-bottom: .75rem; }
.sub-empty p { color: var(--text-muted); font-size: .85rem; margin-bottom: 1rem; }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.data-table th {
  padding: .75rem 1rem; text-align: left;
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); background: var(--bg); border-bottom: 1px solid var(--border);
}
.data-table td { padding: .875rem 1rem; border-bottom: 1px solid var(--border); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }

.source-tag {
  padding: 3px 10px; background: var(--blue-light); color: var(--blue);
  border-radius: 100px; font-size: .72rem; font-weight: 600;
}
.status-pill {
  padding: 3px 10px; border-radius: 100px; font-size: .72rem; font-weight: 600;
}
.status-pill.status-active { background: #d1fae5; color: #059669; }
.status-pill.status-paused { background: #fef3c7; color: #d97706; }

.btn-icon-sm {
  padding: .3rem .5rem; border-radius: 6px; font-size: .8rem;
  color: var(--text-muted); background: var(--bg); border: 1px solid var(--border);
  margin-right: 4px; transition: all .15s;
}
.btn-icon-sm:hover { color: var(--blue); border-color: var(--blue); }
.btn-icon-sm.danger:hover { color: var(--red); border-color: var(--red); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem 1rem; border-radius: 8px;
  font-size: .875rem; font-weight: 600;
  transition: all .15s; cursor: pointer; border: none;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-outline { border: 1.5px solid var(--border); color: var(--text); background: var(--white); }
.btn-outline:hover { border-color: var(--blue); color: var(--blue); }
.btn-block { display: flex; width: 100%; justify-content: center; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.mt-16 { margin-top: 1rem; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .8rem; font-weight: 600; color: var(--text); margin-bottom: .35rem; }
.input-icon { position: relative; }
.input-icon i { position: absolute; left: .875rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: .85rem; }
.input-icon input {
  width: 100%; padding: .65rem .875rem .65rem 2.5rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .9rem; font-family: inherit; color: var(--text);
  background: var(--white); transition: border-color .15s;
}
.input-icon input:focus { outline: none; border-color: var(--blue); }
.input-icon input:disabled { background: var(--bg); color: var(--text-muted); }

/* ===== ALERTS ===== */
.alert {
  padding: .75rem 1rem; border-radius: 8px; font-size: .85rem; font-weight: 500;
  display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem;
}
.alert-error { background: #fee2e2; color: #dc2626; }
.alert-success { background: #d1fae5; color: #059669; }

/* ===== AUTH ===== */
.auth-body { min-height: 100vh; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-container { width: 100%; max-width: 420px; }
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow); }
.auth-title { font-size: 1.4rem; font-weight: 800; color: var(--text); }
.auth-sub { color: var(--text-muted); font-size: .875rem; margin: .35rem 0 1.25rem; }
.auth-link { text-align: center; font-size: .875rem; color: var(--text-muted); margin-top: 1.25rem; }
.auth-link a { color: var(--blue); font-weight: 600; }
.auth-hint { text-align: center; margin-top: .5rem; color: var(--text-muted); }
.auth-back { display: flex; align-items: center; gap: .5rem; justify-content: center; margin-top: 1.25rem; font-size: .85rem; color: var(--text-muted); }
.auth-back:hover { color: var(--blue); }

/* ===== SUB DETAIL ===== */
.sub-detail-card { padding: 1.5rem; }
.sub-detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1.5rem; }
.sub-details-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.detail-item { background: var(--bg); border-radius: 8px; padding: .875rem 1rem; }
.detail-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; margin-bottom: .25rem; display: block; }
.detail-item strong { font-size: .95rem; }

.empty-state { padding: 3rem; text-align: center; }

/* ===== FAQ ===== */
.faq-item {
  border: 1px solid var(--border); border-radius: 10px; margin-bottom: .75rem;
  overflow: hidden; cursor: pointer;
}
.faq-q {
  padding: 1rem 1.25rem; display: flex; justify-content: space-between; align-items: center;
  font-weight: 600; font-size: .9rem; color: var(--text);
}
.faq-icon { transition: transform .2s; color: var(--text-muted); }
.faq-a { padding: 0 1.25rem; max-height: 0; overflow: hidden; transition: all .25s; font-size: .875rem; color: var(--text-muted); }
.faq-item.open .faq-icon { transform: rotate(180deg); }
.faq-item.open .faq-a { max-height: 200px; padding: .75rem 1.25rem 1rem; }

/* ===== WHATSAPP FLOAT ===== */
.wpp-float {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  width: 52px; height: 52px; border-radius: 50%;
  background: #25D366; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; box-shadow: 0 4px 16px rgba(37, 211, 102, .4);
  z-index: 999; transition: transform .2s;
}
.wpp-float:hover { transform: scale(1.1); }

/* ===== CAMPANHAS ===== */
.page-hero { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.page-title { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.breadcrumb { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--text-muted); margin-bottom: 1.25rem; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--blue); }

.search-bar-wrap { margin-bottom: 1rem; }
.search-input { position: relative; }
.search-input i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-input input { width: 100%; padding: .75rem 1rem .75rem 2.75rem; border-radius: 100px; border: 1.5px solid var(--border); font-size: .9rem; font-family: inherit; background: var(--white); }
.search-input input:focus { outline: none; border-color: var(--blue); }

.filter-tabs { display: flex; flex-wrap: wrap; gap: .5rem; padding: .875rem 1.25rem; margin-bottom: 1rem; }
.ftab { font-size: .875rem; font-weight: 600; color: var(--text-muted); padding: .375rem .75rem; border-radius: 6px; transition: all .15s; }
.ftab:hover { color: var(--blue); }
.ftab.active { color: var(--blue); border-bottom: 2px solid var(--blue); }

.camp-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1rem; box-shadow: var(--shadow); overflow: hidden; }
.camp-top { padding: 1.25rem 1.25rem .75rem; }
.camp-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 700; margin-bottom: .25rem; }
.camp-name { font-size: 1rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: .5rem; }
.camp-toggle { font-size: .75rem; color: var(--text-muted); cursor: pointer; transition: transform .2s; }
.camp-url { font-size: .8rem; color: var(--blue); margin-top: .2rem; }

.camp-actions { display: flex; flex-wrap: wrap; gap: .625rem; padding: .625rem 1.25rem 1rem; }
.btn-iniciar { padding: .5rem 1rem; border-radius: 8px; font-size: .875rem; font-weight: 600; }

.camp-details { max-height: 0; overflow: hidden; transition: max-height .3s ease; background: var(--bg); }
.camp-details.open { max-height: 400px; }
.camp-detail-row { display: flex; justify-content: space-between; align-items: center; padding: .625rem 1.25rem; border-top: 1px solid var(--border); font-size: .875rem; }
.cd-label { color: var(--text-muted); }
.cd-val { font-weight: 600; }

.status-badge { padding: .25rem .75rem; border-radius: 100px; font-size: .75rem; font-weight: 700; }
.status-badge.status-active { background: #d1fae5; color: #059669; }
.status-badge.status-paused { background: #fef3c7; color: #d97706; }
.status-badge.status-inactive { background: #fee2e2; color: var(--red); }

/* FORM CAMPANHA */
.form-section { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.form-section-title { font-size: 1.1rem; font-weight: 800; color: #1e3a5f; margin-bottom: 1.25rem; }

.form-section input[type="text"],
.form-section input[type="url"],
.form-section input[type="number"],
.form-section input[type="email"],
.form-section select,
.form-section textarea {
  width: 100%; padding: .65rem .875rem;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .9rem; font-family: inherit; color: var(--text);
  background: var(--white); transition: border-color .15s;
}
.form-section input:focus,
.form-section select:focus,
.form-section textarea:focus { outline: none; border-color: var(--blue); }
.form-section input:disabled { background: var(--bg); color: var(--text-muted); }
.form-section textarea { resize: vertical; }
.form-section label { display: block; font-size: .85rem; font-weight: 600; color: var(--text); margin-bottom: .35rem; }

.field-hint { display: block; font-size: .78rem; color: var(--text-muted); margin-top: .35rem; line-height: 1.5; }
.field-warn { color: #dc2626; }

/* Sliders */
.slider-wrap { display: flex; flex-direction: column; gap: .3rem; }
.slider-val { font-size: 1rem; font-weight: 700; color: var(--text); }
.slider-val-sm { font-size: .8rem; font-weight: 700; color: var(--blue); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px;
  background: #e2e8f0; border-radius: 100px; outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: #1e3a5f; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
input[type="range"]:disabled { opacity: .5; cursor: not-allowed; }

/* Toggle switch */
.toggle-group { display: flex; flex-direction: column; gap: .35rem; }
.toggle-title-above { font-size: .85rem; font-weight: 600; color: var(--text); }
.toggle-label { display: flex; align-items: flex-start; gap: .75rem; cursor: pointer; }
.toggle-switch { position: relative; flex-shrink: 0; margin-top: 2px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  display: block; width: 44px; height: 24px;
  background: var(--border); border-radius: 100px; transition: background .2s;
  position: relative;
}
.toggle-track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: left .2s;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.toggle-switch input:checked + .toggle-track { background: var(--blue); }
.toggle-switch input:checked + .toggle-track::after { left: 23px; }

/* Geolocalização */
.geo-row { display: flex; align-items: center; gap: .625rem; margin-bottom: .5rem; }
.geo-select { flex: 1; }
.geo-pct { width: 70px !important; }
.geo-sep { color: var(--text-muted); }
.btn-trash { padding: .4rem .65rem; border: 1.5px solid var(--red); border-radius: 7px; color: var(--red); background: #fff5f5; cursor: pointer; font-size: .85rem; transition: all .15s; }
.btn-trash:hover { background: var(--red); color: #fff; }

/* Variação semanal */
.weekly-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: .75rem; }
.weekly-day { display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.weekly-label { font-size: .72rem; font-weight: 700; color: var(--text-muted); }

/* Botões extras */
.btn-green { background: #16a34a; color: #fff; }
.btn-green:hover { background: #15803d; }
.btn-danger { background: var(--red); color: #fff; border: none; }
.btn-danger:hover { background: #dc2626; }

/* Footer form */
.form-footer { text-align: center; padding: 1.5rem 0 2rem; color: var(--text-muted); font-size: .85rem; }
.form-footer strong { color: var(--blue); }

/* ===== ROBO ENGINE ===== */
.row-form { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.sources-check { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.check-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .625rem; border-radius: 7px;
  font-size: .8rem; font-weight: 500; color: var(--text);
  border: 1.5px solid var(--border); cursor: pointer;
  transition: all .15s;
}
.check-item:hover { border-color: var(--blue); background: var(--blue-light); }
.check-item input { accent-color: var(--blue); }

.job-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: .875rem 1.25rem; border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.job-item:last-child { border-bottom: none; }
.job-info { flex: 1; min-width: 0; }
.job-name { font-weight: 700; font-size: .875rem; color: var(--text); margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-url { font-size: .72rem; color: var(--text-muted); margin-bottom: .35rem; }
.job-meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .75rem; color: var(--text-muted); }
.job-right { display: flex; flex-direction: column; align-items: flex-end; gap: .375rem; flex-shrink: 0; }
.job-actions { display: flex; gap: .3rem; }
.job-progress-bar { width: 120px; height: 5px; background: var(--border); border-radius: 100px; overflow: hidden; }
.job-progress-fill { height: 100%; background: var(--blue); border-radius: 100px; transition: width .5s; }

.status-pill.status-running { background: #dbeafe; color: var(--blue); }
.status-pill.status-pending { background: #fef3c7; color: #d97706; }

/* ===== MOBILE ===== */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .row-two { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-trend { display: none; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .content-wrapper { padding: 1rem; }
  .topbar { padding: 0 1rem; }
  .user-name { display: none; }
}
