/* chat/styles.css — HIVV advanced chat UI */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #05050a;
  --surface: #0a0a14;
  --surface-raised: #0f0f1e;
  --border: rgba(255,255,255,0.07);
  --border-hover: rgba(0,255,136,0.3);
  --accent: #00ff88;
  --accent-dim: rgba(0,255,136,0.15);
  --accent-glow: rgba(0,255,136,0.25);
  --cyan: #00f0ff;
  --purple: #a855f7;
  --red: #ff5252;
  --yellow: #fbbf24;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --user-bubble: linear-gradient(135deg, #00ff88 0%, #00cc6a 100%);
  --radius: 18px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --code-bg: #01010a;
  --code-border: rgba(255,255,255,0.08);
  --code-header: #080810;
  --sidebar-w: 260px;
  --drawer-w: 320px;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif; overflow: hidden; }

/* ===== LAYOUT ===== */
.app { display: flex; height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { padding: 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.sidebar-header .brand { font-size: 1.05rem; font-weight: 900; background: linear-gradient(135deg, var(--accent), var(--cyan)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.sidebar-list { flex: 1; overflow-y: auto; padding: 8px; }
.sidebar-list::-webkit-scrollbar { width: 4px; }
.sidebar-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 99px; }
.conv-item { padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.82rem; color: var(--text-dim); border: 1px solid transparent; transition: all 0.15s; display: flex; align-items: center; gap: 8px; }
.conv-item:hover { border-color: var(--border-hover); background: var(--surface-raised); }
.conv-item.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }
.conv-item .conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .conv-del { opacity: 0; color: var(--text-muted); cursor: pointer; font-size: 0.7rem; padding: 2px; }
.conv-item:hover .conv-del { opacity: 1; }
.new-conv-btn { margin: 8px; padding: 8px; background: var(--accent-dim); border: 1px solid rgba(0,255,136,0.25); border-radius: var(--radius-sm); color: var(--accent); font-size: 0.8rem; font-weight: 700; cursor: pointer; text-align: center; transition: all 0.2s; }
.new-conv-btn:hover { background: rgba(0,255,136,0.2); border-color: var(--accent); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ===== HEADER ===== */
.header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; gap: 8px; }
.header-center { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.header-center .model-select, .header-center .mode-select { background: var(--surface-raised); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius-xs); padding: 4px 8px; font-size: 0.78rem; font-weight: 600; cursor: pointer; outline: none; }
.header-center .model-select option, .header-center .mode-select option { background: var(--surface-raised); color: var(--text); }
.header-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.icon-btn { width: 34px; height: 34px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; font-size: 0.9rem; }
.icon-btn:hover { border-color: var(--border-hover); color: var(--text); background: var(--surface); }
.icon-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ===== CHAT AREA ===== */
.chat-area { flex: 1; overflow-y: auto; padding: 24px 16px; display: flex; flex-direction: column; gap: 16px; scroll-behavior: smooth; }
.chat-area::-webkit-scrollbar { width: 5px; }
.chat-area::-webkit-scrollbar-track { background: transparent; }
.chat-area::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 99px; }

/* ===== WELCOME ===== */
.welcome { margin: auto; text-align: center; padding: 60px 20px; animation: fadeUp 0.6s ease; }
.welcome-icon { font-size: 3.5rem; margin-bottom: 20px; display: block; filter: drop-shadow(0 0 20px var(--accent-glow)); }
.welcome h1 { font-size: 1.7rem; font-weight: 900; color: #fff; margin-bottom: 10px; letter-spacing: -0.03em; }
.welcome p { color: var(--text-muted); font-size: 0.95rem; max-width: 380px; margin: 0 auto 28px; line-height: 1.6; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 500px; margin: 0 auto; }
.suggestion { background: var(--surface-raised); border: 1px solid var(--border); border-radius: 999px; padding: 8px 16px; font-size: 0.82rem; color: var(--text-dim); cursor: pointer; transition: all 0.2s; }
.suggestion:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ===== MESSAGES ===== */
.message { display: flex; gap: 10px; animation: fadeUp 0.3s ease; max-width: 100%; }
.message.user { flex-direction: row-reverse; }
.msg-avatar { width: 30px; height: 30px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 800; align-self: flex-end; }
.msg-avatar.ai { background: linear-gradient(135deg, rgba(0,255,136,0.2), rgba(0,240,255,0.15)); border: 1px solid rgba(0,255,136,0.3); color: var(--accent); }
.msg-avatar.user-avatar { background: var(--surface-raised); border: 1px solid var(--border); color: var(--text-muted); }
.msg-content { max-width: 82%; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.message.user .msg-content { align-items: flex-end; }
.bubble { padding: 12px 16px; border-radius: var(--radius); font-size: 0.92rem; line-height: 1.7; word-break: break-word; overflow-wrap: break-word; }
.bubble.ai { background: var(--surface-raised); border: 1px solid var(--border); border-radius: 4px 18px 18px 18px; color: var(--text); }
.bubble.user { background: var(--user-bubble); border-radius: 18px 4px 18px 18px; color: #011a0f; font-weight: 500; }
.msg-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s; padding: 0 4px; }
.message:hover .msg-actions { opacity: 1; }
.msg-action-btn { width: 26px; height: 26px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; transition: all 0.15s; }
.msg-action-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ===== MARKDOWN CONTENT ===== */
.bubble.ai p { margin: 0 0 12px; }
.bubble.ai p:last-child { margin-bottom: 0; }
.bubble.ai ul, .bubble.ai ol { margin: 0 0 12px; padding-left: 24px; }
.bubble.ai li { margin: 4px 0; }
.bubble.ai blockquote { border-left: 3px solid var(--accent); padding: 4px 12px; margin: 8px 0; color: var(--text-dim); background: rgba(0,255,136,0.03); border-radius: 0 var(--radius-xs) var(--radius-xs) 0; }
.bubble.ai h1, .bubble.ai h2, .bubble.ai h3, .bubble.ai h4 { margin: 16px 0 8px; color: #fff; font-weight: 700; }
.bubble.ai h1 { font-size: 1.3rem; }
.bubble.ai h2 { font-size: 1.15rem; }
.bubble.ai h3 { font-size: 1.05rem; }
.bubble.ai a { color: var(--cyan); text-decoration: none; }
.bubble.ai a:hover { text-decoration: underline; }
.bubble.ai table { border-collapse: collapse; margin: 8px 0; width: 100%; font-size: 0.85rem; }
.bubble.ai th, .bubble.ai td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.bubble.ai th { background: var(--code-header); color: var(--text-dim); font-weight: 600; }
.bubble.ai hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.bubble.ai code { background: rgba(0,0,0,0.3); border-radius: 4px; padding: 1px 5px; font-family: 'Fira Code', 'Cascadia Code', monospace; font-size: 0.85em; }

/* ===== CODE BLOCKS ===== */
.bubble.ai pre { background: var(--code-bg); border: 1px solid var(--code-border); border-radius: 8px; margin: 8px 0; overflow: hidden; }
.code-header { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; background: var(--code-header); border-bottom: 1px solid var(--code-border); font-size: 0.75rem; }
.code-lang { color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.code-actions { display: flex; gap: 4px; }
.code-action-btn { background: none; border: 1px solid transparent; border-radius: 4px; color: var(--text-muted); cursor: pointer; padding: 2px 6px; font-size: 0.7rem; transition: all 0.15s; display: flex; align-items: center; gap: 3px; }
.code-action-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.code-action-btn.copied { color: var(--accent); }
pre .code-body { padding: 12px 14px; overflow-x: auto; }
pre .code-body code { background: none; padding: 0; font-size: 0.82rem; line-height: 1.6; font-family: 'Fira Code', 'Cascadia Code', monospace; }
pre .line-numbers { display: inline-block; text-align: right; padding-right: 12px; margin-right: 12px; border-right: 1px solid var(--border); color: var(--text-muted); user-select: none; -webkit-user-select: none; }
.line-number { display: block; font-size: 0.75rem; line-height: 1.6; }

/* ===== THINKING ===== */
.thinking { display: flex; gap: 10px; animation: fadeUp 0.3s ease; }
.thinking .msg-avatar { background: linear-gradient(135deg, rgba(168,85,247,0.2), rgba(0,240,255,0.15)); border: 1px solid rgba(168,85,247,0.3); }
.thinking-bubble { background: var(--surface-raised); border: 1px solid var(--border); border-radius: 4px 18px 18px 18px; padding: 14px 18px; color: var(--text-muted); font-size: 0.88rem; line-height: 1.6; }
.thinking-dots { display: flex; gap: 4px; margin-bottom: 6px; }
.thinking-dots span { width: 5px; height: 5px; background: var(--purple); border-radius: 50%; animation: dotPulse 1.2s ease-in-out infinite; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse { 0%, 100% { opacity: 0.3; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.1); } }

/* ===== RECEIPT ===== */
.receipt { font-size: 0.7rem; color: var(--text-muted); padding: 0 4px; display: flex; align-items: center; gap: 4px; }
.receipt .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); opacity: 0.6; }

/* ===== INPUT AREA ===== */
.input-area { flex-shrink: 0; padding: 12px 16px 16px; border-top: 1px solid var(--border); }
.input-row { display: flex; gap: 8px; align-items: flex-end; background: var(--surface-raised); border: 1px solid var(--border); border-radius: 16px; padding: 8px 8px 8px 16px; transition: border-color 0.2s, box-shadow 0.2s; }
.input-row:focus-within { border-color: rgba(0,255,136,0.35); box-shadow: 0 0 0 3px rgba(0,255,136,0.08); }
.input-row.dragover { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(0,240,255,0.15); }
#chatInput { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 0.95rem; line-height: 1.5; resize: none; max-height: 160px; font-family: inherit; padding: 4px 0; }
#chatInput::placeholder { color: var(--text-muted); }
.input-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.voice-toggle, .attach-btn { width: 36px; height: 36px; border-radius: 10px; border: none; background: var(--surface); color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1rem; transition: all 0.2s; }
.voice-toggle:hover, .attach-btn:hover { background: rgba(0,255,136,0.1); color: var(--accent); }
.voice-toggle.listening { background: rgba(0,255,136,0.15); color: var(--accent); box-shadow: 0 0 12px var(--accent-glow); animation: orbPulse 1s ease-in-out infinite; }
.send-btn { width: 36px; height: 36px; border-radius: 10px; border: none; background: var(--accent); color: #011a0f; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1rem; transition: all 0.2s; font-weight: 800; }
.send-btn:hover { background: #00e07a; box-shadow: 0 0 16px var(--accent-glow); transform: scale(1.05); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.stop-btn { width: 36px; height: 36px; border-radius: 10px; border: none; background: rgba(255,82,82,0.15); color: var(--red); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; transition: all 0.2s; }
.stop-btn:hover { background: rgba(255,82,82,0.25); }

/* ===== FILE CHIPS ===== */
.file-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0 2px; }
.file-chip { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 10px; font-size: 0.78rem; color: var(--text-dim); max-width: 200px; }
.file-chip .chip-icon { font-size: 0.85rem; }
.file-chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.file-chip .chip-remove { cursor: pointer; color: var(--text-muted); font-size: 0.7rem; padding: 2px; }
.file-chip .chip-remove:hover { color: var(--red); }
.file-chip .chip-thumb { width: 28px; height: 28px; border-radius: 4px; object-fit: cover; }

/* ===== DRAWER (settings) ===== */
.drawer-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 90; }
.drawer-overlay.open { display: block; }
.drawer { position: fixed; top: 0; right: -340px; width: var(--drawer-w); height: 100vh; background: var(--surface); border-left: 1px solid var(--border); z-index: 100; display: flex; flex-direction: column; transition: right 0.25s ease; }
.drawer.open { right: 0; }
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--border); }
.drawer-header h3 { font-size: 0.95rem; font-weight: 700; color: var(--text); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }
.drawer-body::-webkit-scrollbar { width: 4px; }
.drawer-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 99px; }
.ctrl-group { margin-bottom: 18px; }
.ctrl-group label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; letter-spacing: 0.02em; }
.ctrl-group .ctrl-desc { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 4px; }
.ctrl-group input[type="range"] { width: 100%; accent-color: var(--accent); }
.ctrl-group input[type="number"], .ctrl-group input[type="text"], .ctrl-group textarea { width: 100%; background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-xs); color: var(--text); padding: 6px 10px; font-size: 0.82rem; font-family: inherit; outline: none; }
.ctrl-group input:focus, .ctrl-group textarea:focus { border-color: var(--accent); }
.ctrl-group textarea { min-height: 80px; resize: vertical; }
.ctrl-row { display: flex; gap: 8px; align-items: center; }
.ctrl-row .val { font-size: 0.75rem; color: var(--accent); font-weight: 700; min-width: 32px; text-align: right; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }
.toggle-row span { font-size: 0.82rem; color: var(--text-dim); }
.toggle { position: relative; width: 38px; height: 22px; background: var(--surface-raised); border: 1px solid var(--border); border-radius: 99px; cursor: pointer; transition: all 0.2s; }
.toggle.on { background: var(--accent-dim); border-color: var(--accent); }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-muted); transition: all 0.2s; }
.toggle.on::after { left: 18px; background: var(--accent); }
.preset-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.preset-chip { padding: 3px 8px; border-radius: 99px; font-size: 0.7rem; font-weight: 600; cursor: pointer; background: var(--surface); border: 1px solid var(--border); color: var(--text-dim); transition: all 0.15s; }
.preset-chip:hover { border-color: var(--accent); color: var(--accent); }
.preset-chip.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* ===== VOICE PANEL ===== */
.voice-panel { display: none; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 40px 20px; animation: fadeUp 0.3s ease; }
.voice-panel.active { display: flex; }
.voice-orb { width: 80px; height: 80px; border-radius: 50%; background: radial-gradient(circle, rgba(0,255,136,0.3) 0%, rgba(0,240,255,0.1) 60%, transparent 100%); border: 2px solid var(--accent); display: flex; align-items: center; justify-content: center; font-size: 2rem; animation: orbPulse 1.5s ease-in-out infinite; box-shadow: 0 0 40px var(--accent-glow), inset 0 0 20px rgba(0,255,136,0.1); }
@keyframes orbPulse { 0%, 100% { transform: scale(1); box-shadow: 0 0 40px var(--accent-glow), inset 0 0 20px rgba(0,255,136,0.1); } 50% { transform: scale(1.06); box-shadow: 0 0 60px rgba(0,255,136,0.4), inset 0 0 30px rgba(0,255,136,0.15); } }
.voice-status { font-size: 0.9rem; color: var(--accent); font-weight: 600; letter-spacing: 0.02em; }
.voice-transcript { background: var(--surface-raised); border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 20px; max-width: 500px; width: 100%; text-align: center; font-size: 1rem; color: var(--text); min-height: 48px; font-weight: 500; box-shadow: 0 0 20px var(--accent-glow); }
.voice-transcript.interim { color: var(--cyan); font-style: italic; border-color: var(--cyan); box-shadow: 0 0 20px rgba(0,240,255,0.2); }
.voice-levels { display: flex; gap: 4px; align-items: center; }
.voice-levels span { width: 3px; border-radius: 99px; background: var(--accent); transition: height 0.05s; }

/* ===== TOAST ===== */
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--surface-raised); border: 1px solid var(--border-hover); border-radius: 999px; padding: 8px 18px; font-size: 0.82rem; color: var(--accent); font-weight: 600; opacity: 0; transition: all 0.3s; pointer-events: none; white-space: nowrap; z-index: 200; box-shadow: 0 0 20px rgba(0,255,136,0.15); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== DRAG OVERLAY ===== */
.drag-overlay { display: none; position: fixed; inset: 0; background: rgba(0,255,136,0.05); border: 2px dashed var(--accent); z-index: 50; align-items: center; justify-content: center; pointer-events: none; }
.drag-overlay.visible { display: flex; }
.drag-overlay .drag-msg { background: var(--surface-raised); border: 1px solid var(--accent); border-radius: var(--radius); padding: 24px 40px; font-size: 1rem; color: var(--accent); font-weight: 700; box-shadow: 0 0 40px var(--accent-glow); }

/* ===== ANIMATIONS ===== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .msg-content { max-width: 92%; }
  .welcome h1 { font-size: 1.3rem; }
  .drawer { width: 100%; right: -100%; }
  :root { --drawer-w: 100%; }
}
