/* ============================================================
   MeuGMN — style.css
   ============================================================ */

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
button, input, select { font-family: inherit; }
a { text-decoration: none; }

/* ── CSS Variables (Light) ── */
:root {
  --primary:        #25D366;
  --primary-dark:   #128C7E;
  --primary-hover:  #1DAA52;
  --primary-light:  #D9FDD3;

  --bg-main:    #F0F2F5;
  --bg-card:    #FFFFFF;
  --bg-sidebar: #FFFFFF;
  --bg-hover:   #F5F6F7;
  --bg-input:   #F7F8FA;

  --text-primary:   #111B21;
  --text-secondary: #667781;
  --text-muted:     #8696A0;

  --border:       #E9EDEF;
  --border-input: #DDE1E7;

  --sidebar-w:   260px;
  --topbar-h:    60px;

  --status-pending:    #F59E0B;
  --status-pending-bg: #FEF3C7;
  --status-sent:       #10B981;
  --status-sent-bg:    #D1FAE5;
  --status-error:      #EF4444;
  --status-error-bg:   #FEE2E2;

  --shadow-sm: 0 1px 4px rgba(0,0,0,.07);
  --shadow:    0 2px 14px rgba(0,0,0,.09);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);

  --radius-sm:   8px;
  --radius:      12px;
  --radius-lg:   18px;
  --radius-pill: 9999px;

  --transition: all .25s ease;
}

/* ── Dark Theme ── */
[data-theme="dark"] {
  --bg-main:    #0B1014;
  --bg-card:    #1F2C34;
  --bg-sidebar: #1F2C34;
  --bg-hover:   #2A3942;
  --bg-input:   #2A3942;

  --text-primary:   #E9EDEF;
  --text-secondary: #8696A0;
  --text-muted:     #667781;

  --border:       #2A3942;
  --border-input: #3B4A54;

  --primary-light:     #1B4332;
  --status-pending-bg: #3D2B00;
  --status-sent-bg:    #003D29;
  --status-error-bg:   #3D0000;

  --shadow-sm: 0 1px 4px rgba(0,0,0,.3);
  --shadow:    0 2px 14px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.45);
}

/* ── Base ── */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  transition: background-color .3s, color .3s;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 270px;
  max-width: 360px;
  pointer-events: all;
  animation: toastIn .3s ease, toastOut .3s ease 2.7s forwards;
}
.toast.success { border-left: 4px solid var(--status-sent); }
.toast.error   { border-left: 4px solid var(--status-error); }
.toast.warning { border-left: 4px solid var(--status-pending); }
.toast.info    { border-left: 4px solid var(--primary); }
.toast-msg { flex: 1; font-size: .875rem; color: var(--text-primary); }

@keyframes toastIn  { from { transform: translateX(110%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(110%); } }

/* ============================================================
   LOGIN
   ============================================================ */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-main);
  padding: 20px;
  position: relative;
}

#loginThemeToggle {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 100;
}

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

.login-logo {
  text-align: center;
  margin-bottom: 36px;
}
.logo-icon {
  font-size: 3.2rem;
  display: block;
  margin-bottom: 12px;
}
.login-logo h1 {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: -.5px;
}
.login-logo p {
  font-size: .875rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

@keyframes shake {
  0%,100% { transform: none; }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-5px); }
  80%      { transform: translateX(5px); }
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 20px; }

.form-group label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 1rem;
  outline: none;
  transition: var(--transition);
  -webkit-appearance: none;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(37,211,102,.15);
}
.form-group input::placeholder { color: var(--text-muted); }

.form-hint {
  display: block;
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Password wrapper */
.password-wrapper { position: relative; }
.password-wrapper input { padding-right: 48px; }
.password-toggle {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer; font-size: 1.1rem;
  opacity: .55; transition: opacity .2s;
}
.password-toggle:hover { opacity: 1; }
[data-theme="dark"] .password-toggle { color: #667781; }

/* Login screen: input focus with #128C7E border */
.login-view .form-group input:focus {
  border-color: #128C7E;
  box-shadow: 0 0 0 3px rgba(18,140,126,.15);
}

/* Input with prefix */
.input-with-prefix {
  display: flex;
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  overflow: hidden;
  transition: var(--transition);
}
.input-with-prefix:focus-within {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(37,211,102,.15);
}
.input-prefix {
  padding: 12px 14px;
  background: var(--border);
  color: var(--text-secondary);
  font-size: .875rem;
  white-space: nowrap;
  border-right: 1.5px solid var(--border-input);
  user-select: none;
}
.input-with-prefix input {
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  flex: 1;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 8px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.btn:disabled { opacity: .65; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37,211,102,.35);
}

#loginBtn {
  background: #128C7E;
}
#loginBtn:hover:not(:disabled) {
  background: #0e7269;
  box-shadow: 0 4px 14px rgba(18,140,126,.35);
}

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-full   { width: 100%; padding: 14px; font-size: 1rem; margin-top: 8px; }
.btn-sm     { padding: 6px 14px; font-size: .8rem; }
.btn-icon   {
  width: 34px; height: 34px; padding: 0;
  border: none; border-radius: var(--radius-sm);
  background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: var(--text-secondary);
  transition: var(--transition);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── WhatsApp global status indicator (header) ── */
.wa-global-btn {
  position: relative;
  width: 40px; height: 40px;
  border: none; border-radius: var(--radius-pill);
  background: var(--bg-hover);
  font-size: 1.2rem;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.wa-global-btn:hover { background: var(--border); transform: scale(1.1); }

.wa-global-dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 2px solid var(--bg-card);
  background: var(--text-muted);
}
.wa-global-dot.connected    { background: var(--status-sent); }
.wa-global-dot.disconnected { background: var(--status-error); animation: waBlink 1.2s infinite; }

/* ── WhatsApp badge (sidebar nav) ── */
.wa-nav-badge {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--status-error);
  margin-left: auto;
  flex-shrink: 0;
  animation: waBlink 1.2s infinite;
}

/* ── Theme toggle ── */
.theme-toggle-btn {
  width: 40px; height: 40px;
  border: none; border-radius: var(--radius-pill);
  background: var(--bg-hover);
  color: var(--text-primary);
  cursor: pointer; font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.theme-toggle-btn:hover { background: var(--border); transform: scale(1.1); }
[data-theme="dark"] .theme-toggle-btn { color: #677781; }
[data-theme="dark"] .logo-icon-sm { color: #677781; }

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app-view { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 1000;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  box-shadow: var(--shadow);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo { display: flex; align-items: center; gap: 10px; }
.logo-icon-sm { font-size: 1.5rem; }
.sidebar-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.sidebar-close-btn {
  display: none;
  background: none; border: none;
  cursor: pointer; font-size: 1rem;
  color: var(--text-secondary);
  padding: 6px; border-radius: var(--radius-sm);
  transition: var(--transition);
}
.sidebar-close-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Nav ── */
.sidebar-nav {
  flex: 1;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

/* Section grouping (like reference image) */
.nav-section {
  margin-top: 8px;
}

.nav-section-title {
  display: block;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: 10px 16px 5px;
  user-select: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: .875rem;
  font-weight: 500;
  transition: var(--transition);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 700;
}
.nav-icon { font-size: 1.05rem; width: 22px; text-align: center; flex-shrink: 0; }

/* ── Sidebar footer ── */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 36px; height: 36px;
  border-radius: var(--radius-pill);
  background: #118C7E;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem;
  flex-shrink: 0;
  overflow: hidden;
}
.user-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: var(--radius-pill);
}
.user-details { display: flex; flex-direction: column; min-width: 0; }
.user-name {
  font-size: .875rem; font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role { font-size: .75rem; color: var(--text-muted); }

.btn-logout {
  background: none; border: none;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: var(--text-secondary);
  cursor: pointer; transition: var(--transition); flex-shrink: 0;
}
.btn-logout:hover { background: var(--status-error-bg); color: var(--status-error); }

/* ── Sidebar Overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ── Main content ── */
.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Top bar ── */
.top-bar {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none; border: none;
  cursor: pointer; padding: 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.hamburger-btn:hover { background: var(--bg-hover); }
.hamburger-btn span {
  display: block; width: 22px; height: 2px;
  background: var(--text-primary);
  border-radius: 2px; transition: var(--transition);
}

.page-title { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); flex: 1; }
.top-bar-actions { display: flex; align-items: center; gap: 8px; }

/* ── Page content ── */
.page-content { flex: 1; padding: 24px; }
.page { display: none; }
.page.active { display: block; animation: fadeUp .25s ease; }

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

/* ============================================================
   STATS GRID
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stats-grid.stats-grid-2col {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-icon {
  width: 50px; height: 50px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; flex-shrink: 0;
}
.stat-icon.total   { background: #EEF2FF; color: #6366f1; }
.stat-icon.pending { background: var(--status-pending-bg); color: var(--status-pending); }
.stat-icon.sent    { background: var(--status-sent-bg);    color: var(--status-sent); }
.stat-icon.error   { background: var(--status-error-bg);   color: var(--status-error); }

.stat-info { display: flex; flex-direction: column; min-width: 0; }
.stat-value {
  font-size: 1.9rem; font-weight: 800;
  color: var(--text-primary); line-height: 1;
}
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: 5px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 20px;
}
.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-header h3 { font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.card-body { padding: 20px; }
.card-body.p0 { padding: 0; }

.contact-count {
  font-size: .8rem; color: var(--text-muted);
  background: var(--bg-hover);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--bg-card);
  padding: 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.tab {
  flex: 1;
  padding: 10px 10px;
  border: none; border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: .82rem; font-weight: 500;
  cursor: pointer; transition: var(--transition);
  white-space: nowrap;
}
.tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.tab.active {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(37,211,102,.3);
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeUp .2s ease; }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrapper { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.data-table th {
  padding: 11px 16px;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--bg-hover);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table th { position: relative; }

/* ── Tooltip no cabeçalho da tabela ── */
.th-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px; height: 14px;
  margin-left: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  color: var(--bg-card);
  font-size: .6rem;
  font-weight: 800;
  line-height: 1;
  cursor: default;
  position: relative;
  vertical-align: middle;
  text-transform: none;
  letter-spacing: 0;
}
.th-info::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: var(--bg-card);
  font-size: .75rem;
  font-weight: 400;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  max-width: 220px;
  white-space: normal;
  width: max-content;
  max-width: 200px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
.th-info:hover::after { opacity: 1; }
.th-sortable { cursor: pointer; user-select: none; }
.th-sortable:hover { color: var(--primary); }
.th-sort-icon { margin-left: 4px; opacity: .3; font-size: .7rem; }
.th-sort-icon.active { opacity: 1; color: var(--primary); }
.data-table td {
  padding: 13px 16px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .15s; }
.data-table tbody tr:hover { background: var(--bg-hover); }

/* ── Status badges ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: .73rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-pendente { background: var(--status-pending-bg); color: var(--status-pending); }
.status-enviado  { background: var(--status-sent-bg);    color: var(--status-sent); }
.status-erro     { background: var(--status-error-bg);   color: var(--status-error); }

/* Badge com largura fixa — usado na coluna Status da tabela */
.status-badge-fixed {
  width: 120px;
  justify-content: flex-start;
  box-sizing: border-box;
}

/* ── Status select (inline) ── */
.status-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 120px;
}
.status-select-wrap::before {
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  left: 9px;
  font-size: .7rem;
  pointer-events: none;
  z-index: 1;
}
.status-select-wrap.wrap-pendente::before {
  content: "\f017";
  color: var(--status-pending);
}
.status-select-wrap.wrap-erro::before {
  content: "\f057";
  color: var(--status-error);
}
.status-select-wrap .status-select {
  padding-left: 26px;
  width: 100%;
}

.status-select {
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  font-size: .73rem;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: var(--transition);
  outline: none;
}
.status-select-pendente { background: var(--status-pending-bg); color: var(--status-pending); }
.status-select-enviado  { background: var(--status-sent-bg);    color: var(--status-sent); }
.status-select-erro     { background: var(--status-error-bg);   color: var(--status-error); }
.status-select:hover { opacity: .85; }

/* ============================================================
   TEMPLATE BANNER
   ============================================================ */
.template-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg-hover);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.template-banner-text {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.template-banner-icon { font-size: 1.6rem; flex-shrink: 0; color: #217346; }

.template-banner-text div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.template-banner-text strong {
  font-size: .875rem;
  color: var(--text-primary);
}

.template-banner-text span {
  font-size: .8rem;
  color: var(--text-muted);
}

/* ============================================================
   UPLOAD AREA
   ============================================================ */
.upload-area {
  border: 2px dashed var(--border-input);
  border-radius: var(--radius);
  padding: 44px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-hover);
}
.upload-area:hover,
.upload-area.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-icon { font-size: 2.8rem; display: block; margin-bottom: 12px; color: var(--primary); }
.upload-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.upload-hint { font-size: .8rem; color: var(--text-muted); line-height: 1.7; }

/* ── Import preview ── */
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 0 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.preview-header h4 { font-size: .95rem; font-weight: 600; color: var(--text-primary); }
.preview-actions { display: flex; gap: 8px; }

/* ============================================================
   SEARCH & FILTER
   ============================================================ */
.list-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  flex: 1;
  min-width: 200px;
  transition: var(--transition);
}
.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,211,102,.15);
}
.search-icon { font-size: .9rem; color: var(--text-muted); flex-shrink: 0; }
.search-box input {
  border: none; background: transparent; outline: none;
  font-size: .875rem; color: var(--text-primary); width: 100%;
}
.search-box input::placeholder { color: var(--text-muted); }

.filter-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-btn {
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-secondary);
  font-size: .78rem; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  white-space: nowrap;
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 52px 24px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 2.8rem; display: block; margin-bottom: 12px; opacity: .45; }
.empty-state p { font-size: .9rem; line-height: 1.7; }
.empty-state a { color: var(--primary); font-weight: 600; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}
.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-input);
  background: var(--bg-card);
  color: var(--text);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.pagination-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}
.pagination-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.pagination-btn:disabled {
  opacity: .35;
  cursor: default;
}
.pagination-ellipsis {
  color: var(--text-muted);
  font-size: .85rem;
  padding: 0 4px;
}

/* ============================================================
   DIAGNÓSTICO IA
   ============================================================ */
.diagnostico-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.diagnostico-section { display: flex; flex-direction: column; gap: 8px; }
.diagnostico-section-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 4px;
}
.diagnostico-section-title.positivo { color: var(--status-sent); }
.diagnostico-section-title.negativo { color: var(--status-error); }
.diagnostico-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: .875rem;
  line-height: 1.5;
  color: var(--text);
}
.diagnostico-item i { flex-shrink: 0; margin-top: 3px; font-size: .8rem; }
.diagnostico-conclusao {
  margin-top: 4px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--border);
  font-size: .875rem;
  line-height: 1.7;
  color: var(--text);
}
.diagnostico-conclusao-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.diagnostico-footer {
  margin-top: 16px;
  font-size: .75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
@media (max-width: 768px) {
  .diagnostico-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   CHART CONTAINER
   ============================================================ */
.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
}

/* ============================================================
   CONTACT FORM
   ============================================================ */
.contact-form { max-width: 100%; }

/* Nacional / Internacional toggle */
.contact-type-toggle {
  display: flex;
  gap: 0;
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius);
  overflow: hidden;
  width: 100%;
}
.type-btn {
  flex: 1;
  padding: 10px 16px;
  font-size: .875rem;
  font-weight: 500;
  border: none;
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}
.type-btn:first-child {
  border-right: 1.5px solid var(--border-input);
}
.type-btn.active {
  background: var(--primary);
  color: #fff;
}
.type-btn:not(.active):hover {
  background: var(--border);
  color: var(--text);
}


/* ============================================================
   MESSAGE CONFIG PAGE
   ============================================================ */
.msg-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.msg-preview-full {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.msg-config-hint {
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.5;
}
.msg-config-hint code {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: .8rem;
  color: var(--primary-dark);
  font-family: monospace;
}

.msg-textarea {
  width: 100%;
  min-height: 200px;
  padding: 14px 16px;
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: .95rem;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: var(--transition);
}
.msg-textarea:focus {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(37,211,102,.15);
}
.msg-textarea::placeholder { color: var(--text-muted); }

.msg-config-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ── WhatsApp-style preview bubble ── */
.msg-preview-label {
  font-size: .75rem;
  color: var(--text-muted);
}

.msg-preview-bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.msg-preview-bubble {
  background: var(--primary-light);
  border-radius: 12px 2px 12px 12px;
  padding: 12px 16px;
  max-width: 100%;
  font-size: .9rem;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 52px;
  width: 100%;
  box-shadow: var(--shadow-sm);
}

.msg-preview-empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: .82rem;
}

.msg-preview-time {
  font-size: .7rem;
  color: var(--text-muted);
  padding-right: 2px;
}

/* ── Variables ── */
.msg-vars {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.msg-var-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: .875rem;
  color: var(--text-secondary);
}
.msg-var-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--text-primary);
}

.msg-var-tag {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: .8rem;
  color: var(--primary-dark);
  font-family: monospace;
  white-space: nowrap;
}
.msg-var-item:hover .msg-var-tag {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.msg-var-hint {
  font-size: .75rem;
  color: var(--text-muted);
}

/* ============================================================
   WHATSAPP PAGE
   ============================================================ */
.wa-page-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;        /* ambos os cards com a mesma altura */
  gap: 20px;
  max-width: 860px;
}

/* Faz o card ocupar 100% da célula do grid */
.wa-card-equal {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;            /* remove margin padrão do .card dentro do grid */
}

/* Body do card de status cresce para preencher o espaço */
.wa-card-body-flex {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Empurra os botões para o fundo do card */
.wa-btn-group {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Botão ocupa largura total */
.wa-btn-full { width: 100%; justify-content: center; }

/* ── Status badge ── */
.wa-status-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  border: 1.5px solid;
  font-size: .95rem;
  font-weight: 700;
  transition: var(--transition);
}
.wa-status-badge.disconnected {
  background: var(--status-error-bg);
  border-color: var(--status-error);
  color: var(--status-error);
}
.wa-status-badge.connecting {
  background: #EFF6FF;
  border-color: #3B82F6;
  color: #1D4ED8;
}
[data-theme="dark"] .wa-status-badge.connecting {
  background: #1E3A5F;
  border-color: #3B82F6;
  color: #93C5FD;
}
.wa-status-badge.waiting {
  background: var(--status-pending-bg);
  border-color: var(--status-pending);
  color: var(--status-pending);
}
.wa-status-badge.connected {
  background: var(--status-sent-bg);
  border-color: var(--status-sent);
  color: var(--status-sent);
}

.wa-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.wa-status-badge.connecting .wa-dot,
.wa-status-badge.waiting .wa-dot {
  animation: waBlink 1s infinite;
}
.wa-status-badge.connected .wa-dot {
  animation: waPulse 2.5s infinite;
}
@keyframes waBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: .25; }
}
@keyframes waPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .55; transform: scale(1.3); }
}

/* ── Connected info ── */
.wa-connected-info { display: flex; flex-direction: column; gap: 6px; }
.wa-info-line {
  font-size: .875rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Buttons ── */
.wa-btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ── QR Code Modal ── */
.qr-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn .2s ease;
}

.qr-modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  animation: modalIn .25s cubic-bezier(.34,1.56,.64,1);
}

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

.qr-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.qr-modal-header h3 { font-size: 1rem; font-weight: 700; }
.qr-modal-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.qr-modal-close {
  width: 32px; height: 32px;
  border: none; border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: .95rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.qr-modal-close:hover { background: var(--status-error-bg); color: var(--status-error); }

.qr-modal-body {
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.qr-modal-body.form-body {
  align-items: stretch;
  text-align: left;
}

/* ── Modal visualização ── */
.view-field {
  display: flex;
  flex-direction: column;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.view-field:last-child { border-bottom: none; }
.view-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.view-value {
  font-size: .95rem;
  color: var(--text-primary);
  font-weight: 500;
}
.qr-modal-body.form-body .form-group {
  margin-bottom: 0;
}
.qr-modal-body.form-body select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

.qr-modal-footer {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-hover);
}

/* Steps inline (4 colunas no modal) */
.wa-steps-inline {
  flex-direction: row !important;
  gap: 0 !important;
}
.wa-steps-inline li {
  flex: 1;
  flex-direction: column !important;
  align-items: center !important;
  text-align: center;
  gap: 8px !important;
  padding: 0 4px;
  font-size: .75rem !important;
}
.wa-steps-inline .wa-step-num { margin-top: 0 !important; }

/* ── QR Code ── */
.wa-qr-timer-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
}
.wa-qr-timer-label { color: var(--text-muted); }
.wa-qr-counter {
  background: var(--status-pending-bg);
  color: var(--status-pending);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  min-width: 36px;
  text-align: center;
}
.wa-qr-counter.urgent {
  background: var(--status-error-bg);
  color: var(--status-error);
}

.wa-qr-instruction {
  font-size: .85rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.wa-qr-container {
  display: inline-block;
  padding: 14px;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
/* Force QR canvas/img to be clean */
.wa-qr-container canvas,
.wa-qr-container img { display: block; }

/* ── Pairing code ── */
.wa-pairing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.wa-pairing-label {
  font-size: .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}
.wa-pairing-code {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: .2em;
  color: var(--text-primary);
  font-family: monospace;
}

/* ── Steps list ── */
.wa-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.wa-steps li {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  font-size: .88rem;
  color: var(--text-secondary);
  line-height: 1.55;
}
.wa-step-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: .75rem;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ============================================================
   MOBILE — contacts card view
   ============================================================ */
@media (max-width: 600px) {
  /* Hide table headers */
  .contacts-table thead { display: none; }

  /* Each row becomes a card */
  .contacts-table tbody tr {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow: hidden;
  }
  .contacts-table tbody tr:hover { background: var(--bg-card); }

  /* Each cell stacks */
  .contacts-table tbody td {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-size: .85rem;
    gap: 10px;
  }
  .contacts-table tbody td:last-child { border-bottom: none; }

  /* Label column */
  .contacts-table tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: .7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    width: 72px;
    flex-shrink: 0;
  }
}

/* ============================================================
   RESPONSIVE — general
   ============================================================ */
@media (max-width: 768px) {
  :root { --sidebar-w: 280px; }

  /* Sidebar slides off-screen */
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .sidebar-close-btn { display: flex; }

  /* Main content fills full width */
  .main-content { margin-left: 0; }

  /* Show hamburger */
  .hamburger-btn { display: flex; }

  .top-bar { padding: 0 16px; }
  .page-content { padding: 16px; }

  /* Stats — gap e margem menores em mobile */
  .stats-grid { gap: 12px; margin-bottom: 16px; }
  .stats-grid.stats-grid-2col { grid-template-columns: 1fr; }
  .stat-card { padding: 16px; gap: 12px; }
  .stat-icon { width: 42px; height: 42px; font-size: 1.25rem; }
  .stat-value { font-size: 1.6rem; }

  /* Card padding */
  .card-header, .card-body { padding: 14px 16px; }

  /* Form actions stack */
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }

  /* List controls stack */
  .list-controls { flex-direction: column; }

  /* Login card */
  .login-card { padding: 36px 24px; }

  /* Preview actions */
  .preview-header { flex-direction: column; align-items: flex-start; }
  .preview-actions { width: 100%; }
  .preview-actions .btn { flex: 1; }

  /* Upload area */
  .upload-area { padding: 32px 16px; }

  /* QR modal steps — 2x2 on very small screens */
  .wa-steps-inline { flex-wrap: wrap; }
  .wa-steps-inline li { flex: 0 0 50%; }

  /* Message config — single column on mobile */
  .msg-config-grid { grid-template-columns: 1fr; }
  .msg-preview-full { grid-column: 1; }
  .msg-config-actions { flex-direction: column-reverse; }
  .msg-config-actions .btn { width: 100%; }

  /* Template banner — stack on mobile */
  .template-banner { flex-direction: column; align-items: flex-start; }
  .template-banner .btn { width: 100%; justify-content: center; }

  /* WhatsApp page — coluna única no mobile */
  .wa-page-grid { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .stat-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 14px;
  }
  .tab { font-size: .75rem; padding: 8px 6px; }
}
