/* ═══════════════════════════════════════════
   LLM CHAT PLUGIN — Reusable Styles
   ═══════════════════════════════════════════

   CSS VARIABLES REQUIRED (define in your stylesheet):
   --terracotta, --terracotta-light, --terracotta-dark, --terracotta-bg
   --warm-gray, --warm-gray-light
   --cream, --white
   --text-primary, --text-secondary, --text-tertiary
   --border
   --radius-md, --radius-full
*/

/* ═══════════════════════════════════════════
   MODE TOGGLE — Pill Switch (Static ↔ AI Agent)
   ═══════════════════════════════════════════ */
.mode-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  margin-left: 12px;
  flex-shrink: 0;
  -webkit-user-select: none;
  user-select: none;
}

.mode-toggle-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: color 0.4s, opacity 0.4s;
}
.mode-toggle-label--static { color: var(--text-primary); }
.mode-toggle-label--ai { color: var(--text-tertiary); opacity: 0.5; }

.mode-toggle-track {
  position: relative;
  width: 64px;
  height: 34px;
  border-radius: 100px;
  background: var(--warm-gray-light);
  transition: background 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
}

.mode-toggle-knob {
  position: absolute;
  top: 4px; left: 4px;
  width: 26px; height: 26px;
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1), 0 0 0 0.5px rgba(0,0,0,0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.mode-toggle-icon {
  position: absolute;
  width: 15px; height: 15px;
  color: var(--text-primary);
  transition: opacity 0.3s, transform 0.3s;
}
.mode-toggle-icon--static { opacity: 1; transform: scale(1); }
.mode-toggle-icon--ai { opacity: 0; transform: scale(0.6); }

.mode-toggle.active .mode-toggle-track { background: var(--terracotta-light); }
.mode-toggle.active .mode-toggle-knob { transform: translateX(30px); }
.mode-toggle.active .mode-toggle-icon--static { opacity: 0; transform: scale(0.6); }
.mode-toggle.active .mode-toggle-icon--ai { opacity: 1; transform: scale(1); }
.mode-toggle.active .mode-toggle-label--static { color: var(--text-tertiary); opacity: 0.5; }
.mode-toggle.active .mode-toggle-label--ai { color: var(--text-primary); opacity: 1; }

.mode-toggle:hover .mode-toggle-track {
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.06), 0 0 0 3px rgba(177, 173, 161, 0.25);
}
.mode-toggle.active:hover .mode-toggle-track {
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.06), 0 0 0 3px rgba(193, 95, 60, 0.2);
}

@media (max-width: 600px) {
  .mode-toggle { position: absolute; right: 52px; top: 50%; transform: translateY(-50%); }
  .mode-toggle-label { display: none; }
}

/* ═══════════════════════════════════════════
   CHAT VIEW
   ═══════════════════════════════════════════ */
.chat-view {
  display: none;
  position: fixed;
  top: 76px;
  left: 0;
  width: 100vw;
  height: calc(100vh - 76px);
  height: calc(100dvh - 76px);
  z-index: 90;
  background: var(--cream);
  overflow: hidden;
}
.chat-view.active { display: flex; }

.chat-container {
  display: flex;
  flex-direction: column;
  max-width: 740px;
  width: 100%;
  margin: 0 auto;
  height: 100%;
}

.chat-header {
  padding: 20px 24px;
  border-bottom: 1.5px dashed var(--border);
}
.chat-header-info { display: flex; align-items: center; gap: 12px; }
.chat-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.chat-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.chat-header-name { font-family: 'TikTok Sans', sans-serif; font-weight: 700; font-size: 1rem; letter-spacing: -0.02em; }
.chat-header-sub { font-size: 0.78rem; color: var(--text-tertiary); }

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

.chat-welcome { text-align: center; padding: 48px 16px 24px; }
.chat-welcome h3 { font-family: 'TikTok Sans', sans-serif; font-weight: 700; font-size: 1.4rem; margin-bottom: 8px; }
.chat-welcome p { font-size: 0.9rem; color: var(--text-secondary); max-width: 400px; margin: 0 auto 24px; line-height: 1.6; }

.chat-suggestions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chat-suggestion {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 16px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.chat-suggestion:hover { border-color: var(--terracotta); color: var(--terracotta); background: var(--terracotta-bg); }

@keyframes chatFadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.6;
  animation: chatFadeUp 0.3s ease-out;
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--terracotta);
  color: var(--white);
  border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.chat-typing {
  align-self: flex-start;
  display: flex; gap: 4px;
  padding: 14px 18px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  border-bottom-left-radius: 4px;
}
.chat-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--warm-gray);
  animation: typingDot 1.4s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

.chat-input-wrap {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 16px 24px 24px;
  border-top: 1.5px dashed var(--border);
  background: var(--cream);
}
.chat-input {
  flex: 1; resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-family: inherit;
  font-size: 0.9rem; line-height: 1.5;
  background: var(--white);
  color: var(--text-primary);
  outline: none; max-height: 120px;
  transition: border-color 0.2s;
}
.chat-input::placeholder { color: var(--text-tertiary); }
.chat-input:focus { border-color: var(--terracotta); }

.chat-send {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--terracotta);
  color: var(--white);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.2s;
}
.chat-send:hover { background: var(--terracotta-dark); }
.chat-send svg { width: 18px; height: 18px; }

/* Inline suggestion buttons after replies */
.chat-inline-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: flex-start;
  animation: chatFadeUp 0.3s ease-out;
}

/* Hide portfolio content when chat is active */
body.chat-mode main,
body.chat-mode footer,
body.chat-mode .scroll-top { display: none; }
body.chat-mode {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

/* ── Mobile ── */
@media (max-width: 600px) {
  .chat-view { top: 0; height: 100vh; height: 100dvh; padding-top: 76px; }
  .chat-header { padding: 12px 16px; }
  .chat-header-name { font-size: 0.92rem; }
  .chat-header-sub { font-size: 0.72rem; }
  .chat-avatar { width: 32px; height: 32px; }
  .chat-messages { padding: 14px; gap: 10px; }
  .chat-bubble { max-width: 90%; font-size: 0.84rem; padding: 10px 14px; line-height: 1.5; }
  .chat-input-wrap { padding: 10px 14px calc(16px + env(safe-area-inset-bottom, 0px)); gap: 8px; }
  .chat-input { padding: 10px 14px; font-size: 0.84rem; }
  .chat-send { width: 36px; height: 36px; }
  .chat-send svg { width: 15px; height: 15px; }
  .chat-welcome { padding: 24px 12px 16px; }
  .chat-welcome h3 { font-size: 1.15rem; }
  .chat-welcome p { font-size: 0.82rem; margin-bottom: 16px; }
  .chat-suggestion { font-size: 0.76rem; padding: 6px 12px; }
  .chat-inline-suggestions { gap: 6px; }
}
