/* ── HHAMZX's AI Stylesheet ─────────────────────────── */

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

:root {
  --bg:         #0a0b0d;
  --bg-card:    #111318;
  --bg-card-2:  #161820;
  --bg-input:   #0e1014;
  --border:     rgba(255,255,255,0.07);
  --border-md:  rgba(255,255,255,0.11);
  --text:       #e8eaf0;
  --text-muted: #5a5f72;
  --text-dim:   #3a3f52;
  --accent:     #6c8fff;
  --accent-glow:#6c8fff33;
  --accent-2:   #a78bfa;
  --green:      #34d399;
  --red:        #f87171;
  --user-bg:    #1a1f35;
  --radius:     16px;
  --radius-sm:  10px;
  --radius-xs:  7px;
  --font:       'DM Sans', sans-serif;
  --mono:       'DM Mono', monospace;
  --shadow:     0 2px 20px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 48px rgba(0,0,0,0.6);
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Background ── */
#bg-canvas {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}
.noise-overlay {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 128px 128px;
}

/* ── Header ── */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 56px; padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(10,11,13,0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.header-inner {
  max-width: 760px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; justify-content: space-between;
}
.logo-group { display: flex; align-items: center; gap: 8px; user-select: none; }
.logo-mark { color: var(--accent); display: flex; }
.logo-text { font-size: 15px; font-weight: 600; letter-spacing: 0.04em; }
.logo-badge {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.15em;
  color: var(--accent); background: var(--accent-glow);
  border: 1px solid rgba(108,143,255,0.2);
  padding: 2px 7px; border-radius: 4px; text-transform: uppercase;
}
.header-right { display: flex; align-items: center; gap: 10px; }
.model-pill {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-family: var(--mono);
  color: var(--text-muted); letter-spacing: 0.04em;
}
.model-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 6px var(--green);
  animation: pulse 2.5s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity:1; box-shadow: 0 0 6px var(--green); }
  50% { opacity:0.5; box-shadow: 0 0 3px var(--green); }
}
.btn-ghost {
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius-xs); width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); cursor: pointer; transition: var(--transition);
}
.btn-ghost:hover { border-color: var(--border-md); color: var(--text); background: rgba(255,255,255,0.04); }

/* ── Main Shell ── */
.app-shell {
  position: relative; z-index: 10;
  flex: 1; padding-top: 56px; padding-bottom: 120px;
  display: flex; flex-direction: column;
}

/* ── Empty State ── */
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 24px; text-align: center;
  animation: fadeUp 0.5s ease both;
}
.empty-logo { color: var(--accent); margin-bottom: 20px; opacity: 0.8; }
.empty-title {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 300; letter-spacing: -0.03em;
  margin-bottom: 8px;
}
.empty-sub {
  font-size: 13px; font-family: var(--mono);
  color: var(--text-dim); letter-spacing: 0.04em;
  margin-bottom: 40px;
}

.suggestions {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; max-width: 560px; width: 100%;
}
.suggestion-card {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
  cursor: pointer; text-align: left; transition: var(--transition);
  font-family: var(--font); font-size: 13px; color: var(--text-muted);
  line-height: 1.4;
}
.suggestion-card:hover {
  border-color: var(--border-md); background: var(--bg-card-2);
  color: var(--text); transform: translateY(-1px);
}
.suggestion-icon { font-size: 18px; flex-shrink: 0; }

/* ── Chat Container ── */
.chat-container {
  display: none; flex: 1;
  max-width: 760px; width: 100%;
  margin: 0 auto; padding: 24px 20px 0;
}
.chat-container.visible { display: block; }

.messages { display: flex; flex-direction: column; gap: 24px; }

/* ── Message Bubbles ── */
.message { display: flex; gap: 12px; animation: fadeUp 0.3s ease both; }

.message.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
  font-family: var(--mono); letter-spacing: 0;
}
.message.assistant .msg-avatar {
  background: var(--accent-glow); color: var(--accent);
  border: 1px solid rgba(108,143,255,0.2);
}
.message.user .msg-avatar {
  background: rgba(167,139,250,0.1); color: var(--accent-2);
  border: 1px solid rgba(167,139,250,0.2);
}

.msg-content { flex: 1; min-width: 0; }

.msg-bubble {
  display: inline-block; max-width: 100%;
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 14px; line-height: 1.75;
  position: relative;
}

.message.assistant .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  color: var(--text);
  width: 100%;
}

.message.user .msg-bubble {
  background: var(--user-bg);
  border: 1px solid rgba(108,143,255,0.15);
  border-top-right-radius: 4px;
  color: var(--text);
  text-align: left;
}

/* ── Markdown styles inside bubble ── */
.msg-bubble h1,.msg-bubble h2,.msg-bubble h3 {
  color: #fff; margin: 16px 0 8px; line-height: 1.3; font-weight: 600;
}
.msg-bubble h1 { font-size: 18px; }
.msg-bubble h2 { font-size: 16px; }
.msg-bubble h3 { font-size: 14px; }
.msg-bubble p { margin: 0 0 10px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { padding-left: 20px; margin: 8px 0 10px; }
.msg-bubble li { margin: 4px 0; }
.msg-bubble strong { color: #fff; font-weight: 600; }
.msg-bubble em { color: #c4c9e0; font-style: italic; }
.msg-bubble a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.msg-bubble hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.msg-bubble blockquote {
  border-left: 3px solid var(--accent); padding-left: 12px;
  color: var(--text-muted); margin: 10px 0; font-style: italic;
}
.msg-bubble code {
  background: rgba(108,143,255,0.1); color: #a5c3ff;
  padding: 2px 6px; border-radius: 4px;
  font-family: var(--mono); font-size: 12px;
}
.msg-bubble pre {
  background: #0a0c12; border: 1px solid var(--border);
  border-radius: var(--radius-xs); padding: 14px 16px;
  overflow-x: auto; margin: 10px 0; position: relative;
}
.msg-bubble pre code {
  background: none; padding: 0; color: #c8d3f0;
  font-size: 13px; white-space: pre;
}
.msg-bubble table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 13px; }
.msg-bubble th, .msg-bubble td { border: 1px solid var(--border); padding: 7px 12px; text-align: left; }
.msg-bubble th { background: rgba(255,255,255,0.04); color: #fff; font-weight: 600; }

/* ── Code copy button ── */
.code-block-wrapper { position: relative; margin: 10px 0; }
.code-lang {
  font-family: var(--mono); font-size: 10px; color: var(--text-dim);
  padding: 6px 14px 0; letter-spacing: 0.06em; text-transform: uppercase;
}
.btn-copy-code {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border);
  border-radius: 5px; padding: 4px 10px;
  font-size: 11px; font-family: var(--mono);
  color: var(--text-muted); cursor: pointer; transition: var(--transition);
}
.btn-copy-code:hover { background: rgba(255,255,255,0.1); color: var(--text); }
.btn-copy-code.copied { color: var(--green); border-color: rgba(52,211,153,0.3); }

/* ── Message actions ── */
.msg-actions {
  display: flex; align-items: center; gap: 6px;
  margin-top: 6px; opacity: 0; transition: opacity var(--transition);
}
.message:hover .msg-actions { opacity: 1; }
.btn-copy-msg {
  display: flex; align-items: center; gap: 5px;
  background: none; border: 1px solid var(--border);
  border-radius: 5px; padding: 4px 10px;
  font-size: 11px; font-family: var(--mono);
  color: var(--text-dim); cursor: pointer; transition: var(--transition);
}
.btn-copy-msg:hover { border-color: var(--border-md); color: var(--text-muted); }
.btn-copy-msg.copied { color: var(--green); border-color: rgba(52,211,153,0.3); }

/* ── Typing indicator ── */
.typing-indicator {
  display: flex; align-items: center; gap: 12px;
  animation: fadeUp 0.3s ease both;
}
.typing-dots {
  display: flex; gap: 5px; align-items: center;
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 12px 16px; border-radius: var(--radius-sm);
  border-top-left-radius: 4px;
}
.typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-dim); display: block;
  animation: bounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%,60%,100% { transform: translateY(0); background: var(--text-dim); }
  30% { transform: translateY(-6px); background: var(--accent); }
}

/* ── Input Area ── */
.input-area {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  padding: 12px 20px 20px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.input-card {
  max-width: 760px; margin: 0 auto;
  background: var(--bg-card); border: 1px solid var(--border-md);
  border-radius: var(--radius); padding: 10px 14px;
  box-shadow: var(--shadow-lg);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-card:focus-within {
  border-color: rgba(108,143,255,0.3);
  box-shadow: var(--shadow-lg), 0 0 0 3px var(--accent-glow);
}
.chat-textarea {
  width: 100%; background: none; border: none; outline: none;
  font-family: var(--font); font-size: 15px; color: var(--text);
  resize: none; line-height: 1.6; max-height: 200px;
  overflow-y: auto; caret-color: var(--accent);
}
.chat-textarea::placeholder { color: var(--text-dim); }
.input-actions {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px;
}
.char-count { font-size: 11px; font-family: var(--mono); color: var(--text-dim); }
.btn-send {
  width: 34px; height: 34px; border-radius: var(--radius-xs);
  background: var(--accent); border: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; cursor: pointer; transition: var(--transition);
  flex-shrink: 0;
}
.btn-send:hover:not(:disabled) { background: #7a9aff; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(108,143,255,0.35); }
.btn-send:disabled { background: var(--bg-card-2); color: var(--text-dim); cursor: not-allowed; transform: none; }
.input-disclaimer {
  text-align: center; font-size: 11px; color: var(--text-dim);
  margin-top: 8px; font-family: var(--mono); letter-spacing: 0.02em;
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: 100px; left: 50%;
  transform: translateX(-50%) translateY(8px);
  z-index: 300; display: flex; align-items: center; gap: 10px;
  background: #1c1013; border: 1px solid rgba(248,113,113,0.2);
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-size: 13px; color: #fcb6b6;
  box-shadow: var(--shadow-lg); max-width: 90vw;
  opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: all; }

/* ── Utilities ── */
.hidden { display: none !important; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .suggestions { grid-template-columns: 1fr; }
  .empty-title { font-size: 1.7rem; }
  .input-area { padding: 10px 12px 16px; }
  .model-pill span:last-child { display: none; }
}
