/* Área do cliente + webchat — mesma identidade do portal (faq-site), sem fontes ou recursos externos */
:root {
  --navy: #06152f;
  --navy-2: #091f43;
  --blue: #0758b7;
  --blue-2: #0b93e8;
  --yellow: #ffc400;
  --ink: #0a1730;
  --muted: #60708a;
  --line: #dbe4ef;
  --soft: #f4f7fb;
  --chat-bg: #eef2f8;
  --bubble-in: #fff;
  --bubble-out: #dcecfd;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --success: #1e8449;
  --success-soft: #e8f6ee;
  --warn-soft: #fff8e1;
  --radius: 18px;
  color-scheme: light;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--soft);
}
img { max-width: 100%; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.wrap { width: min(760px, 100% - 32px); margin-inline: auto; }

.topbar { background: linear-gradient(145deg, var(--navy-2), var(--navy)); padding: calc(16px + env(safe-area-inset-top, 0px)) 0 16px; }
.logo { height: 38px; width: auto; display: block; }

.page { flex: 1; padding-block: 24px 40px; display: grid; gap: 18px; align-content: start; }
.dashboard, .dash-main { display: grid; gap: 18px; }

.card { padding: 22px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(10, 40, 80, .05); }
.card h1 { margin: 0 0 6px; font-size: clamp(22px, 5vw, 28px); line-height: 1.2; }
.card h2 { margin: 0 0 8px; font-size: 20px; line-height: 1.25; }
.muted { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.hello h1 { margin: 0; }
.hello .muted { margin: 6px 0 0; }

.loading { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--blue-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

label { display: grid; gap: 6px; font-size: 14px; font-weight: 700; color: #253954; }
label small { font-weight: 400; color: var(--muted); }
input {
  width: 100%; min-height: 48px; padding: 0 14px;
  border: 1px solid #c9d6e5; border-radius: 12px; background: #fff;
  font: inherit; font-size: 16px; color: var(--ink);
}
input[type=file] { padding: 10px; min-height: 0; }
input:focus, textarea:focus { outline: 3px solid rgba(11, 147, 232, .25); border-color: var(--blue-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border: 1px solid transparent; border-radius: 12px;
  font: inherit; font-weight: 800; cursor: pointer; text-decoration: none;
}
.btn[disabled] { opacity: .6; cursor: progress; }
.btn-primary { color: var(--navy); background: var(--yellow); }
.btn-secondary { color: #fff; background: linear-gradient(135deg, var(--blue), var(--blue-2)); }
.btn-outline { color: var(--blue); background: #fff; border-color: #cad9ea; min-height: 42px; padding: 0 14px; font-size: 14px; }
.btn-block { width: 100%; }

.form-error { margin: 0; padding: 10px 14px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 14px; font-weight: 600; }
.result { padding: 12px 14px; border-radius: 12px; font-size: 15px; font-weight: 600; }
.result.success { background: var(--success-soft); color: var(--success); }
.result.warn { background: var(--warn-soft); color: #5c4b00; }

/* Serviços */
.services, .invoices { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.service, .invoice { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--soft); }
.service { display: grid; gap: 12px; }
.service-head, .invoice-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; align-items: center; }
.service strong, .invoice strong { font-size: 16px; }
.service-addr { margin: -8px 0 0; color: var(--muted); font-size: 13px; }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; background: #e5f2fd; color: var(--blue); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.ok { background: var(--success-soft); color: var(--success); }
.service-actions { display: grid; gap: 10px; }
.service-actions p { margin: 0; font-size: 14px; color: var(--muted); }

/* Habilitação até 00h */
.fallback { display: grid; gap: 12px; padding: 16px; border-radius: 14px; background: #fff; border: 1px solid #ffe08a; box-shadow: inset 4px 0 0 var(--yellow); }
.fallback h3 { margin: 0; font-size: 16px; }
.fallback p { margin: 0; font-size: 14px; color: #4a4a3a; }
.fallback ul { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.fallback form { display: grid; gap: 12px; }
.fallback .fallback-motivo { color: var(--muted); font-size: 13px; }
.fallback-choices { display: flex; flex-wrap: wrap; gap: 10px; }
.fallback-choices .btn { flex: 1 1 160px; }

/* Wi-Fi */
.wifi-form { display: grid; gap: 12px; }
.wifi-form p { margin: 0; font-size: 14px; color: var(--muted); }
.wifi-redes { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.wifi-redes li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--soft); font-size: 14px; }
.wifi-redes span { color: var(--muted); font-size: 12px; font-weight: 700; }
.wifi-form .wifi-aviso { padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: #5c4b00; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: 18px; height: 18px; min-height: 0; margin: 0; }
.btn-link { justify-self: center; min-height: 40px; background: none; color: var(--blue); text-decoration: underline; }

/* Atalhos */
.dash-side { display: grid; gap: 18px; align-content: start; }
.quick { padding: 16px; }
.quick h2 { margin: 0 0 12px; font-size: 16px; }
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.quick-btn {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--soft);
  font: inherit; font-size: 14px; font-weight: 700; line-height: 1.2; color: var(--ink); text-align: left; cursor: pointer;
}
.quick-btn:hover { border-color: var(--blue-2); background: #eaf4fe; }
.quick-btn:focus-visible { outline: 3px solid rgba(11, 147, 232, .45); }
.quick-icon { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: var(--navy); background: var(--yellow); }
.quick-icon svg { width: 19px; height: 19px; }

/* Janela dos atalhos */
.modal { position: fixed; inset: 0; z-index: 9; display: grid; place-items: center; padding: 16px; background: rgba(6, 21, 47, .55); }
.modal-box { width: min(440px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; border-radius: var(--radius); background: #fff; box-shadow: 0 24px 60px rgba(6, 21, 47, .35); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 10px 6px 20px; }
.modal-head h2 { flex: 1; margin: 0; font-size: 18px; }
.modal-head .icon-btn { color: var(--muted); }
.modal-body { display: grid; gap: 12px; padding: 6px 20px 20px; }
.modal-text { margin: 0; color: #253954; font-size: 15px; }
.modal-sub { margin: 0; color: var(--muted); font-size: 13px; font-weight: 700; }
.modal-list { display: grid; gap: 8px; }
.modal-loading { display: flex; align-items: center; gap: 12px; margin: 8px 0; color: var(--muted); }

/* Renegociação */
.reneg {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  margin: 4px 0 14px; padding: 14px 16px; border-radius: 14px;
  background: var(--danger-soft); border: 1px solid #f5c6c0;
}
.reneg strong { color: var(--danger); }
.reneg p { margin: 2px 0 0; font-size: 14px; color: #5a2a24; }
.reneg .btn { min-height: 44px; }
.reneg-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.reneg-lista li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 12px; border-radius: 10px; background: var(--soft); font-size: 14px; }
.reneg-total { margin: 0; text-align: right; font-size: 15px; }
.reneg-total strong { font-size: 18px; }
.reneg-campo { display: grid; gap: 8px; font-size: 14px; font-weight: 700; color: #253954; }
.reneg-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  flex: 1 1 0; min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid #c9d6e5;
  background: #fff; font: inherit; font-size: 14px; font-weight: 700; color: var(--ink); cursor: pointer; white-space: nowrap;
}
.chip.on { border-color: var(--blue); background: #e5f2fd; color: var(--blue); box-shadow: inset 0 0 0 1px var(--blue); }
.chip:focus-visible { outline: 3px solid rgba(11, 147, 232, .45); }

/* Faturas */
.invoice-value { font-size: 20px; font-weight: 900; }
.invoice-meta { color: var(--muted); font-size: 13px; }
.code-box { margin-top: 12px; }
.code-box span { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.code-box code {
  display: block; padding: 10px 12px; border-radius: 10px; background: #fff; border: 1px dashed #c9d6e5;
  font-size: 13px; word-break: break-all; user-select: all;
}
.invoice-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.invoice-actions .btn-primary { min-height: 42px; font-size: 14px; padding: 0 14px; }
.invoice details { margin-top: 10px; }
.invoice summary { cursor: pointer; color: var(--blue); font-size: 14px; font-weight: 700; }
.pix { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-top: 12px; padding: 14px; border-radius: 14px; background: #fff; border: 1px solid var(--line); }
.pix-qr { flex: 0 0 auto; width: 176px; height: 176px; }
.pix-qr svg { display: block; width: 100%; height: 100%; }
.pix-info { flex: 1 1 220px; display: grid; gap: 8px; }
.pix-info strong { font-size: 16px; }
.pix-info p { margin: 0; color: var(--muted); font-size: 14px; }
.empty { padding: 14px; border-radius: 12px; background: var(--success-soft); color: var(--success); font-weight: 600; }

/* --- Conversa ----------------------------------------------------------------------------- */
.chat-card {
  display: flex; flex-direction: column; height: min(640px, 82vh); min-height: 420px;
  border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  background: var(--chat-bg); box-shadow: 0 10px 30px rgba(10, 40, 80, .05);
}
.chat-head { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 14px; color: #fff; background: linear-gradient(145deg, var(--navy-2), var(--navy)); }
.agent-avatar { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: #fff; display: grid; place-items: center; }
.agent-avatar img { width: 32px; height: 32px; }
.chat-title { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.chat-title strong { font-size: 16px; }
.chat-status { font-size: 13px; color: #b9c8de; }
.chat-status::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #3ddc84; vertical-align: 1px; }
.chat-status.offline::before { background: #8a9ab3; }
.chat-proto { font-size: 12px; color: #b9c8de; text-align: right; }

.icon-btn {
  flex: 0 0 auto; width: 42px; height: 42px; border: 0; border-radius: 50%;
  display: grid; place-items: center; color: inherit; background: transparent; cursor: pointer;
}
.icon-btn:hover { background: rgba(127, 150, 180, .16); }
.icon-btn:focus-visible, .send-btn:focus-visible { outline: 3px solid rgba(11, 147, 232, .45); }
.icon-btn.small { width: 30px; height: 30px; }
.icon-btn.small svg { width: 16px; height: 16px; }

.messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.messages-inner { padding: 12px 14px 8px; display: flex; flex-direction: column; gap: 4px; }

.day-sep { align-self: center; margin: 12px 0 8px; padding: 4px 12px; border-radius: 999px; background: #dfe6f0; color: #4a5b76; font-size: 12px; font-weight: 700; }
.sys-msg { align-self: center; max-width: 90%; margin: 4px 0 8px; padding: 6px 12px; border-radius: 10px; background: var(--warn-soft); color: #5c4b00; font-size: 13px; text-align: center; }

.msg { display: flex; flex-direction: column; max-width: min(80%, 480px); }
.msg.in { align-self: flex-start; }                       /* suporte */
.msg.out { align-self: flex-end; align-items: flex-end; } /* cliente */
.msg.first { margin-top: 8px; }

.bubble {
  position: relative; padding: 8px 12px 6px; border-radius: 16px;
  background: var(--bubble-in); box-shadow: 0 1px 1px rgba(10, 40, 80, .08);
  overflow-wrap: anywhere; white-space: pre-wrap;
}
.msg.out .bubble { background: var(--bubble-out); }
.msg.in.first .bubble { border-top-left-radius: 4px; }
.msg.out.first .bubble { border-top-right-radius: 4px; }
.bubble.media { padding: 4px; }
.bubble.media .caption { padding: 6px 8px 0; }
.bubble.sticker { padding: 0; background: none; box-shadow: none; }
.bubble.sticker img { width: 140px; height: 140px; object-fit: contain; }

.meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; margin-top: 2px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.bubble.media .meta { padding: 0 6px 2px; }
.ticks svg { width: 16px; height: 16px; stroke-width: 2.2; }
.ticks.read { color: var(--blue-2); }
.msg.pending .meta { opacity: .7; }
.msg.failed .bubble { outline: 1px solid var(--danger); }
.retry { margin-top: 2px; padding: 0; border: 0; background: none; color: var(--danger); font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; text-decoration: underline; }

.media-img { display: block; width: 100%; max-width: 300px; max-height: 340px; object-fit: cover; border-radius: 12px; cursor: zoom-in; background: #dfe6f0; }
.media-video { display: block; width: 100%; max-width: 300px; border-radius: 12px; background: #000; }
.media-audio { display: block; width: 250px; max-width: 100%; height: 40px; }

.doc { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 10px; border-radius: 12px; background: rgba(127, 150, 180, .12); color: inherit; text-decoration: none; }
.doc-icon { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; color: #fff; background: var(--danger); font-size: 11px; font-weight: 900; }
.doc-info { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.doc-info strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-info span { font-size: 12px; color: var(--muted); }
.doc .dl { color: var(--blue); }

.chat-empty { align-self: center; margin: auto 0; padding: 24px 12px; color: var(--muted); font-size: 14px; text-align: center; }
.chat-note { flex: 0 0 auto; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); background: #fff; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; text-align: center; }
.chat-note strong { color: var(--ink); }

.composer { flex: 0 0 auto; display: grid; gap: 8px; padding: 8px 10px; background: #fff; border-top: 1px solid var(--line); }
.composer-row { display: flex; align-items: flex-end; gap: 6px; }
.composer .icon-btn { color: var(--muted); }
textarea {
  flex: 1; min-height: 44px; max-height: 140px; padding: 10px 14px; resize: none;
  border: 1px solid #c9d6e5; border-radius: 22px; background: var(--soft);
  font: inherit; font-size: 16px; line-height: 1.4; color: var(--ink);
}
.send-btn {
  flex: 0 0 auto; width: 44px; height: 44px; border: 0; border-radius: 50%;
  display: grid; place-items: center; color: var(--navy); background: var(--yellow); cursor: pointer;
}
.send-btn svg { fill: currentColor; stroke-width: 1.5; }
.send-btn[disabled] { color: #8a9ab3; background: #e6ebf2; cursor: default; }

.attach-chip { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; border-radius: 12px; background: var(--soft); border: 1px solid var(--line); font-size: 14px; }
.attach-icon { color: var(--blue); display: grid; }
.attach-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lightbox { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 56px 16px 16px; background: rgba(6, 21, 47, .92); }
.lightbox img { max-height: 100%; border-radius: 8px; }
.lightbox .icon-btn { position: absolute; top: calc(8px + env(safe-area-inset-top, 0px)); right: 8px; color: #fff; }

.footer { background: #fff; border-top: 1px solid var(--line); padding: 18px 0 calc(18px + env(safe-area-inset-bottom, 0px)); font-size: 14px; color: var(--muted); }
.footer .wrap { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.footer strong { color: var(--ink); }

/* Computador: a página ocupa exatamente a tela; painel rola à esquerda e o chat fica à direita, na altura toda */
@media (min-width: 1024px) {
  body { height: 100vh; height: 100dvh; overflow: hidden; }
  .topbar .wrap, .footer .wrap, .page { width: min(1320px, 100% - 48px); }
  .page { display: flex; flex-direction: column; min-height: 0; padding-block: 20px; }
  .page > .card { width: min(760px, 100%); align-self: center; }  /* carregando / sem acesso */
  .dashboard { flex: 1; min-height: 0; grid-template-columns: minmax(0, 1fr) minmax(380px, 440px); grid-template-rows: minmax(0, 1fr); gap: 24px; }
  .dash-main { min-width: 0; min-height: 0; overflow-y: auto; align-content: start; padding-right: 6px; scrollbar-gutter: stable; }
  .dash-side { min-height: 0; grid-template-rows: auto minmax(0, 1fr); gap: 16px; }
  .dash-side:has(> #cardAtalhos[hidden]) { grid-template-rows: minmax(0, 1fr); }
  .chat-card { height: auto; min-height: 0; }
}

@media (max-width: 480px) {
  .card { padding: 18px 16px; }
  .msg { max-width: 86%; }
  .chat-proto { display: none; }
  .invoice-actions .btn { flex: 1 1 100%; }
}
.reneg-detalhe { font-weight: 600; color: var(--muted); }
.reneg-pagar { display: grid; gap: 10px; }
.reneg-pagar .reneg-total { text-align: left; }
.reneg-pagar .pix { margin-top: 0; }

/* Widget do Fluctus dentro do card do chat. As regras no elemento hospedeiro vencem o :host do widget;
   o transform faz os elementos "fixed" de dentro se posicionarem pelo card, não pela tela */
.chat-widget { position: relative; flex: 1; min-height: 0; background: #fff; }
.chat-widget > .chat-empty { display: grid; place-items: center; height: 100%; margin: 0; }
.chat-widget > nwflwc-widget-host {
  position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important;
  z-index: auto !important; transform: translateZ(0); overflow: hidden;
}

/* --- Modo conversa: serviço habilitado — chat em destaque, demais informações compactas --- */
.modo-conversa .dash-main { gap: 12px; }
.modo-conversa .dash-main .card { padding: 14px 16px; }
.modo-conversa .hello h1 { font-size: 20px; }
.modo-conversa .dash-main .card h2 { font-size: 16px; margin-bottom: 6px; }
.modo-conversa .service-addr,
.modo-conversa #cardFaturas > .muted,
.modo-conversa .pix-info p { display: none; }
.modo-conversa .invoice-value { font-size: 17px; }
.modo-conversa .pix { gap: 10px; padding: 10px; }
.modo-conversa .pix-qr { width: 112px; height: 112px; }

/* Celular/tablet: saudação, depois o chat (mais alto) e, abaixo, atalhos, serviço e faturas */
@media (max-width: 1023px) {
  .modo-conversa .dash-main { display: contents; }
  .modo-conversa .dash-side { order: 1; }
  .modo-conversa #cardServicos, .modo-conversa #cardFaturas { order: 2; }
  .modo-conversa #cardChat { order: -1; height: min(760px, 78vh); height: min(760px, 78dvh); }
}

/* Computador: chat na coluna larga, informações numa coluna estreita à esquerda */
@media (min-width: 1024px) {
  .modo-conversa .dashboard { grid-template-columns: minmax(300px, 360px) minmax(0, 1fr); }
}
