/* ═══════════════════════════════════════════════════════════
   PRUMO ZAPP — style.css v2.0
   Sidebar branca · Verde #16a34a · Cinza #f8fafc
═══════════════════════════════════════════════════════════ */

:root {
  --green-50:  #f0fdf4;
  --green-100: #dcfce7;
  --green-400: #4ade80;
  --green-500: #22c55e;
  --green-600: #16a34a;
  --green-700: #15803d;
  --green-900: #14532d;
  --navy:      #0D1B2A;
  --gray-50:   #f8fafc;
  --gray-100:  #f1f5f9;
  --gray-200:  #e2e8f0;
  --gray-300:  #cbd5e1;
  --gray-400:  #94a3b8;
  --gray-500:  #64748b;
  --gray-700:  #334155;
  --gray-900:  #0f172a;
  --red-500:   #ef4444;
  --red-100:   #fee2e2;
  --amber-500: #f59e0b;
  --amber-100: #fef3c7;
  --white:     #ffffff;
  --sidebar-w: 240px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
}

/* ── LAYOUT ─────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR BRANCA ──────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: #ffffff;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 2px 0 8px rgba(0,0,0,.04);
}

.sidebar-brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--gray-100);
}

.sidebar-logo { height: 44px; width: auto; max-width: 100%; }

/* Status WA badge */
.wa-status-badge {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 12px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: .72rem; font-weight: 600;
  transition: all .3s;
}
.wa-status-badge.online  { background: var(--green-50); color: var(--green-700); }
.wa-status-badge.offline { background: #fff5f5; color: #b91c1c; }
.wa-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.wa-status-badge.online  .wa-dot { background: var(--green-500); box-shadow: 0 0 6px var(--green-500); animation: pulse-green 2s infinite; }
.wa-status-badge.offline .wa-dot { background: var(--red-500); }
@keyframes pulse-green {
  0%,100% { box-shadow: 0 0 4px var(--green-500); }
  50%      { box-shadow: 0 0 12px var(--green-500); }
}

/* Nav */
.sidebar nav { flex: 1; padding: 8px; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--gray-500);
  text-decoration: none; font-size: .82rem; font-weight: 500;
  transition: all .15s; position: relative;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item span:first-of-type { flex: 1; }
.nav-item:hover { background: var(--gray-50); color: var(--green-700); }
.nav-item.active {
  background: var(--green-50);
  color: var(--green-700);
  font-weight: 700;
  border-left: 3px solid var(--green-600);
}

.nav-badge-green { font-size: .58rem; font-weight: 700; background: var(--green-500); color: #fff; padding: 1px 5px; border-radius: 999px; }
.nav-badge-red   { font-size: .58rem; font-weight: 700; background: var(--red-500);   color: #fff; padding: 1px 5px; border-radius: 999px; }

/* Footer */
.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--gray-100);
  display: flex; align-items: center; gap: 8px;
}
.sidebar-user { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.sidebar-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--green-600); color: #fff;
  font-size: .78rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-user-name { font-size: .78rem; font-weight: 600; color: var(--gray-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-plan { font-size: .65rem; color: var(--green-600); }
.sidebar-logout {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 6px;
  color: var(--gray-400); transition: all .15s;
}
.sidebar-logout:hover { background: var(--red-100); color: var(--red-500); }
.sidebar-logout svg { width: 16px; height: 16px; }

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

.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center;
  padding: 0 24px; height: 60px; gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.mob-toggle { display: none; background: none; border: none; cursor: pointer; padding: 8px; border-radius: 8px; -webkit-tap-highlight-color: transparent; }
.mob-toggle:active { background: var(--gray-100); }
.mob-toggle svg { width: 24px; height: 24px; stroke: var(--gray-700); display: block; }
.topbar-title { font-weight: 700; font-size: .95rem; color: var(--gray-900); }
.topbar-spacer { flex: 1; }

.topbar-wa-status { display: flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 600; padding: 5px 12px; border-radius: 999px; }
.topbar-wa-status.online  { background: var(--green-100); color: var(--green-700); }
.topbar-wa-status.offline { background: var(--red-100); color: var(--red-500); }
.pulse-dot { width: 7px; height: 7px; border-radius: 50%; }
.topbar-wa-status.online  .pulse-dot { background: var(--green-500); animation: pulse-green 2s infinite; }
.topbar-wa-status.offline .pulse-dot { background: var(--red-500); }

.page-content { padding: 24px; flex: 1; background: var(--gray-50); }

/* ── ALERT ───────────────────────────────────────────────── */
.alert { display: flex; align-items: center; gap: 10px; margin: 16px 24px 0; padding: 12px 16px; border-radius: 8px; font-size: .84rem; font-weight: 500; transition: opacity .4s; }
.alert-success { background: var(--green-100); color: var(--green-700); border: 1px solid #bbf7d0; }
.alert-danger  { background: var(--red-100); color: #b91c1c; border: 1px solid #fecaca; }
.alert-close { margin-left: auto; background: none; border: none; cursor: pointer; color: inherit; font-size: 1.2rem; line-height: 1; opacity: .7; }
.alert-close:hover { opacity: 1; }

/* ── CARDS ───────────────────────────────────────────────── */
.card { background: var(--white); border: 1px solid var(--gray-200); border-radius: 12px; overflow: hidden; margin-bottom: 20px; }
.card-header { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--gray-100); }
.card-title { font-weight: 700; font-size: .9rem; color: var(--gray-900); flex: 1; }
.card-body { padding: 20px; }

/* ── STAT CARDS ──────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); border: 1px solid var(--gray-200); border-radius: 12px; padding: 20px; display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon.green  { background: var(--green-100); color: var(--green-600); }
.stat-icon.navy   { background: #f0f4ff; color: #3730a3; }
.stat-icon.amber  { background: var(--amber-100); color: var(--amber-500); }
.stat-icon.red    { background: var(--red-100); color: var(--red-500); }
.stat-icon svg    { width: 20px; height: 20px; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: .72rem; color: var(--gray-500); margin-top: 2px; }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 18px; border-radius: 8px; font-size: .84rem; font-weight: 600; border: none; cursor: pointer; text-decoration: none; transition: all .15s; white-space: nowrap; }
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-primary  { background: var(--green-600); color: #fff; }
.btn-primary:hover { background: var(--green-700); }
.btn-outline  { background: transparent; color: var(--green-600); border: 1.5px solid var(--green-600); }
.btn-outline:hover { background: var(--green-50); }
.btn-danger   { background: var(--red-500); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost    { background: var(--gray-100); color: var(--gray-700); }
.btn-ghost:hover { background: var(--gray-200); }
.btn-wa       { background: #25d366; color: #fff; }
.btn-wa:hover { background: #128c7e; }
.btn-sm { padding: 6px 14px; font-size: .78rem; }
.btn-xs { padding: 4px 10px; font-size: .72rem; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── FORMS ───────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-size: .82rem; font-weight: 600; color: var(--gray-700); }
.form-group .hint { font-size: .72rem; color: var(--gray-400); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=tel], input[type=url], input[type=date], input[type=time],
select, textarea {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--gray-200); border-radius: 8px;
  font-size: .85rem; color: var(--gray-900); background: var(--white);
  transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green-500); box-shadow: 0 0 0 3px rgba(34,197,94,.15); }
input:read-only { background: var(--gray-50); color: var(--gray-500); }
textarea { resize: vertical; min-height: 90px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.span2 { grid-column: span 2; }
.req { color: var(--red-500); }

.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; border-radius: 24px; background: var(--gray-200); cursor: pointer; transition: .3s; }
.toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; left: 3px; top: 3px; transition: .3s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle input:checked + .toggle-slider { background: var(--green-500); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── TABLE ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--gray-200); text-align: left; white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); font-size: .84rem; color: var(--gray-700); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }
.td-bold { font-weight: 600; color: var(--gray-900); }

/* ── TABS ────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; }
.tab-item { padding: 11px 20px; font-size: .82rem; font-weight: 600; color: var(--gray-500); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -2px; transition: all .15s; }
.tab-item:hover { color: var(--green-600); }
.tab-item.active { color: var(--green-700); border-bottom-color: var(--green-600); }

/* ── QR CODE ─────────────────────────────────────────────── */
.qr-container { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 32px; text-align: center; }
.qr-frame { width: 240px; height: 240px; border: 3px solid var(--green-600); border-radius: 16px; padding: 12px; background: #fff; position: relative; }
.qr-frame img { width: 100%; height: 100%; object-fit: contain; }
.qr-corner { position: absolute; width: 20px; height: 20px; border-color: var(--green-600); border-style: solid; }
.qr-corner.tl { top: -3px; left: -3px; border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
.qr-corner.tr { top: -3px; right: -3px; border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; }
.qr-corner.bl { bottom: -3px; left: -3px; border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; }
.qr-corner.br { bottom: -3px; right: -3px; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }
.qr-scanning { animation: scanLine 2s linear infinite; }
@keyframes scanLine { 0%,100% { border-color: var(--green-600); } 50% { border-color: var(--green-400); } }

/* ── STATUS ──────────────────────────────────────────────── */
.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700; }
.status-pill.connected    { background: var(--green-100); color: var(--green-700); }
.status-pill.disconnected { background: var(--red-100); color: #b91c1c; }
.status-pill.connecting   { background: var(--amber-100); color: #b45309; }
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ── TRAINING ────────────────────────────────────────────── */
.train-section { border: 1.5px solid var(--gray-200); border-radius: 10px; padding: 16px; margin-bottom: 12px; transition: border-color .15s; }
.train-section:hover { border-color: var(--green-400); }
.train-section-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .85rem; color: var(--gray-900); margin-bottom: 12px; }
.qa-item { background: var(--gray-50); border-radius: 8px; padding: 12px; margin-bottom: 8px; position: relative; }
.qa-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-400); margin-bottom: 3px; }
.qa-del { position: absolute; top: 8px; right: 8px; background: none; border: none; cursor: pointer; color: var(--red-500); opacity: .5; }
.qa-del:hover { opacity: 1; }

/* ── UPLOAD ──────────────────────────────────────────────── */
.upload-zone { border: 2px dashed var(--gray-300); border-radius: 10px; padding: 24px; text-align: center; cursor: pointer; transition: all .15s; }
.upload-zone:hover, .upload-zone.drag { border-color: var(--green-500); background: var(--green-50); }
.upload-zone input { display: none; }
.upload-icon { color: var(--green-600); margin-bottom: 8px; }
.upload-icon svg { width: 32px; height: 32px; }
.upload-text { font-size: .82rem; color: var(--gray-500); }
.upload-text strong { color: var(--green-700); }
.file-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--green-100); color: #166534; padding: 4px 10px; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.file-chip-del { background: none; border: none; cursor: pointer; color: inherit; opacity: .6; font-size: 1rem; line-height: 1; }
.file-chip-del:hover { opacity: 1; }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin-top: 10px; }
.img-thumb { position: relative; border-radius: 8px; overflow: hidden; aspect-ratio: 1; }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-thumb-del { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.55); color: #fff; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: none; cursor: pointer; font-size: .75rem; }

/* ── PLAN CARDS ──────────────────────────────────────────── */
.plan-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.plan-card { border: 2px solid var(--gray-200); border-radius: 12px; padding: 24px; position: relative; transition: all .2s; }
.plan-card.recommended { border-color: var(--green-500); background: var(--green-50); }
.plan-badge { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: var(--green-600); color: #fff; padding: 2px 12px; border-radius: 999px; font-size: .65rem; font-weight: 700; white-space: nowrap; }
.plan-name { font-size: .82rem; font-weight: 600; color: var(--gray-500); margin-bottom: 8px; }
.plan-price { font-size: 1.8rem; font-weight: 800; color: var(--gray-900); }
.plan-price span { font-size: .78rem; font-weight: 400; color: var(--gray-500); }
.plan-features { list-style: none; margin: 16px 0; display: flex; flex-direction: column; gap: 6px; }
.plan-features li { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--gray-700); }
.plan-features li::before { content: '✓'; color: var(--green-600); font-weight: 700; }

/* ── UPSELL ──────────────────────────────────────────────── */
.upsell-box { background: linear-gradient(135deg, var(--navy), #1e3a5f); border-radius: 12px; padding: 24px; color: #fff; text-align: center; margin-top: 20px; }
.upsell-box h3 { font-size: 1rem; margin-bottom: 8px; }
.upsell-box p  { font-size: .82rem; color: rgba(255,255,255,.75); margin-bottom: 16px; }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay { display:none;position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:500;align-items:center;justify-content:center;padding:20px; }
.modal-overlay.open { display:flex; }
.modal { background:#fff;border-radius:14px;max-width:500px;width:100%;max-height:90vh;overflow-y:auto; }
.modal-header { display:flex;align-items:center;gap:10px;padding:18px 20px;border-bottom:1px solid var(--gray-200); }
.modal-title  { font-weight:700;font-size:.95rem;flex:1; }
.modal-close  { background:none;border:none;cursor:pointer;font-size:1.3rem;color:var(--gray-400);line-height:1; }
.modal-body   { padding:20px; }
.modal-footer { display:flex;justify-content:flex-end;gap:10px;padding:14px 20px;border-top:1px solid var(--gray-100); }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state { padding:48px 24px;text-align:center;color:var(--gray-400); }
.empty-state svg { width:48px;height:48px;margin-bottom:12px;opacity:.4; }
.empty-state h3 { font-size:.95rem;font-weight:600;color:var(--gray-600);margin-bottom:6px; }
.empty-state p  { font-size:.82rem; }

/* ── MOBILE ──────────────────────────────────────────────── */
.sidebar-overlay { display:none;position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:150; }

@media (max-width: 768px) {
  html, body { overflow-x: hidden; }
  .app-layout { width: 100%; overflow-x: hidden; }
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.15); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; width: 100%; max-width: 100vw; }
  .mob-toggle { display: flex; align-items: center; justify-content: center; }
  .topbar { padding: 0 14px; height: 56px; gap: 10px; }
  .topbar-title { font-size: .9rem; max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .span2 { grid-column: span 1; }
  .plan-cards { grid-template-columns: 1fr; }
  .page-content { padding: 16px 14px; max-width: 100vw; overflow-x: hidden; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  /* Tables - permit horizontal scroll on mobile */
  .card-body { overflow-x: auto; }
  table { font-size: .8rem; }
  th, td { padding: 8px 10px; }
  /* Cards never overflow viewport */
  .card { margin-left: 0; margin-right: 0; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .topbar-title { max-width: 50%; }
  .page-content { padding: 14px 12px; }
}

/* ── LOGIN ───────────────────────────────────────────────── */
.login-page { min-height:100vh;display:flex;align-items:center;justify-content:center;background:linear-gradient(135deg,#0D1B2A 0%,#064e3b 100%);padding:20px; }
.login-card { background:#fff;border-radius:16px;padding:40px 36px;width:100%;max-width:400px;box-shadow:0 20px 60px rgba(0,0,0,.3); }
.login-logo { text-align:center;margin-bottom:28px; }
.login-logo img { height:56px; }
.login-title { text-align:center;font-size:1.1rem;font-weight:700;color:var(--gray-900);margin-bottom:4px; }
.login-sub   { text-align:center;font-size:.8rem;color:var(--gray-500);margin-bottom:24px; }
.login-footer{ text-align:center;margin-top:20px;font-size:.76rem;color:var(--gray-400); }