/* === Kurama Chat — The Fox's Den === */

/* Dark background with subtle fox-fire particles */
.bg-gradient-main {
  background: #0f0f12;
  background-image:
    radial-gradient(ellipse at 20% 80%, rgba(237, 120, 3, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(250, 200, 0, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(237, 74, 137, 0.04) 0%, transparent 60%);
  position: relative;
}

/* Floating fox-fire particles (CSS only) */
.bg-gradient-main::before,
.bg-gradient-main::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(60px);
  opacity: 0.4;
  animation: foxfire 8s ease-in-out infinite;
}
.bg-gradient-main::before {
  width: 200px;
  height: 200px;
  background: rgba(237, 120, 3, 0.15);
  top: 10%;
  left: 5%;
  animation-delay: 0s;
}
.bg-gradient-main::after {
  width: 150px;
  height: 150px;
  background: rgba(250, 200, 0, 0.1);
  bottom: 15%;
  right: 8%;
  animation-delay: -4s;
}

@keyframes foxfire {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.3; }
  25% { transform: translate(15px, -20px) scale(1.1); opacity: 0.5; }
  50% { transform: translate(-10px, 10px) scale(0.95); opacity: 0.35; }
  75% { transform: translate(20px, 15px) scale(1.05); opacity: 0.45; }
}

/* Glassmorphism — dark den style */
.glass-card {
  background: rgba(18, 18, 24, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(237, 120, 3, 0.1);
  border-radius: 1.25rem;
}

/* Header glow border */
.header-glow {
  border-bottom: 1px solid rgba(237, 120, 3, 0.2);
  box-shadow: 0 2px 20px rgba(237, 120, 3, 0.05);
}

/* Fox avatar ring */
.fox-avatar {
  position: relative;
  background: linear-gradient(135deg, rgba(237, 120, 3, 0.3), rgba(250, 200, 0, 0.2));
  box-shadow: 0 0 12px rgba(237, 120, 3, 0.2);
}
.fox-avatar::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 1.5px solid rgba(237, 120, 3, 0.3);
  animation: foxPulse 3s ease-in-out infinite;
}

@keyframes foxPulse {
  0%, 100% { border-color: rgba(237, 120, 3, 0.3); box-shadow: 0 0 8px rgba(237, 120, 3, 0.1); }
  50% { border-color: rgba(250, 200, 0, 0.5); box-shadow: 0 0 16px rgba(250, 200, 0, 0.15); }
}

/* Online status dot */
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
  margin-right: 4px;
  animation: statusPulse 2s ease-in-out infinite;
}
.status-dot.offline { background: #6b7280; animation: none; }
.status-dot.thinking { background: #fbbf24; }
.status-dot.sleeping { background: #8b5cf6; }

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Chat bubbles */
.bubble-user {
  background: linear-gradient(135deg, rgba(237, 120, 3, 0.2), rgba(236, 110, 0, 0.15));
  border: 1px solid rgba(237, 120, 3, 0.25);
  border-radius: 1rem 1rem 0.25rem 1rem;
  color: #e5e5e5;
}

.bubble-bot {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 1rem 1rem 1rem 0.25rem;
  color: rgba(255, 255, 255, 0.85);
  position: relative;
  overflow: hidden;
}

/* Fox paw accent on bot messages */
.bubble-bot::before {
  content: '🐾';
  position: absolute;
  left: -8px;
  bottom: -6px;
  font-size: 10px;
  opacity: 0.25;
  transform: rotate(-20deg);
}

/* Message fade-in */
.msg-enter {
  animation: msgFadeIn 0.35s ease-out forwards;
}

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Typing indicator — fox tail wag style */
.typing-dots {
  display: flex;
  align-items: center;
  gap: 3px;
}
.typing-dots span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ED7803, #FAC800);
  animation: foxDot 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes foxDot {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.3; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* Custom scrollbar — fox orange */
.custom-scrollbar::-webkit-scrollbar {
  width: 4px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(237, 120, 3, 0.2);
  border-radius: 999px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: rgba(237, 120, 3, 0.4);
}
.custom-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: rgba(237, 120, 3, 0.2) transparent;
}

/* Lottie canvas */
#login-canvas,
#bot-canvas {
  width: 100%;
  height: 100%;
}

/* Lottie container glow */
.lottie-glow {
  filter: drop-shadow(0 0 20px rgba(237, 120, 3, 0.15));
}

/* Bot markdown content */
.bot-content p { margin-bottom: 0.4em; }
.bot-content p:last-child { margin-bottom: 0; }
.bot-content strong { color: #FAC800; font-weight: 600; }
.bot-content em { font-style: italic; color: rgba(255,255,255,0.7); }
.bot-content ul, .bot-content ol {
  padding-left: 1.5em;
  margin: 0.3em 0;
  list-style-position: inside;
}
.bot-content ul { list-style-type: disc; }
.bot-content ol { list-style-type: decimal; }
.bot-content li {
  margin-bottom: 0.2em;
  padding-left: 0.2em;
}
.bot-content code {
  background: rgba(237, 120, 3, 0.1);
  border: 1px solid rgba(237, 120, 3, 0.15);
  padding: 0.1em 0.35em;
  border-radius: 0.3em;
  font-size: 0.85em;
  font-family: 'Courier New', monospace;
  color: #FAC800;
}
.bot-content pre {
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(237, 120, 3, 0.1);
  padding: 0.6em 0.8em;
  border-radius: 0.5em;
  overflow-x: auto;
  margin: 0.4em 0;
}
.bot-content pre code {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
}
.bot-content h1, .bot-content h2, .bot-content h3, .bot-content h4 {
  color: #FAC800;
  font-weight: 700;
  margin: 0.6em 0 0.3em;
}
.bot-content h1:first-child, .bot-content h2:first-child,
.bot-content h3:first-child, .bot-content h4:first-child { margin-top: 0; }
.bot-content h1 { font-size: 1.15em; }
.bot-content h2 { font-size: 1.05em; }
.bot-content h3 { font-size: 0.95em; }
.bot-content h4 { font-size: 0.9em; }
.bot-content hr {
  border: none;
  border-top: 1px solid rgba(237, 120, 3, 0.2);
  margin: 0.6em 0;
}
.bot-content ol {
  list-style-type: decimal;
}
.bot-content a {
  color: #ED7803;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Fade transition for lottie area */
.lottie-fade { transition: opacity 0.3s ease; }
.lottie-fade.hidden-anim { opacity: 0; }

/* Input focus glow */
.input-fox:focus {
  border-color: rgba(237, 120, 3, 0.5) !important;
  box-shadow: 0 0 0 2px rgba(237, 120, 3, 0.1), 0 0 20px rgba(237, 120, 3, 0.05);
}

/* Send button fox-fire */
.btn-foxfire {
  background: linear-gradient(135deg, #ED7803, #EC6E00);
  position: relative;
  overflow: hidden;
}
.btn-foxfire::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(250, 200, 0, 0.3), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}
.btn-foxfire:hover::after { opacity: 1; }
.btn-foxfire:hover {
  box-shadow: 0 0 20px rgba(237, 120, 3, 0.3);
}

/* Header action buttons */
.header-action {
  color: rgba(255, 255, 255, 0.3);
  transition: all 0.2s;
}
.header-action:hover {
  color: #ED7803;
  filter: drop-shadow(0 0 4px rgba(237, 120, 3, 0.3));
}

/* Easter egg — fox quip tooltip */
.fox-quip {
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(237, 120, 3, 0.9);
  color: #fff;
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  animation: quipIn 0.3s ease-out, quipOut 0.3s ease-in 2s forwards;
  z-index: 100;
}
.fox-quip::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid rgba(237, 120, 3, 0.9);
}

@keyframes quipIn {
  from { opacity: 0; transform: translateX(-50%) translateY(5px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes quipOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Attach menu */
.attach-menu-card {
  background: rgba(18, 18, 24, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(237, 120, 3, 0.15);
  border-radius: 0.75rem;
  z-index: 50;
}
.attach-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.45rem 0.85rem;
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.8rem;
  transition: all 0.15s;
  text-align: left;
}
.attach-menu-item:hover {
  background: rgba(237, 120, 3, 0.1);
  color: #ED7803;
}

/* Attachment preview chips */
.attach-chip {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(237, 120, 3, 0.08);
  border: 1px solid rgba(237, 120, 3, 0.15);
  border-radius: 0.6rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  max-width: 160px;
  flex-shrink: 0;
}
.attach-chip img {
  width: 28px;
  height: 28px;
  border-radius: 0.35rem;
  object-fit: cover;
}
.attach-chip .chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
}
.attach-chip .chip-remove {
  color: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
  font-size: 1rem;
}
.attach-chip .chip-remove:hover { color: #f87171; }

/* Recording indicator */
.recording-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  animation: recordPulse 1s ease-in-out infinite;
}
@keyframes recordPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Audio message in chat bubble */
.bubble-audio {
  margin-bottom: 0.4rem;
}
.bubble-audio audio {
  width: 100%;
  max-width: 280px;
  height: 36px;
  border-radius: 0.5rem;
  filter: sepia(0.3) hue-rotate(-10deg) saturate(1.5) brightness(0.9);
}
.audio-text {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 0.25rem;
  border-top: 1px solid rgba(237, 120, 3, 0.1);
  padding-top: 0.3rem;
}

/* Attachment in chat bubble */
.bubble-attachment { margin-bottom: 0.35rem; }
.bubble-attachment img {
  max-width: 200px;
  max-height: 150px;
  border-radius: 0.5rem;
  cursor: pointer;
}
.bubble-attachment audio { max-width: 100%; height: 32px; }
.bubble-attachment .file-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(237, 120, 3, 0.08);
  border: 1px solid rgba(237, 120, 3, 0.12);
  border-radius: 0.4rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
}

/* Kurama watermark */
.kurama-watermark {
  position: fixed;
  bottom: 6px;
  right: 10px;
  font-size: 0.55rem;
  color: rgba(237, 120, 3, 0.15);
  letter-spacing: 0.05em;
  pointer-events: none;
  z-index: 0;
}

/* Login card fox-fire border */
.login-card {
  background: rgba(18, 18, 24, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(237, 120, 3, 0.15);
  border-radius: 1.25rem;
  box-shadow: 0 0 40px rgba(237, 120, 3, 0.05);
}

/* ═══════════════════════════════════════════════════════ */
/* Sidebar — ChatGPT-style session list                   */
/* ═══════════════════════════════════════════════════════ */
.sidebar {
  width: 260px;
  display: flex;
  flex-direction: column;
  background: rgba(12, 12, 16, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid rgba(237, 120, 3, 0.1);
  border-radius: 1.25rem 0 0 1.25rem;
  flex-shrink: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid rgba(237, 120, 3, 0.08);
}

.sidebar-title {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
  color: #ED7803;
  background: rgba(237, 120, 3, 0.08);
  border: 1px solid rgba(237, 120, 3, 0.15);
  border-radius: 0.5rem;
  transition: all 0.2s;
  cursor: pointer;
}
.new-chat-btn:hover {
  background: rgba(237, 120, 3, 0.15);
  box-shadow: 0 0 8px rgba(237, 120, 3, 0.1);
}

.sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.session-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.6rem 0.75rem;
  margin-bottom: 2px;
  border-radius: 0.5rem;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.session-item:hover {
  background: rgba(237, 120, 3, 0.06);
  color: rgba(255, 255, 255, 0.85);
}
.session-item.active {
  background: rgba(237, 120, 3, 0.12);
  color: #ED7803;
  border: 1px solid rgba(237, 120, 3, 0.15);
}

/* Session title — truncated text */
.session-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Session action buttons container */
.session-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.session-item:hover .session-actions,
.session-item.active .session-actions,
.session-actions-visible {
  opacity: 1;
}

/* Individual action button */
.session-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 0.35rem;
  color: rgba(255, 255, 255, 0.4);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.session-action-btn svg {
  width: 14px;
  height: 14px;
}
.session-action-btn:hover {
  color: #ED7803;
  background: rgba(237, 120, 3, 0.1);
}

/* Delete button — red accent */
.session-action-delete:hover {
  color: #f87171;
  background: rgba(248, 113, 113, 0.1);
}

/* Save/confirm button — green accent */
.session-action-save:hover {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.1);
}

/* Confirm-yes in delete flow — red */
.session-action-confirm-yes {
  color: rgba(248, 113, 113, 0.7);
}
.session-action-confirm-yes:hover {
  color: #f87171;
  background: rgba(248, 113, 113, 0.15);
}

/* Inline edit input */
.session-edit-input {
  flex: 1;
  min-width: 0;
  padding: 0.15rem 0.4rem;
  font-size: 0.8rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(237, 120, 3, 0.3);
  border-radius: 0.35rem;
  outline: none;
  font-family: inherit;
}
.session-edit-input:focus {
  border-color: rgba(237, 120, 3, 0.5);
  box-shadow: 0 0 0 1px rgba(237, 120, 3, 0.1);
}

/* Delete confirmation inline */
.session-confirm-delete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.5rem;
}
.session-confirm-text {
  font-size: 0.75rem;
  color: rgba(248, 113, 113, 0.8);
  white-space: nowrap;
}
.session-confirm-btns {
  display: flex;
  align-items: center;
  gap: 2px;
}

.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(237, 120, 3, 0.08);
}

.sidebar-user-email {
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 35;
}
.sidebar-overlay.active {
  display: block;
}

/* Hamburger button — hidden on desktop by default via media query */
.hamburger-btn {
  display: none;
}

/* Main chat area */
.chat-main .glass-card:first-child {
  border-radius: 0 1.25rem 0 0;
}

/* ═══════════════════════════════════════════════════════ */
/* Mobile full-screen chat                                */
/* ═══════════════════════════════════════════════════════ */
@media (max-width: 639px) {
  #chat-screen {
    max-width: 100%;
    max-height: none;
  }

  /* Sidebar: off-screen by default, slide-in on .open */
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 40;
    border-radius: 0;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* Show hamburger on mobile */
  .hamburger-btn {
    display: flex;
  }

  /* Always show session action buttons on mobile (no hover) */
  .session-actions {
    opacity: 0.5;
  }
  .session-item.active .session-actions {
    opacity: 1;
  }

  .chat-main .glass-card {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .chat-main .glass-card:first-child {
    border-top: none;
    border-radius: 0;
  }
  #chat-screen > .chat-main > div:last-child .glass-card,
  #chat-screen > .chat-main > .glass-card:last-of-type {
    border-bottom: none;
  }
  .bg-gradient-main::before,
  .bg-gradient-main::after {
    display: none;
  }
}
