/* ==========================================================================
   OrderFlow — Chatbot Público (chatbot.css)
   Reaproveita o Design System do styles.css + componentes exclusivos de chat
   ========================================================================== */

:root[data-theme="dark"] {
  --bg-main: #0b0f19;
  --bg-card: rgba(21, 28, 44, 0.78);
  --bg-card-hover: rgba(28, 38, 60, 0.88);
  --bg-input: rgba(16, 22, 37, 0.75);
  --bg-modal: rgba(21, 28, 46, 0.92);
  --bg-modal-overlay: rgba(5, 8, 15, 0.75);
  --border-color: rgba(255, 255, 255, 0.12);
  --border-color-hover: rgba(255, 255, 255, 0.25);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent-primary: #4f46e5;
  --accent-primary-hover: #4338ca;
  --accent-light: rgba(79, 70, 229, 0.2);
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.15);
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.15);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
  --blur-bg: blur(16px);
}

:root[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: rgba(241, 245, 249, 0.95);
  --bg-input: rgba(241, 245, 249, 0.85);
  --bg-modal: rgba(255, 255, 255, 0.96);
  --bg-modal-overlay: rgba(15, 23, 42, 0.5);
  --border-color: rgba(226, 232, 240, 0.9);
  --border-color-hover: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-primary: #4f46e5;
  --accent-primary-hover: #4338ca;
  --accent-light: rgba(79, 70, 229, 0.08);
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.1);
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  --blur-bg: blur(8px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background-color 0.3s ease;
}

.hidden { display: none !important; }

/* ---------- Header ---------- */
.bot-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-modal-overlay);
  backdrop-filter: var(--blur-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.5rem;
}
.bot-header-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: 0.85rem; }
.brand-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(99,102,241,0.4);
}
.brand-text h1 { font-size: 1.3rem; font-weight: 800; line-height: 1.1; }
.brand-text span { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.6rem 1.05rem;
  font-family: inherit; font-size: 0.85rem; font-weight: 600; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer; transition: all 0.2s ease; text-decoration: none; }
.btn-primary { background: linear-gradient(135deg, #4f46e5, #4338ca); color: #fff; box-shadow: 0 4px 14px rgba(79,70,229,0.35); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--bg-card); color: var(--text-primary); border-color: var(--border-color); }
.btn-secondary:hover { border-color: var(--border-color-hover); }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 10px; background: var(--bg-card);
  border: 1px solid var(--border-color); color: var(--text-secondary); display: inline-flex;
  align-items: center; justify-content: center; cursor: pointer; }
.btn-icon:hover { color: var(--text-primary); border-color: var(--border-color-hover); }
:root[data-theme="dark"] .sun-icon { display: block; }
:root[data-theme="dark"] .moon-icon { display: none; }
:root[data-theme="light"] .sun-icon { display: none; }
:root[data-theme="light"] .moon-icon { display: block; }

/* ---------- Layout ---------- */
.bot-main { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.5rem 3rem;
  display: grid; grid-template-columns: 340px 1fr; gap: 1.25rem; align-items: start; }

/* Layout sem painel lateral (chat centralizado) */
.bot-main-centered { grid-template-columns: 1fr; max-width: 780px; }

.info-panel { display: flex; flex-direction: column; gap: 1rem; }
.info-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 16px;
  padding: 1.25rem; backdrop-filter: var(--blur-bg); box-shadow: var(--shadow-md); }
.info-card h2 { font-size: 1.05rem; font-weight: 800; margin-bottom: 0.4rem; display: flex; gap: 0.5rem; align-items: center; }
.info-card h2 svg { width: 20px; height: 20px; color: var(--accent-primary); }
.info-card p { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.55; }
.steps-list { list-style: none; margin-top: 0.8rem; display: flex; flex-direction: column; gap: 0.6rem; }
.steps-list li { display: flex; gap: 0.6rem; font-size: 0.83rem; color: var(--text-secondary); align-items: flex-start; }
.step-num { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-light);
  color: var(--accent-primary); font-size: 0.72rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sector-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.8rem; }
.sector-chips span { font-size: 0.72rem; font-weight: 700; padding: 0.25rem 0.6rem; border-radius: 9999px;
  background: var(--bg-input); border: 1px solid var(--border-color); color: var(--text-secondary); }
.ai-badge { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; font-weight: 700;
  padding: 0.3rem 0.7rem; border-radius: 9999px; margin-top: 0.8rem; }
.ai-badge.on { background: var(--success-light); color: var(--success); border: 1px solid rgba(16,185,129,0.3); }
.ai-badge.off { background: var(--accent-light); color: var(--accent-primary); border: 1px solid rgba(79,70,229,0.3); }
.ai-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ---------- Chat card ---------- */
.chat-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 20px;
  overflow: hidden; display: flex; flex-direction: column; height: 72vh; min-height: 540px;
  backdrop-filter: var(--blur-bg); box-shadow: var(--shadow-lg); }
.chat-top { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; gap: 0.8rem; background: rgba(0,0,0,0.08); }
.bot-avatar { width: 44px; height: 44px; border-radius: 14px; background: linear-gradient(135deg,#10b981,#059669);
  display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.chat-top-info { flex: 1; }
.chat-top-info strong { display: block; font-size: 0.95rem; }
.online { font-size: 0.75rem; color: var(--success); font-weight: 600; display: flex; align-items: center; gap: 0.3rem; }
.online::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--success); display: inline-block; }

.chat-messages { flex: 1; overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: 0.85rem; }
.msg { max-width: 82%; padding: 0.7rem 0.95rem; border-radius: 14px; font-size: 0.88rem; line-height: 1.5;
  animation: msg-in 0.25s ease; white-space: pre-wrap; word-break: break-word; }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.msg.bot { align-self: flex-start; background: var(--bg-input); border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px; color: var(--text-primary); }
.msg.user { align-self: flex-end; background: linear-gradient(135deg,#4f46e5,#4338ca); color: #fff;
  border-bottom-right-radius: 4px; }
.msg.bot strong { color: var(--text-primary); }
.order-summary { background: var(--bg-card); border: 1px dashed var(--accent-primary); border-radius: 12px;
  padding: 0.8rem; margin-top: 0.5rem; font-size: 0.83rem; }
.order-summary div { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.15rem 0; }
.order-summary span:first-child { color: var(--text-muted); }
.typing { align-self: flex-start; background: var(--bg-input); border: 1px solid var(--border-color);
  padding: 0.8rem 1rem; border-radius: 14px; display: flex; gap: 5px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.2s; } .typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,100% { opacity: 0.3; } 50% { opacity: 1; } }

.quick-replies { display: flex; gap: 0.5rem; flex-wrap: wrap; padding: 0.6rem 1.25rem 0; }
.quick-replies:empty { display: none; }
.qr-btn { padding: 0.45rem 0.85rem; border-radius: 9999px; font-size: 0.8rem; font-weight: 600; cursor: pointer;
  background: var(--accent-light); color: var(--accent-primary); border: 1px solid rgba(79,70,229,0.35); transition: all 0.15s ease; }
.qr-btn:hover { background: var(--accent-primary); color: #fff; }

.chat-input-bar { padding: 1rem 1.25rem; border-top: 1px solid var(--border-color); display: flex; gap: 0.6rem; }
.chat-input-bar input { flex: 1; padding: 0.75rem 1rem; background: var(--bg-input);
  border: 1px solid var(--border-color); border-radius: 12px; color: var(--text-primary);
  font-family: inherit; font-size: 0.9rem; outline: none; }
.chat-input-bar input:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-light); }
.btn-send { width: 46px; height: 46px; border-radius: 12px; border: none; cursor: pointer;
  background: linear-gradient(135deg,#4f46e5,#4338ca); color: #fff; display: flex; align-items: center; justify-content: center; }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }
.progress-bar { padding: 0.6rem 1.25rem 0; }
.progress-track { height: 6px; background: var(--bg-input); border-radius: 9999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg,#10b981,#4f46e5); border-radius: 9999px; transition: width 0.4s ease; width: 5%; }
.progress-label { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.3rem; display: block; }

/* ---------- Config modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: var(--bg-modal-overlay); backdrop-filter: blur(6px);
  z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.modal-card { background: var(--bg-modal); border: 1px solid var(--border-color); border-radius: 20px;
  width: 100%; max-width: 560px; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.modal-header { padding: 1.2rem 1.5rem; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-size: 1.1rem; font-weight: 800; display: flex; gap: 0.5rem; align-items: center; }
.modal-body { padding: 1.5rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); }
.form-group input, .form-group select { padding: 0.65rem 0.85rem; background: var(--bg-input);
  border: 1px solid var(--border-color); border-radius: 10px; color: var(--text-primary); font-family: inherit; font-size: 0.875rem; outline: none; }
.form-group input:focus, .form-group select:focus { border-color: var(--accent-primary); }
.hint { font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; }
.hint code { background: var(--bg-input); padding: 0.1rem 0.35rem; border-radius: 6px; font-size: 0.75rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 0.7rem; }
.sql-box { background: #0b0f19; color: #a5f3fc; border-radius: 10px; padding: 0.8rem; font-family: monospace; font-size: 0.72rem; overflow-x: auto; white-space: pre; }

/* Toast */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 2000; display: flex; flex-direction: column; gap: 0.7rem; }
.toast { min-width: 280px; padding: 0.85rem 1.1rem; border-radius: 12px; background: var(--bg-card);
  border: 1px solid var(--border-color); display: flex; gap: 0.7rem; align-items: center; font-size: 0.85rem; font-weight: 600; }
.toast-success { border-left: 4px solid var(--success); }

@media (max-width: 900px) {
  .bot-main { grid-template-columns: 1fr; }
  .info-panel { order: 2; }
  .chat-card { height: 70vh; }
  .msg { max-width: 92%; }
}
