/* =========================================================================
   AGR CRM — tokens e componentes base
   Fonte: canvas "AGR CRM" (Design). Copiar para wwwroot/css/agr.css
   Sem dependência de biblioteca de componentes. Fonte: Inter (Google Fonts)
   com fallback para a fonte do sistema.
   ========================================================================= */

:root {
  /* --- Cores de marca / interface --- */
  --c-navy: #0f2747;          /* barra superior, chips ativos no celular */
  --c-navy-line: #36507a;     /* divisor logo | CRM na barra */
  --c-nav-text: #c3d1e5;      /* itens de menu inativos */
  --c-primary: #1d5fa8;       /* botões primários, links, foco de campo */
  --c-primary-hover: #174f8f;
  --c-primary-ink: #123f73;   /* link hover */
  --c-primary-soft: #e1ecfa;  /* fundos azuis claros, contador de aba */
  --c-primary-soft-2: #eef3fa;/* hover de botão secundário, opção de lista */
  --c-amber: #e0a526;         /* destaque: Venda p/ finalizar */
  --c-amber-bright: #f2b632;  /* selo CRM, sublinhado do menu, anel de foco */
  --c-amber-bg: #fff7e0;      /* fundo do KPI urgente e da faixa "Amanda pausada" */
  --c-amber-col: #fdf3d6;     /* fundo da coluna Venda p/ finalizar */
  --c-amber-ink: #7f4500;     /* texto sobre âmbar claro */

  --c-bg: #f3f5f9;            /* fundo da aplicação */
  --c-surface: #ffffff;
  --c-surface-2: #f8fafc;     /* cabeçalho de tabela, rodapés de card */
  --c-col: #e9edf3;           /* corpo das colunas do kanban */
  --c-border: #dde3ec;
  --c-border-soft: #edf0f5;   /* linhas internas */
  --c-border-input: #c3cddb;
  --c-border-btn2: #b6c5da;

  --c-text: #14213d;
  --c-text-2: #3a4863;        /* labels de campo */
  --c-text-muted: #51607a;    /* texto secundário (6,4:1 sobre branco) */

  --c-danger: #b42318;
  --c-danger-ink: #a01c14;
  --c-danger-bg: #fdecea;
  --c-danger-line: #f4b8b2;
  --c-danger-row: #fff8f7;    /* linha em confirmação de exclusão */
  --c-success: #16613a;

  /* --- Etapas do funil (bg / texto / ponto) --- */
  --st-novo-bg:#eceff4;  --st-novo-fg:#3f4b5e;  --st-novo-dot:#64748b;
  --st-ia-bg:#ece8fc;    --st-ia-fg:#5536b0;    --st-ia-dot:#7c5ce0;
  --st-fu-bg:#dff2f7;    --st-fu-fg:#0a5a6e;    --st-fu-dot:#0e8aa8;
  --st-vend-bg:#e1ecfa;  --st-vend-fg:#174f8f;  --st-vend-dot:#1d5fa8;
  --st-venda-bg:#fdefc8; --st-venda-fg:#7f4500; --st-venda-dot:#e0a526;
  --st-cli-bg:#dff3e6;   --st-cli-fg:#16613a;   --st-cli-dot:#1f9d55;
  --st-dorm-bg:#eceef1;  --st-dorm-fg:#535d6e;  --st-dorm-dot:#9aa3b2;
  --st-perd-bg:#fde6e4;  --st-perd-fg:#a01c14;  --st-perd-dot:#d23c3c;

  /* --- Tipografia --- */
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-xs: 11px;  /* etiquetas, horários */
  --fs-sm: 12px;  /* apoio, labels */
  --fs-md: 13px;  /* texto denso: prévias, filtros */
  --fs-base: 14px;
  --fs-lg: 15px;
  --fs-h1-mobile: 20px;
  --fs-h1: 22px;
  --fs-kpi: 26px;
  --fs-total: 28px;

  /* --- Espaço (base 4) --- */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;

  /* --- Raios / sombras / medidas --- */
  --r-sm: 4px;   /* etiquetas */
  --r-md: 8px;   /* campos, botões, cards do kanban */
  --r-lg: 10px;  /* cartões, colunas */
  --r-pill: 999px;
  --shadow-pop: 0 12px 32px rgba(15,39,71,.18);  /* popover, autocompletar */
  --shadow-drag: 0 14px 30px rgba(15,39,71,.22); /* card arrastado */
  --topbar-h: 56px;
  --topbar-h-mobile: 52px;
  --container: 1392px;
  --ctl-h: 40px;        /* altura mínima de controle no desktop */
  --ctl-h-touch: 44px;  /* altura mínima no celular */
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--c-bg); color: var(--c-text); font-family: var(--font); font-size: var(--fs-base); line-height: 1.45; }
a { color: var(--c-primary); }
a:hover { color: var(--c-primary-ink); }
:focus-visible { outline: 3px solid var(--c-amber-bright); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--c-text-muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--c-navy); color: #fff; display: flex; align-items: center; gap: 28px; padding: 0 var(--sp-6); height: var(--topbar-h); }
.topbar__brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.topbar__logo { height: 36px; width: auto; display: block; }
.topbar__crm { border-left: 1px solid var(--c-navy-line); padding-left: 10px; font-size: 13px; font-weight: 700; letter-spacing: .12em; color: var(--c-amber-bright); }
.topbar__nav { display: flex; align-self: stretch; }
.topbar__nav a { color: var(--c-nav-text); text-decoration: none; padding: 0 16px; display: flex; align-items: center; font-weight: 500; border-top: 3px solid transparent; border-bottom: 3px solid transparent; }
.topbar__nav a:hover { color: #fff; }
.topbar__nav a.active { color: #fff; font-weight: 600; border-bottom-color: var(--c-amber-bright); }

.page { max-width: var(--container); margin: 0 auto; padding: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-4); }
.page-title { font-size: var(--fs-h1); font-weight: 700; letter-spacing: -.01em; margin: 0; }
.page-sub { font-size: var(--fs-md); color: var(--c-text-muted); margin: 2px 0 0; }
.section-title { font-size: var(--fs-sm); font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--c-text-2); margin: 0 0 var(--sp-3); }

/* ---------- Cartão ---------- */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); }

/* ---------- Botões ---------- */
.btn { font: inherit; font-size: var(--fs-base); font-weight: 600; border-radius: var(--r-md); padding: 8px 16px; min-height: var(--ctl-h); border: 1px solid var(--c-primary); background: var(--c-primary); color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; white-space: nowrap; transition: background-color .12s ease, border-color .12s ease; }
.btn:hover { background: var(--c-primary-hover); color: #fff; }
.btn--secondary { background: #fff; color: var(--c-primary); border-color: var(--c-border-btn2); }
.btn--secondary:hover { background: var(--c-primary-soft-2); color: var(--c-primary-hover); }
.btn--amber { background: var(--c-amber-bg); color: var(--c-amber-ink); border-color: var(--c-amber); } /* "Reativar Amanda" */
.btn--danger { background: var(--c-danger); border-color: var(--c-danger); }
.btn--sm { padding: 4px 10px; min-height: 32px; font-size: var(--fs-md); }
.btn--block { width: 100%; }
.btn:disabled { background: var(--c-border-input); border-color: var(--c-border-input); color: var(--c-text-muted); cursor: not-allowed; }
.btn-link { background: none; border: 0; padding: 4px 2px; font: inherit; font-size: var(--fs-md); color: var(--c-primary); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.btn-link--quiet { color: var(--c-text-muted); }
.btn-link--quiet:hover { color: var(--c-danger); }

/* ---------- Campos ---------- */
.field { display: flex; flex-direction: column; gap: 5px; font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-2); min-width: 0; }
.input { font: inherit; font-size: var(--fs-base); width: 100%; min-height: var(--ctl-h); padding: 8px 12px; border: 1px solid var(--c-border-input); border-radius: var(--r-md); background: #fff; color: var(--c-text); }
.input:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(29,95,168,.18); }
.input[aria-invalid="true"] { border-color: var(--c-danger); background: var(--c-danger-row); }
.input:disabled { background: var(--c-bg); color: var(--c-text-muted); }
.input--money { text-align: right; font-variant-numeric: tabular-nums; }
.input--edited { border-color: var(--c-amber); background: #fffbef; } /* preço diferente do de mercado */
.field__error { font-weight: 500; color: var(--c-danger); }
.field__hint { font-weight: 400; font-size: var(--fs-sm); color: var(--c-text-muted); }

/* ---------- Badges / etiquetas ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 600; border-radius: var(--r-pill); padding: 3px 10px; white-space: nowrap; line-height: 1.3; }
.badge__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.stage-novo  { background: var(--st-novo-bg);  color: var(--st-novo-fg); }  .stage-novo  .badge__dot { background: var(--st-novo-dot); }
.stage-ia    { background: var(--st-ia-bg);    color: var(--st-ia-fg); }    .stage-ia    .badge__dot { background: var(--st-ia-dot); }
.stage-fu    { background: var(--st-fu-bg);    color: var(--st-fu-fg); }    .stage-fu    .badge__dot { background: var(--st-fu-dot); }
.stage-vend  { background: var(--st-vend-bg);  color: var(--st-vend-fg); }  .stage-vend  .badge__dot { background: var(--st-vend-dot); }
.stage-venda { background: var(--st-venda-bg); color: var(--st-venda-fg); } .stage-venda .badge__dot { background: var(--st-venda-dot); }
.stage-cli   { background: var(--st-cli-bg);   color: var(--st-cli-fg); }   .stage-cli   .badge__dot { background: var(--st-cli-dot); }
.stage-dorm  { background: var(--st-dorm-bg);  color: var(--st-dorm-fg); }  .stage-dorm  .badge__dot { background: var(--st-dorm-dot); }
.stage-perd  { background: var(--st-perd-bg);  color: var(--st-perd-fg); }  .stage-perd  .badge__dot { background: var(--st-perd-dot); }

.order-orcamento { background: #eceff4; color: #3f4b5e; }
.order-aberto    { background: #fdf1bf; color: #6f4b00; }
.order-pago      { background: #dff3e6; color: #16613a; }
.order-enviado   { background: #e1ecfa; color: #174f8f; }
.order-entregue  { background: #1d6b3e; color: #fff; }
.order-cancelado { background: #fde6e4; color: #a01c14; text-decoration: line-through; }

.tag { font-size: var(--fs-xs); font-weight: 600; border-radius: var(--r-sm); padding: 2px 6px; background: #eef2f8; color: var(--c-text-2); white-space: nowrap; }
.tag--revenda { background: #e6e0fa; color: #4b2fa0; }
.tag--ia-pausada { background: #fdefc8; color: #7a4300; }
.tag--nao-quer { background: #fde6e4; color: #a01c14; }

.avatar { border-radius: 50%; background: #dbe6f5; color: #174f8f; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
.avatar--sm { width: 32px; height: 32px; font-size: 12px; }
.avatar--md { width: 40px; height: 40px; font-size: 14px; }
.avatar--lg { width: 64px; height: 64px; font-size: 22px; }
.avatar--anon { background: #eceff4; color: var(--c-text-muted); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-3); }
.kpi { background: #fff; border: 1px solid var(--c-border); border-radius: var(--r-lg); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.kpi__label { font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-muted); }
.kpi__value { font-size: var(--fs-kpi); font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi--urgent { background: var(--c-amber-bg); border: 2px solid var(--c-amber); color: var(--c-text); text-decoration: none; }
.kpi--urgent .kpi__label, .kpi--urgent .kpi__cta { color: var(--c-amber-ink); }

/* ---------- Kanban ---------- */
.board { display: flex; gap: var(--sp-3); overflow-x: auto; padding-bottom: var(--sp-2); align-items: flex-start; scroll-snap-type: x proximity; }
.col { flex: 1 0 232px; max-width: 300px; background: var(--c-col); border-radius: var(--r-lg); display: flex; flex-direction: column; position: relative; scroll-snap-align: start; }
.col__head { padding: 10px 12px 8px; background: #fff; border-radius: var(--r-lg) var(--r-lg) 0 0; border-top: 4px solid var(--stage-color); border-bottom: 1px solid var(--c-border); }
.col__name { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.col__count { margin-left: auto; font-size: var(--fs-sm); font-weight: 700; background: #eef2f8; color: var(--c-text-2); border-radius: var(--r-pill); padding: 1px 8px; font-variant-numeric: tabular-nums; }
.col__desc { font-size: var(--fs-sm); color: var(--c-text-muted); margin-top: 2px; }
.col__body { padding: var(--sp-2); display: flex; flex-direction: column; gap: var(--sp-2); min-height: 120px; }
.col--urgent { background: var(--c-amber-col); max-width: 320px; }
.col--urgent .col__count { background: var(--c-amber); color: #2b1a00; }
.col--drop-target { outline: 2px solid var(--c-amber); outline-offset: -2px; }  /* aplicar em qualquer coluna durante dragover */
.col__drop-slot { border: 2px dashed var(--c-amber); background: #fffbef; border-radius: var(--r-md); height: 92px; display: flex; align-items: center; justify-content: center; font-size: var(--fs-sm); font-weight: 600; color: var(--c-amber-ink); }
.col__origin-slot { border: 2px dashed var(--c-border-btn2); border-radius: var(--r-md); height: 92px; background: rgba(255,255,255,.4); }
.col__empty { border: 1px dashed var(--c-border-btn2); border-radius: var(--r-md); padding: 28px 14px; text-align: center; color: var(--c-text-muted); font-size: var(--fs-md); background: rgba(255,255,255,.5); }
.col-strip { flex: none; width: 52px; background: #fff; border: 1px solid var(--c-border); border-radius: var(--r-lg); display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0; cursor: pointer; font: inherit; color: var(--c-text); }
.col-strip:hover { background: var(--c-primary-soft-2); }
.col-strip__label { writing-mode: vertical-rl; font-weight: 700; font-size: var(--fs-md); }

.lead { display: block; background: #fff; border: 1px solid var(--c-border); border-radius: var(--r-md); padding: 10px 11px; color: var(--c-text); text-decoration: none; cursor: grab; }
.lead:hover { border-color: #9db5d6; color: var(--c-text); box-shadow: 0 1px 3px rgba(15,39,71,.08); }
.lead--dragging { opacity: .95; transform: rotate(-3deg); box-shadow: var(--shadow-drag); border-color: var(--c-primary); cursor: grabbing; }
.lead__head { display: flex; gap: 9px; align-items: flex-start; }
.lead__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead__name--anon { color: var(--c-text-muted); font-style: italic; }
.lead__phone { font-size: var(--fs-sm); color: var(--c-text-muted); font-variant-numeric: tabular-nums; }
.lead__time { margin-left: auto; padding-top: 2px; font-size: var(--fs-xs); color: var(--c-text-muted); white-space: nowrap; }
.lead__time--late { color: #9a3412; font-weight: 700; } /* Venda p/ finalizar esperando > 1 h */
.lead__msg { margin: 8px 0 0; font-size: var(--fs-md); color: var(--c-text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lead__msg b { font-weight: 600; color: var(--c-text); }
.lead__tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }

/* ---------- Tabela ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-muted); padding: 10px 16px; border-bottom: 1px solid var(--c-border); background: var(--c-surface-2); white-space: nowrap; }
.table td { padding: 11px 16px; border-bottom: 1px solid var(--c-border-soft); vertical-align: middle; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: #f5f8fc; }
.table .right { text-align: right; }
.table-foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; font-size: var(--fs-md); color: var(--c-text-muted); background: var(--c-surface-2); }

/* ---------- Abas ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--c-border); overflow-x: auto; }
.tab { display: flex; align-items: center; gap: 6px; padding: 10px 14px; min-height: 44px; color: var(--c-text-2); font-weight: 500; text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--c-text); }
.tab.active { color: var(--c-navy); font-weight: 700; border-bottom-color: var(--c-primary); }
.tab__count { font-size: var(--fs-xs); font-weight: 700; background: var(--c-primary-soft); color: #174f8f; border-radius: var(--r-pill); padding: 1px 7px; }

/* ---------- Faixas / estados ---------- */
.banner { display: flex; gap: 10px; align-items: center; border-radius: var(--r-lg); padding: 12px 16px; font-size: var(--fs-base); }
.banner--paused { background: var(--c-amber-bg); border: 1px solid #f0cf7a; color: #5c3400; }
.banner--info { background: var(--c-primary-soft-2); border: 1px solid #cfdcee; color: #1f3556; font-size: var(--fs-md); }
.banner--revenda { background: #f1edfd; border: 1px solid #d9d0f6; color: #2f1f6b; font-size: var(--fs-md); }
.banner--error { background: var(--c-danger-bg); border: 1px solid var(--c-danger-line); color: #8a1a12; font-size: var(--fs-md); }
.saved { color: var(--c-success); font-weight: 600; font-size: var(--fs-md); }
.empty { border: 1px dashed var(--c-border-btn2); border-radius: var(--r-md); padding: 18px; text-align: center; color: var(--c-text-muted); font-size: var(--fs-md); }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--c-border); border-top-color: var(--c-primary); animation: spin .8s linear infinite; }
.skeleton { background: #e3e8ef; border-radius: 6px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .spinner, .skeleton { animation: none; } .btn { transition: none; } }

/* ---------- Chat ---------- */
.chat { padding: 12px 22px 20px; display: flex; flex-direction: column; gap: 10px; background: #f6f8fb; }
.chat__day { display: flex; align-items: center; gap: 12px; font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-muted); margin: 8px 0; }
.chat__day::before, .chat__day::after { content: ""; flex: 1; height: 1px; background: var(--c-border); }
.msg { max-width: 68%; display: flex; flex-direction: column; gap: 3px; }
.msg--in { align-self: flex-start; }
.msg--out { align-self: flex-end; align-items: flex-end; }
.msg__who { font-size: var(--fs-xs); font-weight: 700; }
.msg__bubble { border-radius: 12px; padding: 9px 12px 6px; }
.msg--cliente .msg__bubble { background: #fff; border: 1px solid var(--c-border); border-top-left-radius: 4px; }
.msg--cliente .msg__who { color: var(--c-text-2); }
.msg--amanda .msg__bubble { background: var(--st-ia-bg); border: 1px solid #d6cdf6; border-top-right-radius: 4px; }
.msg--amanda .msg__who { color: var(--st-ia-fg); }
.msg--vendedor .msg__bubble { background: var(--c-primary); color: #fff; border-top-right-radius: 4px; }
.msg--vendedor .msg__who { color: #174f8f; }
.msg--vendedor .msg__time { color: #d3e1f3; }
.msg__time { display: block; text-align: right; font-size: var(--fs-xs); color: var(--c-text-muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.msg__media { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); font-weight: 700; color: var(--c-text-2); background: rgba(15,39,71,.07); border-radius: var(--r-sm); padding: 1px 6px; margin-bottom: 4px; }

/* ---------- Responsivo ---------- */
@media (max-width: 767px) {
  .topbar { height: var(--topbar-h-mobile); padding: 0 12px; gap: 8px; justify-content: space-between; }
  .topbar__logo { height: 28px; }
  .topbar__crm { font-size: 11px; padding-left: 8px; }
  .topbar__nav a { padding: 0 10px; font-size: 13px; }
  .page { padding: 14px; gap: 12px; }
  .page-title { font-size: var(--fs-h1-mobile); }
  .btn, .input { min-height: var(--ctl-h-touch); }
  .input { font-size: 16px; } /* evita zoom no iOS */
  .msg { max-width: 85%; }
}
