/* Painel administrativo — whatsapp-agent (FASE 10, plano §46). Sem JavaScript: o CSP bloqueia scripts. */
:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --border: #dde1e6;
    --text: #1d232b;
    --muted: #677382;
    --accent: #1f6f5c;
    --accent-ink: #ffffff;
    --danger: #b3261e;
    --ok: #1e6b34;
    --in: #ffffff;
    --out: #e7f3ef;
    --human: #fff4dc;
    --radius: 8px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1.25rem 0 .5rem; }
code { font-size: .8rem; background: #eef0f3; padding: 0 .25rem; border-radius: 4px; }
.muted { color: var(--muted); }
.small, small { font-size: .82rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.empty { color: var(--muted); font-style: italic; }

.topbar {
    display: flex; align-items: center; gap: 1.5rem;
    padding: .6rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.brand span { color: var(--accent); }
.topnav { display: flex; gap: 1rem; flex: 1; }
.topnav a { text-decoration: none; font-weight: 600; }
.who { display: flex; align-items: center; gap: .75rem; }
.who form { margin: 0; }

.page { padding: 1.25rem; max-width: 1600px; margin: 0 auto; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.search { display: flex; gap: .5rem; }
.search input { min-width: 18rem; }

input[type=email], input[type=password], input[type=search], textarea {
    width: 100%; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: var(--radius);
    font: inherit; background: var(--surface); color: var(--text);
}
textarea { resize: vertical; }
label { display: block; font-weight: 600; font-size: .9rem; }
label input, label textarea { margin-top: .3rem; font-weight: 400; }
.stack { display: flex; flex-direction: column; gap: .75rem; }

.btn {
    display: inline-block; padding: .5rem .9rem; border-radius: var(--radius); border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; }
.btn-small { padding: .25rem .6rem; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.alert { padding: .6rem .8rem; border-radius: var(--radius); margin: 0 0 1rem; }
.alert-error { background: #fdecea; color: var(--danger); }
.alert-ok { background: #e6f4ea; color: var(--ok); }

.login { max-width: 380px; margin: 10vh auto; background: var(--surface); padding: 2rem; border-radius: 12px; border: 1px solid var(--border); }
.login h1 { margin-bottom: .25rem; }
.login h1 span { color: var(--accent); }

/* Inbox (§46 Tela 1) */
.board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 1rem; align-items: start; }
.column { background: #eceef1; border-radius: 10px; padding: .75rem; min-height: 8rem; }
.column h2 { display: flex; justify-content: space-between; }
.count { background: var(--surface); border-radius: 999px; padding: 0 .55rem; font-size: .8rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .65rem .75rem; margin-bottom: .6rem; }
.card-link { display: flex; flex-direction: column; gap: .1rem; text-decoration: none; color: var(--text); }
.card time { color: var(--muted); font-size: .8rem; }
.card form { margin: .5rem 0 0; }
.column-waiting_human { background: #fbefd6; }
.column-human { background: #dcefe8; }

/* Conversa (§46 Tela 2) */
.conversation-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr) 340px; gap: 1rem; align-items: start; }
.contacts-pane, .lead-pane, .chat-pane { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; }
.contacts-pane ul { list-style: none; margin: 0; padding: 0; }
.contacts-pane li a { display: flex; flex-direction: column; padding: .45rem .5rem; border-radius: 6px; text-decoration: none; color: var(--text); }
.contacts-pane li.active a, .contacts-pane li a:hover { background: var(--out); }
.chat-header { border-bottom: 1px solid var(--border); padding-bottom: .75rem; margin-bottom: 1rem; }
.chat-header p { margin: .25rem 0 0; }
.messages { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: .5rem; max-height: 62vh; overflow-y: auto; }
.message { max-width: 78%; padding: .5rem .75rem; border-radius: 10px; border: 1px solid var(--border); background: var(--in); }
.message.out { align-self: flex-end; background: var(--out); }
.message.out.human { background: var(--human); }
.message p { margin: .2rem 0 0; overflow-wrap: anywhere; }
.message .meta { display: flex; gap: .5rem; align-items: baseline; font-size: .8rem; color: var(--muted); }
.message .meta strong { color: var(--text); }
.status { text-transform: uppercase; font-size: .7rem; letter-spacing: .03em; }
.status-failed { color: var(--danger); }
.composer { display: flex; gap: .5rem; align-items: flex-end; }
.composer textarea { flex: 1; }

.badge { display: inline-block; border-radius: 999px; padding: 0 .5rem; font-size: .75rem; font-weight: 600; background: #eceef1; }
.badge-waiting_human { background: #fbefd6; }
.badge-human { background: #dcefe8; }
.badge-closed, .badge-archived { background: #e4e4e4; color: var(--muted); }
.window-open { color: var(--ok); }
.window-closed { color: var(--danger); }

.fields { display: grid; grid-template-columns: max-content 1fr; gap: .3rem .75rem; margin: 0; }
.fields dt { font-weight: 600; color: var(--muted); font-size: .85rem; }
.fields dd { margin: 0; overflow-wrap: anywhere; }
.fields-inline { max-width: 640px; margin-bottom: 1.5rem; }
.actions { display: flex; flex-direction: column; gap: .5rem; margin: 1rem 0; }
.actions form { margin: 0; }
.confirm-form { border: 1px dashed var(--border); border-radius: var(--radius); padding: .5rem; }
.confirm-form label { font-weight: 400; margin-bottom: .4rem; }
.summary { white-space: pre-wrap; font: inherit; font-size: .85rem; background: var(--bg); padding: .6rem; border-radius: 6px; margin: .5rem 0 0; }
.files { padding-left: 1.1rem; margin: 0; }
.note { background: var(--human); border-radius: 6px; padding: .4rem .6rem; margin-bottom: .5rem; }
.note p { margin: 0; overflow-wrap: anywhere; }
.history { padding-left: 1.1rem; font-size: .85rem; }
details summary { cursor: pointer; font-weight: 600; margin-top: 1rem; }

.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.table th, .table td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
.table th { background: #eceef1; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.error-page { max-width: 560px; margin: 8vh auto; text-align: center; }

@media (max-width: 1100px) {
    .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .conversation-layout { grid-template-columns: 1fr; }
    .contacts-pane { order: 3; }
}
@media (max-width: 640px) {
    .board { grid-template-columns: 1fr; }
    .search input { min-width: 0; }
    .topbar { flex-wrap: wrap; gap: .5rem 1rem; }
    .message { max-width: 100%; }
}

/* Conectar WhatsApp (Cadastro incorporado) */
.connect { max-width: 640px; }
.connect ul { margin: 0; padding-left: 1.2rem; }
