/* Chatbox CSS — mobile full (10px padding), voice-status cạnh nút Gửi */

#tac-chat-container{
  box-sizing:border-box; isolation:isolate;
  --tac-bg:#fff; --tac-fg:#1f2937; --tac-muted:#6b7280; --tac-border:#e5e7eb;
  --tac-surface:#f9f9f9; --tac-surface-2:#f3f4f6; --tac-accent:#4f726c; --tac-accent-hover:#44615c;
  max-width:840px; width:100%; margin:20px auto;
  background:var(--tac-bg); border:1px solid var(--tac-border); border-radius:12px;
  box-shadow:0 10px 25px -5px rgba(0,0,0,.05);
  display:flex; flex-direction:column; font-family:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,sans-serif;
  overflow:hidden; position:relative; -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility;
}
#tac-chat-container *,#tac-chat-container *::before,#tac-chat-container *::after{box-sizing:inherit}

/* Messages (font +2) */
#tac-chat-container .tac-messages{padding:1.5rem;overflow-y:auto;display:flex;flex-direction:column;gap:16px;max-height:45vh;transition:max-height .4s ease-in-out;scroll-behavior:smooth}
#tac-chat-container.tac-is-focused .tac-messages{max-height:80vh}
#tac-chat-container .tac-message{display:flex;width:100%;max-width:100%}
#tac-chat-container .tac-message-user{justify-content:flex-end}
#tac-chat-container .tac-message-ai{justify-content:flex-start}
#tac-chat-container .tac-bubble{
  max-width:80%;min-width:40px;padding:12px 18px;border-radius:18px;
  font-size:17px; line-height:1.65;
  white-space:pre-wrap;word-break:break-word;background:var(--tac-surface);color:var(--tac-fg);border:1px solid var(--tac-border)
}
#tac-chat-container .tac-message-user .tac-bubble{border-bottom-right-radius:4px}
#tac-chat-container .tac-message-ai .tac-bubble{border-bottom-left-radius:4px}

/* Input (font +2) */
#tac-chat-container .tac-input-container{padding:.5rem 1.5rem;border-top:1px solid var(--tac-border);background:var(--tac-bg)}
#tac-chat-container .tac-input-wrapper{border:1px solid #d1d5db;border-radius:12px;padding:8px;display:flex;flex-direction:column;background:transparent}
#tac-chat-container .tac-input-textarea{
  display:block;width:100%;min-height:72px;max-height:192px;padding:0 8px;font-size:18px;
  font-family:inherit;border:none;resize:none;outline:none;background:transparent;box-shadow:none;color:var(--tac-fg)
}

/* Attach strip */
#tac-attach-strip{display:flex;flex-wrap:wrap;gap:8px;padding:6px 4px 0 4px}
.tac-attach-item{position:relative;border:1px solid var(--tac-border);border-radius:10px;background:var(--tac-surface-2);overflow:hidden;width:64px;height:64px;display:inline-flex;align-items:center;justify-content:center}
.tac-attach-item img{max-width:100%;max-height:100%;display:block}
.tac-attach-item .tac-file-pill{padding:6px;font-size:11px;line-height:1.2;text-align:center;color:#374151;word-break:break-word}
.tac-attach-remove{position:absolute;top:4px;right:4px;width:18px;height:18px;border-radius:9px;background:rgba(0,0,0,.7);color:#fff;display:inline-flex;align-items:center;justify-content:center;font-size:12px;border:none;cursor:pointer}
.tac-attach-remove:hover{background:rgba(0,0,0,.9)}

/* Toolbar */
#tac-chat-container .tac-input-toolbar{display:flex;justify-content:space-between;align-items:center;margin-top:8px;flex-wrap:wrap;gap:8px}
#tac-chat-container .tac-toolbar-left,#tac-chat-container .tac-toolbar-right{display:flex;align-items:center;gap:8px}
#tac-chat-container .tac-btn-icon,#tac-chat-container .tac-btn-send{background:none;border:none;color:var(--tac-muted);width:32px;height:32px;display:flex;align-items:center;justify-content:center;border-radius:8px;cursor:pointer;transition:background-color .2s;padding:0}
#tac-chat-container .tac-btn-icon:hover{background-color:var(--tac-surface-2)}
#tac-chat-container .tac-btn-icon svg,#tac-chat-container .tac-btn-send svg{width:20px;height:20px;stroke:currentColor;stroke-width:2;fill:none}
#tac-chat-container .tac-btn-send{width:36px;height:36px;background-color:var(--tac-accent);border-radius:50%;color:#fff}
#tac-chat-container .tac-btn-send:hover{background-color:var(--tac-accent-hover)}
#tac-chat-container .tac-btn-send[disabled]{opacity:.5;cursor:not-allowed}

/* Credit & quota (quota -2 cỡ) */
#tac-chat-container .tac-toolbar-right .tac-credit-balance,
#tac-chat-container .tac-toolbar-right .tac-btn-save,
#tac-chat-container .tac-toolbar-right .tac-btn-suggestion{
  height:32px;display:flex;align-items:center;gap:6px;font-weight:500;font-size:14px;background:var(--tac-surface-2);color:#374151;border:1px solid #d1d5db;padding:0 12px;border-radius:8px;cursor:pointer;white-space:nowrap
}
#tac-quota-display{font-size:12px; color:#6b7280; margin-left:6px;} /* giảm 2 cỡ */

/* Voice status cạnh nút gửi */
.tac-voice-status{
  display:inline-flex; align-items:center; gap:6px;
  padding:4px 8px; border-radius:999px; background:#fee2e2; border:1px solid #fecaca; color:#991b1b;
  font-size:12px; line-height:1;
}
.tac-voice-status .dot{
  width:8px; height:8px; border-radius:50%; background:#ef4444; display:inline-block;
  animation: tac-pulse 1.2s infinite ease-in-out;
}
@keyframes tac-pulse{
  0%{transform:scale(1); opacity:1}
  50%{transform:scale(0.6); opacity:0.6}
  100%{transform:scale(1); opacity:1}
}

/* Bottom toolbar */
#tac-chat-container .tac-bottom-toolbar{padding:.75rem 1.5rem;background:#f9fafb;border-top:1px solid var(--tac-border);padding-bottom:calc(.75rem + env(safe-area-inset-bottom,0))}
#tac-chat-container .tac-model-selector{display:flex;flex-wrap:wrap;gap:0;justify-content:flex-start}
#tac-chat-container .tac-model-btn,#tac-chat-container .tac-tool-btn{font-size:13px;font-weight:500;padding:6px 12px;border-radius:6px;cursor:pointer;background:#e5e7eb;color:#4b5563;border:1px solid #d1d5db;transition:background-color .2s;margin:4px}
#tac-chat-container .tac-model-btn.active{background:#1f2937;color:#fff;border-color:#1f2937}
#tac-chat-container .tac-model-btn:hover,#tac-chat-container .tac-tool-btn:hover,#tac-chat-container .tac-btn-save:hover{background:#d1d5db}

/* Tooltip */
.tac-tooltip-wrapper{position:relative;display:inline-flex;align-items:center}
.tac-tooltip{visibility:hidden;width:max-content;background:#333;color:#fff;text-align:center;border-radius:6px;padding:5px 10px;position:absolute;z-index:1000;bottom:125%;left:50%;transform:translateX(-50%);opacity:0;transition:opacity .2s;font-size:12px;pointer-events:none;white-space:nowrap}
.tac-tooltip-wrapper:hover .tac-tooltip{visibility:visible;opacity:1}

/* Dark mode */
#tac-chat-container.tac-dark{--tac-bg:#0b0f12;--tac-fg:#e5e7eb;--tac-muted:#9ca3af;--tac-border:#1f2937;--tac-surface:#111827;--tac-surface-2:#0f172a;--tac-accent:#5aa39a;--tac-accent-hover:#4a8d84}
#tac-chat-container.tac-dark .tac-bottom-toolbar{background:#0f172a}
#tac-chat-container.tac-dark .tac-model-btn,#tac-chat-container.tac-dark .tac-tool-btn{background:#1f2937;color:#e5e7eb;border-color:#374151}
#tac-chat-container.tac-dark .tac-model-btn:hover,#tac-chat-container.tac-dark .tac-tool-btn:hover{background:#374151}

/* Responsive — mobile full (10px padding) */
@media (max-width:600px){
  #tac-chat-container{margin:0;border-radius:0;padding:0 10px}
  #tac-chat-container .tac-input-textarea{min-height:64px;font-size:17px}
  .tac-attach-item{width:56px;height:56px}
  #tac-chat-container .tac-toolbar-right{width:100%;justify-content:flex-end;gap:6px;flex-wrap:wrap}
  #tac-quota-display{font-size:11px}
  .tac-voice-status{font-size:11px;padding:3px 7px}
}
