/* public/saas-ui.css — Design system compartilhado (admin + portal do tenant)
   Visual moderno, claro e responsivo. Tokens + componentes reutilizáveis. */

:root {
  --bg: #f6f7fb;             /* fundo da página */
  --surface: #ffffff;        /* cartões */
  --surface-2: #f1f3f9;      /* superfícies secundárias */
  --border: #e6e8f0;         /* bordas suaves */
  --txt: #1b2333;            /* texto principal */
  --muted: #6b7488;          /* texto secundário */
  --brand: #6d5efc;          /* roxo/índigo da marca */
  --brand-2: #8b7bff;
  --brand-ink: #4b3fd4;
  --accent: #14b8a6;         /* teal de apoio */
  --success: #16a34a;
  --warning: #d97706;
  --danger: #e23b54;
  --grad: linear-gradient(135deg, #6d5efc 0%, #8b7bff 50%, #b18bff 100%);
  --shadow-sm: 0 1px 2px rgba(20,25,45,.06), 0 1px 3px rgba(20,25,45,.05);
  --shadow: 0 6px 24px rgba(30,35,70,.08);
  --shadow-lg: 0 18px 48px rgba(30,35,70,.18);
  --radius: 14px;
  --radius-sm: 10px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Plus Jakarta Sans', 'Inter', -apple-system, 'Segoe UI', sans-serif;
}

/* Títulos/destaques em Plus Jakarta Sans; corpo em Inter */
.h1, .h2, .h3, .display, .brand, .stat .v, .card-title, .modal h2,
h1, h2, h3 { font-family: var(--font-display); }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--txt);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Tipografia utilitária ===== */
.h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.h2 { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.h3 { font-size: 15px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 14px; } .mt-4 { margin-top: 22px; }

/* ===== Botões ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: transform .04s ease, box-shadow .15s ease, background .15s ease, opacity .15s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(109,94,252,.35); }
.btn-primary:hover { box-shadow: 0 8px 22px rgba(109,94,252,.45); }
.btn-ghost { background: var(--surface); color: var(--txt); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-soft { background: rgba(109,94,252,.10); color: var(--brand-ink); }
.btn-soft:hover { background: rgba(109,94,252,.18); }
.btn-danger { background: #fdecef; color: var(--danger); border-color: #f7c9d2; }
.btn-danger:hover { background: #fbdde2; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

/* ===== Formulários ===== */
label { display: block; font-size: 13px; font-weight: 600; color: var(--txt); margin: 14px 0 6px; }
label .muted { font-weight: 400; }
input, textarea, select {
  width: 100%; padding: 11px 13px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--txt); font-size: 14px; font-family: inherit; transition: border .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 80px; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(109,94,252,.15);
}
.check { display: flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 500; font-size: 14px; margin-top: 6px; }
.check input { width: auto; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 150px; }

/* ===== Cartões / superfícies ===== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

/* ===== Badges / tags ===== */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
}
.badge.ok { background: #e7f7ee; color: var(--success); }
.badge.warn { background: #fdf2e3; color: var(--warning); }
.badge.off { background: #fdecef; color: var(--danger); }
.badge.brand { background: rgba(109,94,252,.12); color: var(--brand-ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ===== Barra de progresso ===== */
.progress { height: 9px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; background: var(--grad); border-radius: 999px; transition: width .4s ease; }
.progress.warn > span { background: linear-gradient(90deg,#f59e0b,#ef4444); }

/* ===== Estatística (KPI) ===== */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .v { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.stat .k { font-size: 13px; color: var(--muted); font-weight: 500; }

/* ===== App shell (sidebar + conteúdo) ===== */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 22px 16px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; margin-bottom: 26px; letter-spacing: -.01em; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: var(--grad); display: grid; place-items: center; color: #fff; font-size: 18px; box-shadow: 0 4px 12px rgba(109,94,252,.4); }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 11px 13px; border-radius: var(--radius-sm); background: transparent; color: var(--muted);
  border: none; cursor: pointer; font-size: 14px; font-weight: 600; font-family: inherit; margin-bottom: 3px;
}
.nav-item:hover { background: var(--surface-2); color: var(--txt); }
.nav-item.ativo { background: rgba(109,94,252,.12); color: var(--brand-ink); }
.sidebar .spacer { flex: 1; }
.sidebar .user-box { border-top: 1px solid var(--border); padding-top: 14px; font-size: 13px; color: var(--muted); }

.main { padding: 28px 34px; overflow-y: auto; max-height: 100vh; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }

/* ===== Lista de itens (cartões clicáveis) ===== */
.item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  cursor: pointer; transition: border .15s, box-shadow .15s, transform .05s; box-shadow: var(--shadow-sm);
}
.item:hover { border-color: var(--brand); box-shadow: var(--shadow); transform: translateY(-1px); }
.item .meta { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ===== Tabela ===== */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: none; }

/* ===== Modal ===== */
.modal-bg { position: fixed; inset: 0; background: rgba(20,25,45,.45); backdrop-filter: blur(3px); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 60; }
.modal-bg.aberto { display: flex; }
.modal { background: var(--surface); border-radius: 18px; padding: 26px; width: 100%; max-width: 660px; max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal h2 { font-size: 19px; font-weight: 700; margin-bottom: 4px; }

/* ===== Chat de teste ===== */
.chat { background: var(--surface-2); border-radius: 12px; padding: 14px; height: 300px; overflow-y: auto; margin-bottom: 10px; }
.bolha { max-width: 80%; padding: 9px 13px; border-radius: 14px; margin-bottom: 8px; font-size: 14px; white-space: pre-wrap; line-height: 1.45; }
.bolha.user { background: var(--grad); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.bolha.bot { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }

/* ===== Auth (login/signup) ===== */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth-hero { background: var(--grad); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; }
.auth-hero h1 { font-size: 38px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.auth-hero p { opacity: .92; margin-top: 16px; font-size: 16px; max-width: 420px; }
.auth-hero .feat { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-weight: 500; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-card { width: 100%; max-width: 400px; }
.tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 5px; border-radius: 12px; margin-bottom: 20px; }
.tab { flex: 1; padding: 9px; border: none; background: transparent; border-radius: 9px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--muted); font-family: inherit; }
.tab.ativo { background: var(--surface); color: var(--txt); box-shadow: var(--shadow-sm); }

/* ===== Utilidades ===== */
.hidden { display: none !important; }
.erro { color: var(--danger); font-size: 13px; min-height: 16px; margin-top: 10px; }
.ok-msg { color: var(--success); font-size: 13px; margin-top: 8px; }
.url-box { display: block; background: var(--surface-2); padding: 11px; border-radius: 9px; font-size: 12px; font-family: ui-monospace, monospace; word-break: break-all; margin-top: 6px; border: 1px solid var(--border); }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Inbox (multi-atendimento) ===== */
.inbox { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.conv-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; max-height: 72vh; overflow-y: auto; box-shadow: var(--shadow-sm); }
.conv { padding: 13px 15px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.conv:hover { background: var(--surface-2); }
.conv.ativo { background: rgba(109,94,252,.10); }
.conv .nome { font-weight: 600; font-size: 14px; }
.conv .prev { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.conv .nb { background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.thread-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.thread-top { display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.bolha.atendente { background: #e7f7ee; color: #0f5132; margin-left: auto; border-bottom-right-radius: 4px; }
@media (max-width: 860px) { .inbox { grid-template-columns: 1fr; } .conv-list { max-height: 40vh; } }

/* ===== Toast ===== */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--txt); color: #fff; padding: 13px 18px; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500; z-index: 90; opacity: 0; transform: translateY(12px); transition: .25s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }

/* ===== Responsivo ===== */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; overflow-x: auto; padding: 12px; gap: 6px; }
  .sidebar .brand, .sidebar .spacer, .sidebar .user-box { display: none; }
  .nav-item { width: auto; margin-bottom: 0; }
  .main { padding: 20px 16px; max-height: none; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}
