/* =========================================================
   TRC Chat — Design System
   Mesma linguagem visual da plataforma de e-mail (SaaS clean),
   com a identidade azul da TRC ADS.
   ========================================================= */

:root {
  --bg:            #f7f8fb;
  --surface:       #ffffff;
  --surface-2:     #f1f3f8;
  --border:        #e5e7eb;
  --border-strong: #d1d5db;
  --text:          #111827;
  --text-muted:    #6b7280;
  --text-soft:     #9ca3af;

  --brand:         #2563eb;
  --brand-strong:  #1d4ed8;
  --brand-soft:    #dbeafe;
  --brand-softer:  #eff6ff;
  --navy:          #0b1f3a;

  --info:          #2563eb;
  --info-soft:     #dbeafe;
  --success:       #16a34a;
  --success-soft:  #dcfce7;
  --warning:       #f59e0b;
  --warning-soft:  #fef3c7;
  --danger:        #dc2626;
  --danger-soft:   #fee2e2;

  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
  --radius-xl:  20px;

  --shadow-sm:  0 1px 2px rgba(17,24,39,.05);
  --shadow:     0 1px 3px rgba(17,24,39,.06), 0 1px 2px rgba(17,24,39,.04);
  --shadow-lg:  0 10px 25px -10px rgba(17,24,39,.12), 0 4px 10px -3px rgba(17,24,39,.06);

  --sidebar-w:  248px;
  --header-h:   64px;

  --font-sans:  'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono:  ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--font-sans); font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); text-decoration: underline; }
img, svg { max-width: 100%; }
h1,h2,h3,h4,h5 { color: var(--text); margin: 0 0 .6em; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 16px; }
p { margin: 0 0 .6em; }
small, .muted { color: var(--text-muted); font-size: 13px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }

/* ---------- Layout ---------- */
.app-shell { min-height: 100vh; display: flex; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 50; overflow-y: auto;
}
.sidebar-brand {
  height: var(--header-h); display: flex; align-items: center; gap: 10px;
  padding: 0 22px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 17px; color: var(--text); letter-spacing: -.01em;
}
.sidebar-brand .logo-dot {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--navy), var(--brand));
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 12px;
  box-shadow: 0 6px 12px -6px rgba(37,99,235,.6);
}
.sidebar-section-title {
  padding: 18px 22px 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em;
  color: var(--text-soft); text-transform: uppercase;
}
.sidebar-nav { padding: 6px 12px 24px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px;
  color: var(--text-muted); font-weight: 500; font-size: 14px; text-decoration: none;
  transition: background .15s, color .15s; white-space: nowrap;
}
.sidebar-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar-nav a.active { background: var(--brand-softer); color: var(--brand-strong); font-weight: 600; }
.sidebar-nav .nav-icon { width: 18px; height: 18px; flex: 0 0 18px; display:inline-flex; align-items:center; justify-content:center; }
.sidebar-foot { margin-top: auto; padding: 14px 22px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-soft); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--header-h); background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 28px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-size: 15px; font-weight: 600; margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-user {
  display: flex; align-items: center; gap: 10px; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  font-size: 13px; color: var(--text);
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%; overflow: hidden; flex: 0 0 auto;
  background: var(--brand-soft); color: var(--brand-strong);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px;
}
.content { padding: 28px; max-width: 1400px; width: 100%; }
.page-header { margin-bottom: 22px; display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap: 14px; }
.page-header h1 { margin: 0; font-size: 22px; }
.page-header .subtitle { color: var(--text-muted); margin-top: 4px; font-size: 14px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.card-hover { transition: box-shadow .15s, transform .15s; }
.card-hover:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.card-title { font-size: 15px; font-weight: 600; margin: 0 0 12px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.kpi .label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 26px; font-weight: 700; line-height: 1.2; }
.kpi .trend { font-size: 12px; color: var(--text-muted); }
.kpi.brand .value { color: var(--brand-strong); }
.kpi.success .value { color: var(--success); }
.kpi.warning .value { color: var(--warning); }
.kpi.danger .value { color: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; line-height: 1;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer; text-decoration: none;
  background: var(--surface-2); color: var(--text);
  transition: background .15s, color .15s, border-color .15s, transform .05s; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-loading { opacity: .65; pointer-events: none; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #15803d; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-link { background: transparent; color: var(--brand); border: none; padding: 0; height: auto; font-weight: 600; }
.btn-link:hover { text-decoration: underline; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label, .field .label { display: block; font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 6px; }
.field .hint { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px;
  transition: border-color .15s, box-shadow .15s; appearance: none;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.input[disabled], .select[disabled], .textarea[disabled] { background: var(--surface-2); color: var(--text-muted); cursor: not-allowed; }
.textarea { resize: vertical; min-height: 96px; line-height: 1.5; font-family: var(--font-mono); font-size: 13px; }
.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236b7280' d='M6 8L0 0h12z'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}
.input-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--brand); margin: 0 6px 0 0; vertical-align: middle; }

/* ---------- Tables ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th, .table td { padding: 12px 16px; text-align: left; }
.table thead th { background: var(--surface-2); color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tbody td { border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .empty { text-align: center; padding: 36px 20px; color: var(--text-muted); font-style: italic; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; font-size: 12px; font-weight: 600; border-radius: 999px; line-height: 1.4; background: var(--surface-2); color: var(--text); }
.badge-success { background: var(--success-soft); color: #166534; }
.badge-warning { background: var(--warning-soft); color: #92400e; }
.badge-danger  { background: var(--danger-soft);  color: #991b1b; }
.badge-info    { background: var(--info-soft);    color: #1e40af; }
.badge-brand   { background: var(--brand-soft);   color: var(--brand-strong); }
.badge-muted   { background: var(--surface-2);    color: var(--text-muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--success); } .dot-amber { background: var(--warning); } .dot-red { background: var(--danger); } .dot-gray { background: var(--text-soft); }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); margin-bottom: 16px; font-size: 14px; display: flex; align-items: flex-start; gap: 10px; }
.alert-success { background: var(--success-soft); border-color: #bbf7d0; color: #166534; }
.alert-warning { background: var(--warning-soft); border-color: #fde68a; color: #92400e; }
.alert-danger  { background: var(--danger-soft);  border-color: #fecaca; color: #991b1b; }
.alert-info    { background: var(--info-soft);    border-color: #bfdbfe; color: #1e40af; }

/* ---------- Modais ---------- */
.modal { position: fixed; inset: 0; background: rgba(17,24,39,.55); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; backdrop-filter: blur(2px); }
.modal.open { display: flex; }
.modal-card { background: var(--surface); border-radius: var(--radius-lg); max-width: 520px; width: 100%; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; max-height: 90vh; overflow: hidden; animation: modalIn .18s ease-out; }
.modal-card.modal-lg { max-width: 760px; } .modal-card.modal-xl { max-width: 1000px; }
@keyframes modalIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h2, .modal-head h3 { margin: 0; font-size: 16px; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 22px; line-height: 1; color: var(--text-muted); padding: 4px 8px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); }

/* ---------- Empty ---------- */
.empty-state { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 44px 20px; text-align: center; color: var(--text-muted); }
.empty-state .ico { font-size: 34px; margin-bottom: 10px; }
.empty-state h3 { color: var(--text); margin-bottom: 6px; }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 0% 0%, rgba(37,99,235,.10), transparent 42%),
              radial-gradient(circle at 100% 100%, rgba(11,31,58,.10), transparent 42%), var(--bg); padding: 20px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 410px; padding: 36px 32px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; justify-content: center; }
.auth-brand .logo-dot { width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, var(--navy), var(--brand)); display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 15px; }
.auth-brand .name { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.auth-title { font-size: 20px; font-weight: 700; margin: 0 0 6px; text-align: center; }
.auth-sub { font-size: 14px; color: var(--text-muted); margin: 0 0 22px; text-align: center; }

/* ---------- Utils ---------- */
.flex { display: flex; } .flex-col { flex-direction: column; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.mt-1{margin-top:4px}.mt-2{margin-top:8px}.mt-3{margin-top:12px}.mt-4{margin-top:16px}
.mb-1{margin-bottom:4px}.mb-2{margin-bottom:8px}.mb-3{margin-bottom:12px}.mb-4{margin-bottom:16px}.mb-6{margin-bottom:24px}
.w-full{width:100%}.text-center{text-align:center}.text-right{text-align:right}
.text-muted{color:var(--text-muted)}.text-danger{color:var(--danger)}.text-success{color:var(--success)}.text-brand{color:var(--brand-strong)}
.font-mono{font-family:var(--font-mono)}
.code { font-family: var(--font-mono); background: var(--surface-2); padding: 2px 6px; border-radius: 4px; font-size: 13px; word-break: break-all; }
.grid { display: grid; gap: 16px; } .grid-cards { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.toolbar .filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar .filters .input, .toolbar .filters .select { padding: 8px 12px; font-size: 13px; min-width: 130px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; border: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* funil */
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel-row { display: flex; align-items: center; gap: 12px; }
.funnel-label { width: 130px; font-size: 13px; color: var(--text-muted); flex: 0 0 130px; }
.funnel-bar-wrap { flex: 1; background: var(--surface-2); border-radius: 6px; height: 26px; overflow: hidden; }
.funnel-bar { height: 100%; background: linear-gradient(90deg, var(--brand), #60a5fa); display:flex; align-items:center; padding-left: 10px; color:#fff; font-size:12px; font-weight:600; border-radius: 6px; }
.funnel-val { width: 80px; text-align: right; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* toast */
.toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: #fff; padding: 12px 16px; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow-lg); animation: modalIn .2s; max-width: 340px; }
.toast.success { background: #166534; } .toast.danger { background: #991b1b; } .toast.warning { background: #92400e; }

/* mobile */
.menu-toggle { display: none; background: transparent; border: none; cursor: pointer; font-size: 22px; color: var(--text); padding: 6px 8px; }
@media (max-width: 920px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 18px; }
}

.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
