/* ═══════════════════════════════════════════
   Ask Ron — AI Chat  |  style.css
   Theme: Dark Education / Math (Matches Portfolio)
═══════════════════════════════════════════ */

/* ─── TOKENS ──────────────────────────── */
:root {
  --neon: #22ff6e;
  --neon-dim: #0fbe4f;
  --neon-glow: rgba(34, 255, 110, 0.18);
  --bg: #050e08;
  --bg-alt: #07140a;
  --card-bg: rgba(9, 22, 12, 0.75);
  --card-border: rgba(34, 255, 110, 0.11);
  --text: #dff0e4;
  --text-muted: rgba(223, 240, 228, 0.52);
  --header-bg: rgba(5, 14, 8, 0.92);
  --input-bg: rgba(12, 28, 16, 0.9);
  --input-border: rgba(34, 255, 110, 0.2);
  --font-s: "Syne", sans-serif;
  --font-d: "DM Sans", sans-serif;
  --font-m: "JetBrains Mono", monospace;
  --radius: 14px;
  --radius-sm: 8px;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --header-h: 62px;
}

[data-theme="light"] {
  --neon: #0a7a32;
  --neon-dim: #0a5e27;
  --neon-glow: rgba(10, 122, 50, 0.12);
  --bg: #f2f9f4;
  --bg-alt: #e6f2ea;
  --card-bg: rgba(255, 255, 255, 0.95);
  --card-border: rgba(10, 122, 50, 0.16);
  --text: #0b1e0f;
  --text-muted: rgba(11, 30, 15, 0.58);
  --header-bg: rgba(242, 249, 244, 0.96);
  --input-bg: rgba(255, 255, 255, 0.97);
  --input-border: rgba(10, 122, 50, 0.22);
}

/* ─── RESET ───────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 16px;
  height: 100%;
}
body {
  font-family: var(--font-d);
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition:
    background 0.3s,
    color 0.3s;
}
a {
  color: var(--neon);
  text-decoration: none;
}
a:hover {
  opacity: 0.8;
}
button {
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
}
textarea {
  font: inherit;
}

/* ─── HEADER ──────────────────────────── */
.chat-header {
  height: var(--header-h);
  background: var(--header-bg);
  border-bottom: 1px solid var(--card-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex-shrink: 0;
  z-index: 100;
  /* FIX: needed so the absolute-positioned brand stays within header bounds */
  position: relative;
}
.chat-header-inner {
  max-width: 760px;
  margin: 0 auto;
  height: 100%;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Left — live badge */
.header-status-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border-radius: 100px;
  border: 1px solid rgba(34, 255, 110, 0.2);
  background: rgba(34, 255, 110, 0.06);
  font-family: var(--font-m);
  font-size: 0.68rem;
  color: var(--neon);
  font-weight: 600;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

/* Center — brand */
.chat-header-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.bot-avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--neon-dim), var(--neon));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-m);
  font-size: 0.58rem;
  font-weight: 600;
  color: #050e08;
  flex-shrink: 0;
  box-shadow: 0 0 14px var(--neon-glow);
}
.chat-header-title {
  font-family: var(--font-s);
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  display: block;
  line-height: 1.2;
}
.chat-header-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: var(--font-m);
  display: block;
  line-height: 1;
}

/* Online dot */
.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--neon);
  animation: pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
.status-label {
  line-height: 1;
}

/* Right — theme toggle */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
  transition:
    color 0.2s,
    border-color 0.2s;
}
.theme-toggle:hover {
  color: var(--neon);
  border-color: var(--neon);
}

/* ─── CHAT WINDOW ─────────────────────── */
.chat-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}
.chat-window {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* ─── MESSAGES ────────────────────────── */
.msg-group {
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
  animation: fadeUp 0.3s var(--ease) both;
}
.bot-group {
  align-self: flex-start;
  max-width: 82%;
}
.user-group {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: 72%;
}

.bot-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--neon-dim), var(--neon));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-m);
  font-size: 0.55rem;
  font-weight: 600;
  color: #050e08;
  flex-shrink: 0;
  align-self: flex-end;
  box-shadow: 0 0 10px var(--neon-glow);
}

.msg-bubbles {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.bubble {
  padding: 0.75rem 1rem;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.7;
  word-break: break-word;
}
.bot-bubble {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text);
  border-bottom-left-radius: 4px;
  backdrop-filter: blur(10px);
}
.user-bubble {
  background: var(--neon);
  color: #050e08;
  font-weight: 500;
  border-bottom-right-radius: 4px;
}
[data-theme="light"] .user-bubble {
  color: #fff;
}

/* FIX: error-bubble needs to override bot-bubble — more specific selector */
.bot-bubble.error-bubble {
  background: rgba(255, 80, 80, 0.08);
  border: 1px solid rgba(255, 80, 80, 0.25);
  color: #ff6b6b;
}

/* FIX: inline code style inside bot bubbles */
.bot-bubble code {
  font-family: var(--font-m);
  font-size: 0.8em;
  background: rgba(34, 255, 110, 0.08);
  border: 1px solid rgba(34, 255, 110, 0.15);
  border-radius: 4px;
  padding: 0.1em 0.4em;
}

/* ─── TYPING INDICATOR ────────────────── */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0.75rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  backdrop-filter: blur(10px);
}
.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--neon);
  opacity: 0.5;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

/* ─── SUGGESTIONS ─────────────────────── */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-left: calc(32px + 0.65rem);
  animation: fadeUp 0.4s var(--ease) 0.15s both;
}
.suggestion-btn {
  font-size: 0.78rem;
  color: var(--neon);
  background: rgba(34, 255, 110, 0.06);
  border: 1px solid rgba(34, 255, 110, 0.2);
  padding: 0.42rem 0.85rem;
  border-radius: 100px;
  transition:
    background 0.2s,
    transform 0.2s var(--spring);
  text-align: left;
}
.suggestion-btn:hover {
  background: rgba(34, 255, 110, 0.14);
  transform: translateY(-2px);
}

/* ─── INPUT ───────────────────────────── */
.chat-input-wrap {
  flex-shrink: 0;
  background: var(--bg);
  border-top: 1px solid var(--card-border);
  padding: 0.85rem 1.25rem 0.65rem;
}
.chat-input-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 14px;
  padding: 0.62rem 0.62rem 0.62rem 1rem;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.chat-input-inner:focus-within {
  border-color: var(--neon);
  box-shadow: 0 0 0 3px rgba(34, 255, 110, 0.1);
}
.chat-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.5;
  resize: none;
  /* FIX: min-height so single line doesn't collapse */
  min-height: 24px;
  max-height: 120px;
  overflow-y: auto;
}
.chat-input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}
.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--neon);
  color: #050e08;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    opacity 0.2s,
    transform 0.2s var(--spring),
    box-shadow 0.2s;
}
.send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
}
.send-btn:not(:disabled):hover {
  transform: scale(1.08);
  box-shadow: 0 0 16px var(--neon-glow);
}
[data-theme="light"] .send-btn {
  color: #fff;
}

.input-hint {
  max-width: 760px;
  margin: 0.45rem auto 0;
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
  font-family: var(--font-m);
}
.input-hint a {
  color: var(--neon);
  opacity: 0.75;
  transition: opacity 0.2s;
}
.input-hint a:hover {
  opacity: 1;
}

/* ─── KEYFRAMES ───────────────────────── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(0.82);
  }
}
@keyframes typingBounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* ─── SCROLLBAR ───────────────────────── */
.chat-main::-webkit-scrollbar {
  width: 4px;
}
.chat-main::-webkit-scrollbar-track {
  background: transparent;
}
.chat-main::-webkit-scrollbar-thumb {
  background: var(--card-border);
  border-radius: 4px;
}

/* ─── MOBILE ──────────────────────────── */
@media (max-width: 600px) {
  .chat-window {
    padding: 1rem 0.9rem;
    gap: 1rem;
  }
  .bubble {
    font-size: 0.85rem;
    padding: 0.65rem 0.88rem;
  }
  .suggestion-btn {
    font-size: 0.73rem;
  }
  .chat-input-wrap {
    padding: 0.7rem 0.9rem 0.5rem;
  }
  .chat-header-brand {
    left: 50%;
    transform: translateX(-50%);
  }
}