/* =====================================================================
   AtendeAgil · complementos do design system (chat, conexões, robô)
   ===================================================================== */
:root { --wa: #25d366; --wa-dark: #128c7e; }
[hidden] { display: none !important; }
.aa-mark { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 11px; background: var(--grad); }
.aa-mark svg { width: 26px; height: 26px; }
.aa-mark svg path { fill: #fff; }
.aa-mark svg circle { fill: #6d5dfc; }
.login .logo .aa-mark { width: 44px; height: 44px; }

/* ------------------------------------------------------------- chat em 3 colunas */
.content.chat-page { padding: 0; height: 100vh; overflow: hidden; }
.content.chat-page > .flash { margin: 12px; }
.chat { display: grid; grid-template-columns: 340px minmax(0, 1fr) 300px; height: 100vh; }
.chat.no-info { grid-template-columns: 340px minmax(0, 1fr); }
.chat .col-list, .chat .col-info { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.chat .col-info { border-right: 0; border-left: 1px solid var(--line); overflow-y: auto; padding: 18px; }
.chat.no-info .col-info { display: none; }
.list-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.list-head .row { display: flex; gap: 8px; align-items: center; }
.list-head input, .list-head select { padding: 8px 10px; font-size: 13px; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 3px; border-radius: 11px; background: var(--panel-hi); border: 1px solid var(--line); }
.tabs button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 650; padding: 7px 4px;
  border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.tabs button.on { background: var(--panel-solid); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.tabs .n { font-size: 10.5px; padding: 0 6px; border-radius: 99px; background: var(--neutral-bg); }
.tabs button.on .n.hot, .tabs .n.hot { background: var(--wa); color: #04130a; }
.tickets { flex: 1; overflow-y: auto; }
.tk { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line);
  cursor: pointer; position: relative; }
.tk:hover { background: var(--panel-hi); }
.tk.on { background: var(--grad-soft); }
.tk.on::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--grad); }
.av-c { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 750; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, var(--wa-dark), var(--wa)); flex: none; }
.tk b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; }
.tk .last { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk .meta { text-align: right; font-size: 11px; color: var(--dim); display: grid; gap: 4px; justify-items: end; align-content: start; }
.tk .unread { background: var(--wa); color: #04130a; font-weight: 800; font-size: 11px; min-width: 20px; height: 20px; border-radius: 10px;
  display: grid; place-items: center; padding: 0 6px; }
.qtag { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 650; padding: 1px 7px; border-radius: 6px;
  background: var(--neutral-bg); color: var(--label); margin-top: 3px; max-width: 100%; overflow: hidden; white-space: nowrap; }
.qtag i { width: 7px; height: 7px; border-radius: 50%; flex: none; }

.col-chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--panel); }
.chat-head .who { flex: 1; min-width: 0; }
.chat-head .who b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .who small { color: var(--muted); }
.chat-head .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.msgs { flex: 1; overflow-y: auto; padding: 20px 6% 12px; display: flex; flex-direction: column; gap: 4px;
  background-image: radial-gradient(var(--grid) 1px, transparent 1px); background-size: 18px 18px; }
.day-sep { align-self: center; font-size: 11.5px; color: var(--muted); background: var(--panel-solid); border: 1px solid var(--line);
  padding: 3px 12px; border-radius: 8px; margin: 10px 0 6px; }
.ticket-sep { align-self: center; font-size: 11.5px; color: var(--info-fg); background: var(--info-bg); padding: 3px 12px; border-radius: 8px; margin: 12px 0 6px; }
.bubble { max-width: min(560px, 78%); padding: 7px 10px 5px; border-radius: 12px; position: relative; word-wrap: break-word;
  white-space: pre-wrap; font-size: 14px; line-height: 1.4; box-shadow: 0 1px 1px rgba(0,0,0,.12); }
.bubble.in { align-self: flex-start; background: var(--panel-solid); border: 1px solid var(--line); border-top-left-radius: 4px; }
.bubble.out { align-self: flex-end; background: #144d37; color: #e9fff3; border-top-right-radius: 4px; }
[data-theme="light"] .bubble.out { background: #d9fdd3; color: #0b2b1a; }
.bubble.note { align-self: center; max-width: 80%; background: var(--warn-bg); color: var(--warn-fg); border: 1px dashed currentColor; font-size: 13px; }
.bubble.auto { opacity: .88; }
.bubble .by { font-size: 11.5px; font-weight: 700; opacity: .8; margin-bottom: 2px; }
.bubble .tm { font-size: 10.5px; opacity: .7; float: right; margin: 6px 0 -2px 10px; display: inline-flex; align-items: center; gap: 3px; }
.bubble .tick { font-size: 11px; letter-spacing: -3px; padding-right: 3px; }
.bubble .tick.read { color: #53bdeb; }
.bubble .tick.error { color: var(--danger); letter-spacing: 0; }
.bubble img.media, .bubble video.media { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; margin-bottom: 4px; cursor: zoom-in; }
.bubble audio { display: block; max-width: 280px; margin-bottom: 4px; }
.bubble .doc-link { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; background: rgba(0,0,0,.15);
  color: inherit; margin-bottom: 4px; text-decoration: none; }
.bubble .err { font-size: 11px; color: var(--danger); margin-top: 3px; }
.composer { border-top: 1px solid var(--line); padding: 10px 14px; background: var(--panel); position: relative; }
.composer .row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; min-height: 42px; max-height: 160px; padding: 10px 12px; font: inherit; line-height: 1.4; }
.composer .ibtn { width: 42px; height: 42px; }
.composer .send { width: 42px; height: 42px; border-radius: 50%; padding: 0; }
.composer .modes { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
.composer.internal textarea { border-color: var(--warn); background: var(--warn-bg); }
.composer .file-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 8px; background: var(--info-bg);
  color: var(--info-fg); font-size: 12px; }
.composer .file-chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 14px; }
.qr-pop { position: absolute; bottom: calc(100% + 4px); left: 14px; right: 14px; max-height: 260px; overflow-y: auto; background: var(--panel-solid);
  border: 1px solid var(--line-hi); border-radius: 12px; box-shadow: var(--shadow); z-index: 5; }
.qr-pop div { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line); font-size: 13px; }
.qr-pop div.on, .qr-pop div:hover { background: var(--grad-soft); }
.qr-pop b { color: var(--violet-2); margin-right: 6px; }
.blocked-bar { padding: 14px 18px; border-top: 1px solid var(--line); background: var(--panel); display: flex; align-items: center;
  justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.chat-empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 30px; }
.chat-empty .big { width: 84px; height: 84px; border-radius: 26px; display: grid; place-items: center; margin: 0 auto 16px; background: var(--grad-soft); }
.chat-empty .big svg { width: 40px; height: 40px; color: var(--violet-2); }
.info-av { width: 86px; height: 86px; font-size: 28px; margin: 4px auto 10px; }
.col-info h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; color: var(--dim); margin: 20px 0 8px; }
.col-info .field { margin-bottom: 10px; }
.col-info .field input, .col-info .field textarea { font-size: 13px; padding: 8px 10px; }
.tag-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-pick label { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
  font-size: 12px; cursor: pointer; color: var(--muted); }
.tag-pick input { display: none; }
.tag-pick label.on { color: var(--text); border-color: currentColor; background: var(--panel-hi); }
.tag-pick i { width: 8px; height: 8px; border-radius: 50%; }
.past a { display: flex; justify-content: space-between; font-size: 12.5px; padding: 6px 0; border-bottom: 1px solid var(--line); color: var(--text); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: none; place-items: center; z-index: 90; cursor: zoom-out; }
.lightbox.open { display: grid; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }
.modal.left { text-align: left; }
.modal .field { text-align: left; }

/* ------------------------------------------------------------- conexões */
.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.conn { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.conn .top { display: flex; align-items: center; gap: 12px; }
.conn .ico { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: rgba(37,211,102,.14); color: var(--wa); }
.conn .qrbox { background: #fff; border-radius: 14px; padding: 10px; display: grid; place-items: center; min-height: 240px; }
.conn .qrbox img { width: 240px; height: 240px; }
.conn .steps-mini { font-size: 12.5px; color: var(--muted); margin: 0; padding-left: 18px; }
.badge.connected { background: var(--ok-bg); color: var(--ok-fg); }
.badge.disconnected { background: var(--bad-bg); color: var(--bad-fg); }
.badge.qrcode, .badge.starting, .badge.reconnecting { background: var(--warn-bg); color: var(--warn-fg); }
.badge.bot { background: var(--info-bg); color: var(--info-fg); }
.badge.pending { background: var(--warn-bg); color: var(--warn-fg); }
.badge.closed { background: var(--neutral-bg); color: var(--muted); }
.badge.error { background: var(--bad-bg); color: var(--bad-fg); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 6px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 10px; }
.bars div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars i { display: block; width: 100%; border-radius: 6px 6px 2px 2px; background: var(--grad); min-height: 3px; }
.bars span { font-size: 10.5px; color: var(--dim); }
.bars b { font-size: 11px; color: var(--muted); font-weight: 600; }
.code { font-family: var(--mono); font-size: 12px; background: var(--input); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  white-space: pre-wrap; word-break: break-all; }
.hours-row { display: grid; grid-template-columns: 120px 110px 110px; gap: 10px; align-items: center; margin-bottom: 8px; }
.vars { font-size: 12px; color: var(--muted); }
.vars code { background: var(--panel-hi); padding: 1px 6px; border-radius: 5px; font-family: var(--mono); }

@media (max-width: 1250px) { .chat { grid-template-columns: 300px minmax(0, 1fr); } .chat .col-info { display: none; } }
@media (max-width: 860px) {
  .chat, .chat.no-info { grid-template-columns: 1fr; }
  .chat .col-list { display: flex; } .chat .col-chat { display: none; }
  .chat.viewing .col-list { display: none; } .chat.viewing .col-chat { display: flex; }
}
