/* =============================================
   SDR Visimob — Panel structural styles
   Built strictly on Visimob design tokens (tokens.css). No new colors.
   ============================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-brand);
  background: var(--color-off-white);
  color: var(--fg1);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}
a { color: var(--color-red); text-decoration: none; }
a:hover { color: var(--color-red-dark); }

/* ── Shell ── */
.shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; }
.topbar {
  background: var(--color-ink); color: #fff;
  display: flex; align-items: center; gap: var(--space-3);
  padding: 12px 24px; border-bottom: 1px solid rgba(255,255,255,.06);
}
.topbar .wordmark { height: 18px; }
.topbar .sep { width: 1px; height: 16px; background: rgba(255,255,255,.2); }
.topbar .sysname { font-weight: 600; font-size: 13px; color: rgba(255,255,255,.85); letter-spacing: .04em; }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: 13px; color: rgba(255,255,255,.7); }
.topbar .user b { color: #fff; font-weight: 600; }
.topbar a.logout { color: rgba(255,255,255,.6); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; margin-left: 16px; }
.topbar a.logout:hover { color: #fff; }

.body-grid { display: grid; grid-template-columns: 220px 1fr; min-height: 0; }
.sidebar { background: #0F0C0C; padding: 20px 0; }
.nav-group { margin-bottom: 18px; }
.nav-group-label { font-size: 9px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: rgba(255,255,255,.3); padding: 0 24px; margin-bottom: 8px; }
.nav-item {
  display: block; padding: 10px 24px; font-size: 13px; font-weight: 500;
  color: rgba(255,255,255,.65); border-left: 2px solid transparent;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,.04); }
.nav-item.active { color: #fff; background: var(--color-red-subtle); border-left-color: var(--color-red); font-weight: 600; }
.content { padding: 32px 48px; min-width: 0; }

/* ── Page header ── */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 28px; }
.page-eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--color-red); margin-bottom: 8px; }
.page-title { font-size: var(--text-2xl); font-weight: 900; line-height: 1; letter-spacing: -.02em; color: var(--fg1); }
.page-meta { font-size: 12px; color: var(--fg3); text-align: right; line-height: 1.7; }

/* ── Buttons ── */
.btn { font-family: var(--font-brand); font-weight: 700; font-size: 14px; letter-spacing: .04em; border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: all .15s ease; text-transform: uppercase; text-decoration: none; }
.btn-primary { background: var(--color-red); color: #fff; padding: 12px 24px; border-radius: var(--radius-sm); }
.btn-primary:hover { background: var(--color-red-dark); color: #fff; }
.btn-dark { background: var(--color-ink); color: #fff; padding: 12px 24px; border-radius: var(--radius-sm); }
.btn-outline { background: transparent; color: var(--color-red); padding: 11px 24px; border-radius: var(--radius-sm); border: 2px solid var(--color-red); }
.btn-outline-dark { background: transparent; color: var(--color-ink); padding: 11px 24px; border-radius: var(--radius-sm); border: 2px solid var(--color-ink); }
.btn-ghost { background: transparent; color: var(--color-red); padding: 12px 18px; border-radius: var(--radius-sm); }
.btn-win { background: #16a34a; color: #fff; padding: 12px 24px; border-radius: var(--radius-sm); }
.btn-win:hover { background: #15803d; color: #fff; }
.btn-sm { font-size: 12px; padding: 9px 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Cards ── */
.card { background: #fff; border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 24px; }
.card + .card { margin-top: 16px; }
.card-label { font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--color-red); margin-bottom: 12px; }
.card-title { font-size: var(--text-lg); font-weight: 700; color: var(--fg1); margin-bottom: 6px; }
.card-text { font-size: 13px; color: var(--fg3); line-height: 1.5; }

/* ── Stat cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; margin-bottom: 16px; }
.stat-card { border-radius: var(--radius-md); padding: 22px 24px; }
.stat-card.red { background: var(--color-red); }
.stat-card.ink { background: var(--color-ink); }
.stat-card.white { background: #fff; box-shadow: var(--shadow-md); }
.stat-num { font-size: var(--text-2xl); font-weight: 900; line-height: 1; letter-spacing: -.02em; }
.stat-card.red .stat-num, .stat-card.ink .stat-num { color: #fff; }
.stat-card.white .stat-num { color: var(--fg1); }
.stat-desc { font-size: 12px; margin-top: 6px; }
.stat-card.red .stat-desc { color: rgba(255,255,255,.8); }
.stat-card.ink .stat-desc { color: rgba(255,255,255,.6); }
.stat-card.white .stat-desc { color: var(--fg3); }

/* ── Badges ── */
.badge { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 5px 12px; border-radius: var(--radius-full); display: inline-flex; align-items: center; line-height: 1; }
.badge-red { background: var(--color-red); color: #fff; }
.badge-ink { background: var(--color-ink); color: #fff; }
.badge-outline { background: transparent; color: var(--color-red); border: 1.5px solid var(--color-red); }
.badge-subtle { background: var(--color-red-subtle); color: var(--color-red); }
.badge-light { background: var(--color-surface); color: var(--fg2); border: 1px solid var(--color-border); }

/* ── Forms ── */
.field-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--fg3); }
.field-input, .field-select, .field-textarea {
  font-family: var(--font-brand); font-size: 15px; font-weight: 400; color: var(--fg1); background: #fff;
  border: 1.5px solid var(--color-border); border-radius: var(--radius-sm); padding: 12px 16px; outline: none;
  transition: border-color .15s; width: 100%;
}
.field-textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.field-input:focus, .field-select:focus, .field-textarea:focus { border-color: var(--color-red); }
.field-input.error { border-color: var(--color-red); }
.field-error { font-size: 11px; color: var(--color-red); }
.field-help { font-size: 11px; color: var(--fg3); }
.fields-row { display: flex; gap: 12px; }
.fields-row > .field-group { flex: 1; }
.secret-row { display: flex; gap: 8px; align-items: center; }
.secret-row .field-input { flex: 1; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.checkbox-row label { font-size: 13px; color: var(--fg2); }

/* ── Table ── */
.table-wrap { background: #fff; border-radius: var(--radius-md); box-shadow: var(--shadow-md); overflow: hidden; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--fg3); padding: 14px 16px; border-bottom: 1px solid var(--color-border); }
table.data td { padding: 14px 16px; font-size: 14px; color: var(--fg2); border-bottom: 1px solid var(--color-surface); }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--color-off-white); }
table.data a.row-link { color: var(--fg1); font-weight: 600; }

/* ── Filters ── */
.filters { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 16px; flex-wrap: wrap; }
.filters .field-group { margin-bottom: 0; min-width: 160px; }

/* ── Flash ── */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; margin-bottom: 16px; }
.flash.success { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3); color: #166534; }
.flash.error { background: var(--color-red-subtle); border: 1px solid rgba(232,25,44,.3); color: var(--color-red); }
.flash.info { background: var(--color-surface); border: 1px solid var(--color-border); color: var(--fg2); }

/* ── Login ── */
.login-wrap { min-height: 100vh; background: var(--color-ink); display: flex; align-items: center; justify-content: center; position: relative; }
.login-accent { position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--color-red); }
.login-card { background: #fff; padding: 36px 32px; width: 340px; border-radius: 2px; box-shadow: var(--shadow-lg); }
.login-logo-row { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--color-border); }
.login-logo-row .visimob { font-weight: 900; font-size: 15px; color: var(--color-ink); }
.login-logo-row .sep { width: 1px; height: 16px; background: var(--color-border); }
.login-logo-row .sysname { font-weight: 600; font-size: 13px; color: var(--fg3); }
.login-headline { font-weight: 800; font-size: 20px; color: var(--fg1); margin-bottom: 4px; }
.login-sub { font-weight: 300; font-size: 13px; color: var(--fg3); margin-bottom: 24px; }

/* ── Lead detail ──
   Conversa STICKY no centro com rolagem própria; os cards se dividem em duas laterais que rolam
   com a página (leitura à esquerda, trabalho à direita) — nunca sobra tela vazia. Em telas
   médias as duas laterais empilham numa coluna só; no mobile tudo empilha. */
.lead-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.lead-chat { position: sticky; top: 20px; grid-column: 1; grid-row: 1 / span 2;
  display: flex; flex-direction: column; gap: 16px; height: calc(100vh - 40px); min-width: 0; }
.lead-chat .card { flex: 0 0 auto; }
.lead-col { min-width: 0; }
.lead-col-work { grid-column: 2; grid-row: 1; }
.lead-col-info { grid-column: 2; grid-row: 2; }
@media (min-width: 1281px) {
  .lead-grid { grid-template-columns: 300px minmax(0, 1fr) 340px; }
  .lead-col-info { grid-column: 1; grid-row: 1; }
  .lead-chat { grid-column: 2; grid-row: 1; }
  .lead-col-work { grid-column: 3; grid-row: 1; }
}
.transcript { background: #fff; border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 20px; flex: 1 1 auto; min-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 78%; padding: 10px 14px; font-size: 14px; line-height: 1.45; }
.bubble .meta { font-size: 10px; margin-top: 5px; opacity: .7; }
.bubble.inbound { align-self: flex-start; background: var(--color-surface); color: var(--fg1); border-radius: var(--radius-md) var(--radius-md) var(--radius-md) 2px; }
.bubble.outbound { align-self: flex-end; background: var(--color-red); color: #fff; border-radius: var(--radius-md) var(--radius-md) 2px var(--radius-md); }
.bubble.outbound .meta { color: rgba(255,255,255,.75); }
.bubble.system { align-self: center; background: transparent; color: var(--fg3); font-size: 11px; font-style: italic; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--color-surface); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--fg3); }
.kv .v { color: var(--fg1); font-weight: 600; text-align: right; }
.score-big { font-size: var(--text-3xl); font-weight: 900; line-height: 1; color: var(--color-red); }

/* ── Timeline ── */
.timeline { list-style: none; }
.timeline li { position: relative; padding: 0 0 16px 20px; border-left: 1px solid var(--color-border); }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ''; position: absolute; left: -4px; top: 4px; width: 7px; height: 7px; border-radius: 50%; background: var(--color-red); }
.timeline .t-meta { font-size: 10px; color: var(--fg3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 2px; }
.timeline .t-body { font-size: 13px; color: var(--fg2); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.section-sep { height: 1px; background: var(--color-border); margin: 20px 0; }
.muted { color: var(--fg3); }
.right { text-align: right; }
.mb-0 { margin-bottom: 0; }
.repeat-row { display: flex; gap: 8px; margin-bottom: 8px; }
.repeat-row .field-input { flex: 1; margin: 0; }

/* ── Abas da configuração do agente ── */
.atabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--color-border);
  overflow-x: auto; -webkit-overflow-scrolling: touch; }
.atab { background: none; border: none; cursor: pointer; font-family: var(--font-brand);
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--fg3); padding: 10px 14px; border-bottom: 2px solid transparent; white-space: nowrap; }
.atab:hover { color: var(--fg1); }
.atab.active { color: var(--color-red); border-bottom-color: var(--color-red); }
/* cards tabulados nascem ocultos (o JS mostra a aba ativa) — evita o flash da página inteira
   antes do script rodar; o <noscript> do template reexibe tudo sem JS */
[data-atab] { display: none; }

/* ── CRM kanban ── */
.kanban { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 16px; }
.kanban-col { flex: 0 0 232px; background: var(--color-surface); border-radius: var(--radius-md); padding: 10px; min-height: 120px; }
.kanban-col.dropover { outline: 2px dashed var(--color-red); outline-offset: -2px; }
.kanban-col-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 6px 10px; }
.kanban-col-title { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--fg2); }
.kanban-col-count { font-size: 11px; font-weight: 700; color: var(--fg3); background: #fff; border-radius: var(--radius-full); padding: 2px 9px; }
.kanban-col-body { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.kanban-card { background: #fff; border-radius: var(--radius-sm); box-shadow: var(--shadow-md); padding: 10px 12px; cursor: default; }
.kanban-card[draggable="true"] { cursor: grab; }
.kanban-card.dragging { opacity: .45; }
.kanban-card-name { display: block; font-size: 13px; font-weight: 700; color: var(--fg1); margin-bottom: 4px; }
.kanban-card-meta { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.kanban-card-emp { font-size: 11px; color: var(--fg2); margin-top: 4px; }
.kanban-card-time { font-size: 10px; margin-top: 4px; }
.crm-score { font-size: 10px; font-weight: 800; border-radius: var(--radius-full); padding: 2px 8px; line-height: 1.3; }
.crm-score--hot { background: var(--color-red); color: #fff; }
.crm-score--warm { background: var(--color-red-subtle); color: var(--color-red); }
.crm-score--cold { background: #fff; color: var(--fg3); border: 1px solid var(--color-border); }
.kanban-toast { position: fixed; right: 24px; bottom: 24px; background: var(--color-ink); color: #fff;
  padding: 12px 18px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 50; }
.kanban-toast.error { background: var(--color-red); }

/* ── Modal de ações do calendário ── */
.cal-overlay { position: fixed; inset: 0; background: rgba(15,12,12,.45); z-index: 40;
  display: flex; align-items: center; justify-content: center; padding: 16px; }
/* display:flex acima venceria o [hidden] do user-agent — sem esta regra o overlay nasceria visível */
.cal-overlay[hidden] { display: none; }
.cal-modal { background: #fff; border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  padding: 24px; width: 100%; max-width: 420px; }
.cal-actions { display: flex; flex-direction: column; gap: 8px; }
.cal-actions .btn { width: 100%; }

/* ── Responsivo ──
   O desktop permanece intacto; abaixo de 960px a sidebar vira uma barra horizontal rolável,
   os grids empilham e as tabelas ganham rolagem própria (a página nunca estoura na largura). */
@media (max-width: 960px) {
  .body-grid { grid-template-columns: 1fr; }
  .sidebar { display: flex; gap: 2px; overflow-x: auto; padding: 6px 10px; align-items: center;
    -webkit-overflow-scrolling: touch; }
  .nav-group { display: flex; margin-bottom: 0; align-items: center; }
  .nav-group-label { display: none; }
  .nav-item { padding: 9px 12px; border-left: none; border-bottom: 2px solid transparent;
    white-space: nowrap; font-size: 12px; }
  .nav-item.active { border-left: none; border-bottom-color: var(--color-red); background: transparent; }
  .content { padding: 18px 14px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; margin-bottom: 18px; }
  .page-meta { text-align: left; }
  .lead-grid { grid-template-columns: 1fr; }
  .lead-chat, .lead-col-info, .lead-col-work { grid-column: auto; grid-row: auto; }
  .lead-chat { position: static; height: auto; order: 0; }
  .lead-col-work { order: 1; }
  .lead-col-info { order: 2; }
  .transcript { max-height: 70vh; min-height: 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .fields-row { flex-direction: column; gap: 0; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.data { min-width: 640px; }
  .filters .field-group { min-width: 130px; flex: 1; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .topbar { padding: 10px 12px; flex-wrap: wrap; }
  .topbar .user { font-size: 11px; }
  .content { padding: 14px 10px; }
  .kanban-col { flex: 0 0 200px; }
  .bubble { max-width: 92%; }
  .transcript { padding: 12px; }
  .card { padding: 16px; }
  .login-card { width: calc(100vw - 32px); max-width: 340px; }
}
