:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e3e6ea;
  --text: #1f2329;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --sidebar: #ffffff;
  --bot-bubble: #f1f3f5;
  --user-bubble: #2563eb;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.layout { display: flex; height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 16px;
  padding: 4px 8px 18px;
}
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }

.menu { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  background: transparent;
  color: var(--text);
  border: none;
  border-radius: 9px;
  padding: 11px 12px;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  width: 100%;
  white-space: nowrap;
}
.nav-item:hover { background: var(--bg); filter: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .ico { font-size: 16px; }

.sidebar-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--muted);
  padding: 10px 8px 2px;
  border-top: 1px solid var(--border);
}
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #d1d5db; }
.status-dot.ok { background: #16a34a; }
.status-dot.busy { background: #f59e0b; }
.status-dot.err { background: #dc2626; }

/* ===== Content / views ===== */
.content { flex: 1; min-width: 0; padding: 22px; overflow-y: auto; }
.view { display: none; flex-direction: column; height: 100%; max-width: 860px; margin: 0 auto; }
.view.active { display: flex; }
.view-head h2 { margin: 0 0 16px; font-size: 20px; font-weight: 650; }

/* ===== Buttons ===== */
button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s ease;
}
button:hover { filter: brightness(1.05); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.ghost { background: var(--accent-soft); color: var(--accent); }
button.small { padding: 6px 11px; font-size: 13px; }

/* ===== Cards ===== */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card h3 { margin: 0 0 4px; font-size: 15.5px; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--muted); font-size: 13px; margin: 4px 0 12px; }
.hint { font-size: 12.5px; color: var(--muted); }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input[type="text"], input[type="password"] {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  outline: none;
}
input:focus { border-color: var(--accent); }

.config-row, .upload-row { display: flex; gap: 8px; align-items: center; }
input[type="file"] {
  flex: 1;
  font-size: 13.5px;
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: 9px;
  background: var(--bg);
}
.card-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }

/* ===== Doc list ===== */
.doc-list { list-style: none; margin: 6px 0 0; padding: 0; }
.doc-list li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.doc-list li:last-child { border-bottom: none; }
.doc-list .del {
  background: transparent; color: #dc2626; padding: 4px 8px; font-size: 13px;
}
.doc-list .del:hover { filter: none; text-decoration: underline; }

/* ===== Chat ===== */
.chat {
  flex: 1;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.bot .bubble { background: var(--bot-bubble); border-top-left-radius: 4px; }
.msg.user .bubble { background: var(--user-bubble); color: #fff; border-top-right-radius: 4px; }
.bubble.typing { color: var(--muted); font-style: italic; }

.composer { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px; }
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 160px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 11px;
  font-size: 14.5px;
  font-family: inherit;
  outline: none;
  background: var(--panel);
}
.composer textarea:focus { border-color: var(--accent); }

/* ===== Badges de status da conexão ===== */
.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  margin-left: 8px;
}
.badge.connected { background: #dcfce7; color: #166534; }
.badge.pending { background: #fef9c3; color: #854d0e; }
.badge.disconnected { background: #fee2e2; color: #991b1b; }

.doc-list .wa-actions { display: flex; gap: 6px; align-items: center; }
.doc-list .wa-info { display: flex; flex-direction: column; }
.doc-list .wa-sub { font-size: 12px; color: var(--muted); }
.btn-qr { background: var(--accent-soft); color: var(--accent); padding: 5px 10px; font-size: 13px; }

/* ===== Modal QR ===== */
.modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, 0.45);
  align-items: center; justify-content: center;
  z-index: 50;
}
.modal.open { display: flex; }
.modal-box {
  background: var(--panel);
  border-radius: 14px;
  padding: 24px;
  width: 360px;
  max-width: 92vw;
  text-align: center;
  box-shadow: 0 10px 40px rgba(16, 24, 40, 0.25);
}
.modal-box h3 { margin: 0 0 6px; }
.qr-wrap {
  display: flex; align-items: center; justify-content: center;
  width: 264px; height: 264px;
  margin: 14px auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.qr-wrap img { width: 256px; height: 256px; }

@media (max-width: 640px) {
  .sidebar { width: 64px; padding: 14px 8px; }
  .logo span:last-child, .nav-item span:not(.ico), .sidebar-status span:last-child { display: none; }
}
