/* WeBot — Clean, modern chat UI */
:root {
  --bg: #0f1117;
  --bg-surface: #1a1d27;
  --bg-elevated: #232736;
  --border: #2a2e3d;
  --text: #e4e6ef;
  --text-secondary: #8b8fa3;
  --text-muted: #5a5e72;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --success: #22c55e;
  --error: #ef4444;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "SF Mono", "Fira Code", monospace;
}

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

body { font-family: var(--font); background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; }
a { color: var(--accent); text-decoration: none; }

/* ── Login ─────────────────────────────────── */
.login-page {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; background: var(--bg);
}
.login-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px; width: 100%; max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.logo { text-align: center; margin-bottom: 32px; }
.logo-icon { font-size: 48px; margin-bottom: 8px; }
.logo h1 { font-size: 24px; font-weight: 600; }
.subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }
.field input {
  width: 100%; padding: 10px 14px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text);
  font-size: 14px; outline: none; transition: border-color 0.2s;
}
.field input:focus { border-color: var(--accent); }
.btn-primary {
  width: 100%; padding: 10px; background: var(--accent); color: white;
  border: none; border-radius: 8px; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background 0.2s; margin-top: 8px;
}
.btn-primary:hover { background: var(--accent-hover); }
.login-footer { text-align: center; margin-top: 16px; font-size: 12px; }

/* ── Layout ────────────────────────────────── */
.app { display: flex; height: 100vh; }

/* ── Sidebar ───────────────────────────────── */
.sidebar {
  width: 260px; background: var(--bg-surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.logo-text { font-size: 16px; font-weight: 600; }
.btn-icon {
  width: 28px; height: 28px; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--accent); border-color: var(--accent); }
.sidebar-user {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text-secondary);
}
.user-name { font-weight: 500; color: var(--text); }
.user-role { font-size: 11px; color: var(--text-muted); margin-left: 6px; }
.convo-list { flex: 1; overflow-y: auto; padding: 8px; }
.convo-item {
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; margin-bottom: 2px;
  transition: background 0.15s;
}
.convo-item:hover { background: var(--bg-elevated); }
.convo-title { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-time { font-size: 11px; color: var(--text-muted); }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); }
.btn-logout {
  width: 100%; padding: 8px; background: transparent; border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-secondary); font-size: 13px; cursor: pointer;
}
.btn-logout:hover { border-color: var(--error); color: var(--error); }

/* ── Main Chat ─────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: baseline; gap: 10px;
}
.chat-title { font-size: 15px; font-weight: 600; }
.chat-subtitle { font-size: 12px; color: var(--text-muted); }

.messages {
  flex: 1; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}

/* ── Messages ──────────────────────────────── */
.msg { display: flex; gap: 10px; max-width: 85%; animation: fadeIn 0.2s; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }
.msg-bot { align-self: flex-start; }
.msg-avatar {
  width: 32px; height: 32px; border-radius: 8px; background: var(--bg-elevated);
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  flex-shrink: 0;
}
.msg-content {
  padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.6;
  word-wrap: break-word;
}
.msg-user .msg-content { background: var(--accent); color: white; border-bottom-right-radius: 4px; }
.msg-bot .msg-content { background: var(--bg-surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }

/* ── Data Formatting ───────────────────────── */
.table-wrap { overflow-x: auto; margin: 8px 0; }
.data-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table th {
  text-align: left; padding: 8px 10px; background: var(--bg-elevated);
  border-bottom: 1px solid var(--border); color: var(--text-secondary);
  font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
}
.data-table td {
  padding: 7px 10px; border-bottom: 1px solid var(--border); color: var(--text);
}
.data-table tr:hover td { background: rgba(99,102,241,0.05); }

.card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; margin: 8px 0;
}
.card-row { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.card-row:last-child { border-bottom: none; }
.card-label { font-size: 12px; color: var(--text-secondary); min-width: 120px; font-weight: 500; }
.card-value { font-size: 13px; color: var(--text); font-family: var(--font-mono); }

.list { margin: 8px 0; }
.list-item { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.list-item:last-child { border-bottom: none; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin: 8px 0; }
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: var(--success); }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: var(--error); }

/* ── Empty State ───────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.empty-desc { color: var(--text-secondary); font-size: 14px; margin-bottom: 20px; }
.quick-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.quick-actions button {
  padding: 8px 16px; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px; cursor: pointer;
  transition: all 0.15s;
}
.quick-actions button:hover { border-color: var(--accent); color: var(--accent); }

/* ── Input ─────────────────────────────────── */
.input-area { padding: 12px 20px; border-top: 1px solid var(--border); }
.input-form { display: flex; gap: 8px; align-items: flex-end; }
.input-form textarea {
  flex: 1; padding: 10px 14px; background: var(--bg-surface);
  border: 1px solid var(--border); border-radius: 10px; color: var(--text);
  font-size: 14px; font-family: var(--font); resize: none; outline: none;
  max-height: 120px; line-height: 1.5;
}
.input-form textarea:focus { border-color: var(--accent); }
.btn-send {
  width: 36px; height: 36px; background: var(--accent); border: none;
  border-radius: 8px; color: white; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.btn-send:hover { background: var(--accent-hover); }

/* ── Typing Indicator ──────────────────────── */
.typing-indicator { display: flex; gap: 4px; padding: 4px 0; }
.typing-indicator span {
  width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }

/* ── Flash Messages ────────────────────────── */
#flash-container {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.flash {
  padding: 10px 16px; border-radius: 8px; font-size: 13px; font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3); pointer-events: auto;
  animation: slideIn 0.2s ease-out; max-width: 320px;
}
.flash-error { background: #ef4444; color: white; border: 1px solid #dc2626; }
.flash-success { background: #22c55e; color: white; border: 1px solid #16a34a; }
.flash-hide { opacity: 0; transform: translateX(100px); transition: all 0.3s ease-out; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(100px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Hide inline result — flash messages replace it */
#result { display: none; }
