/* chat.css – messages, input area, code blocks, thinking indicators */

/* ----------------------------------------- */
/* chat container & layout                   */
/* ----------------------------------------- */

.view-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.view-chat.idle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.view-chat.idle .chat-container {
  flex: none;
  width: 100%;
  display: flex;
  justify-content: center;
}

.view-chat.idle .messages {
  align-items: center;
}

.view-chat.idle .welcome-text {
  margin: 0;
  margin-bottom: 24px;
}

.view-chat.idle .input-area {
  position: relative;
  border-top: none;
  background: transparent;
  padding-top: 0;
  width: 100%;
}

.chat-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 24px 16px;
  scroll-behavior: smooth;
}

.messages {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ----------------------------------------- */
/* message bubbles                           */
/* ----------------------------------------- */

.message {
  opacity: 0;
  transform: translateY(10px);
  animation: fadeIn 0.2s ease forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.user {
  align-self: flex-end;
  max-width: 80%;
}

.message.ai {
  width: 100%;
}

.bubble {
  padding: 14px 18px;
  border-radius: 20px;
  background: rgba(20, 20, 20, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: #eee;
  line-height: 1.6;
  font-size: 14px;
}

.user .bubble {
  background: rgba(30, 30, 30, 0.8);
  border-bottom-right-radius: 6px;
  border-radius: 18px 18px 6px 18px;
}

/* AI message bubbles – final style (overrides previous) */
.ai .bubble {
  border-radius: 16px;
  background: linear-gradient(
    145deg,
    rgba(18, 18, 18, 0.95),
    rgba(25, 25, 25, 0.9)
  );
  border: none;
  box-shadow: 
    0 0 0 1px rgba(96, 165, 250, 0.08),
    0 10px 30px rgba(0, 0, 0, 0.4);
}

.ai .content {
  color: #eee;
  line-height: 1.7;
  font-size: 14px;
}

.ai .content p {
  margin-bottom: 16px;
}

.ai .content strong {
  font-weight: 600;
}

.ai .content em {
  font-style: italic;
}

.ai .content ul,
.ai .content ol {
  margin: 16px 0;
  padding-left: 24px;
}

.ai .content a {
  color: #60a5fa;
  text-decoration: none;
}

.ai .content a:hover {
  text-decoration: underline;
}

.ai .content h1,
.ai .content h2,
.ai .content h3 {
  margin: 20px 0 10px;
  font-weight: 600;
}

/* welcome text – unified */
.welcome-text {
  font-size: clamp(34px, 6vw, 48px);
  font-weight: 700;
  background: linear-gradient(90deg, #ffffff, #60a5fa, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
}

/* ----------------------------------------- */
/* thinking indicators                       */
/* ----------------------------------------- */

.thinking-squares {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  animation: rotateNeural 1.4s linear infinite;
}

.thinking-squares .square {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #60a5fa;
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(96, 165, 250, 0.6);
}

.thinking-squares .square:nth-child(1) {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}
.thinking-squares .square:nth-child(2) {
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}
.thinking-squares .square:nth-child(3) {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}
.thinking-squares .square:nth-child(4) {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

@keyframes rotateNeural {
  100% {
    transform: rotate(360deg);
  }
}

.message.ai.thinking {
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(20, 20, 20, 0.7);
  border: 1px solid rgba(96, 165, 250, 0.15);
  box-shadow: 0 0 20px rgba(96, 165, 250, 0.08);
}

.brain-loader {
  font-size: 28px;
  color: white;
  animation: brainPulse 1.4s ease-in-out infinite;
  text-align: center;
}

@keyframes brainPulse {
  0%,
  100% {
    opacity: 0.6;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
  }
  50% {
    opacity: 1;
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.9);
  }
}

.response-appear {
  opacity: 0;
  transform: translateY(6px);
  animation: responseFade 0.3s ease forwards;
}

@keyframes responseFade {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ----------------------------------------- */
/* code blocks                               */
/* ----------------------------------------- */

.code-block-wrapper {
  border-radius: 12px;
  overflow: hidden;
  background: #0b0b0b;
  margin: 16px 0;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.code-toolbar {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(17, 17, 17, 0.8);
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.15s;
}

.code-block-wrapper:hover .code-toolbar {
  opacity: 1;
}

.lang-label {
  font-size: 12px;
  color: #999;
  padding: 4px 8px;
}

.code-toolbar button {
  background: transparent;
  border: none;
  color: #ddd;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: background 0.1s;
}

.code-toolbar button:hover {
  background: rgba(30, 30, 30, 0.8);
}

.code-toolbar button.copied {
  color: #4ade80;
}

pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  background: transparent;
}

code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ----------------------------------------- */
/* input area                                */
/* ----------------------------------------- */

.input-area {
  padding: 18px 24px;
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  background: linear-gradient(to top, rgba(10, 10, 10, 0.9), transparent);
  z-index: 3;
  position: relative;
  flex-shrink: 0;
}

.input-area::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.02), transparent);
  pointer-events: none;
}

.input-wrapper {
  width: clamp(420px, 60%, 780px);
  margin: 0 auto;
  background: rgba(20, 20, 20, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 60px;
  display: flex;
  align-items: flex-end;
  padding: 8px 12px 8px 20px;
  gap: 8px;
  transition: width 0.25s ease, box-shadow 0.2s ease;
}

.input-wrapper.expanded {
  width: 80%;
}

.input-wrapper.focused {
  box-shadow: 
    0 0 0 2px rgba(96, 165, 250, 0.25),
    0 10px 30px rgba(0, 0, 0, 0.4);
}

.message-input {
  flex: 1;
  background: transparent;
  border: none;
  color: white;
  font-size: 15px;
  outline: none;
  resize: none;
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.5;
  padding: 8px 0;
  caret-color: #60a5fa;
}

.message-input::placeholder {
  color: #555;
}

.action-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* model pill & search toggle */
.model-pill,
.search-toggle {
  background: rgba(30, 30, 30, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 40px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #ddd;
  font-size: 12px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.model-pill {
  height: 34px;
  padding: 10px;
  border-radius: 50%;
}

.model-pill i {
  font-size: 18px;
}

.model-pill.active-brain i {
  color: white;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}

.model-pill span#modelLabel,
.model-pill .chevron {
  display: none;
}

.search-toggle.active {
  background: #1e3a8a;
  color: white;
}

.model-pill:hover,
.search-toggle:hover {
  transform: scale(1.02);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.copy-btn {
  background: transparent;
  border: none;
  color: #888;
  font-size: 12px;
  margin-top: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.message:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  color: #60a5fa;
}

.edit-btn {
  background: transparent;
  border: none;
  color: #888;
  font-size: 12px;
  margin-left: 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.message:hover .edit-btn {
  opacity: 1;
}

.edit-btn:hover {
  color: #60a5fa;
}

.regen-btn {
  margin-top: 8px;
  background: transparent;
  border: none;
  color: #60a5fa;
  font-size: 12px;
  cursor: pointer;
  opacity: 0.7;
}

.regen-btn:hover {
  opacity: 1;
  text-decoration: underline;
}

/* send button */
.send-btn {
  background: linear-gradient(135deg, #16a34a, #22c55e);
  border: none;
  color: white;
  padding: 6px 12px;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.1s, transform 0.1s, box-shadow 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.send-btn i {
  font-size: 14px;
}

.send-btn.disabled {
  background: #4b5563;
  cursor: not-allowed;
  pointer-events: none;
}

.send-btn:not(.disabled):hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 18px rgba(34, 197, 94, 0.4);
}

/* stop button */
.stop-btn {
  background: #991b1b;
  padding: 10px 20px;
  border-radius: 40px;
  color: white;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: none;
  transition: background 0.1s;
}

.stop-btn.visible {
  display: inline-block;
}

.stop-btn:hover {
  background: #b91c1c;
}

/* ----------------------------------------- */
/* model dropdown menu                        */
/* ----------------------------------------- */

.model-dropdown {
  position: relative;
}

.model-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  width: 180px;
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  padding: 4px;
  z-index: 100;
  display: none; /* shown via JS (e.g. .show class) */
}

.model-menu.show {
  display: block;
}

.model-menu-item {
  padding: 8px 12px;
  border-radius: 8px;
  color: #eee;
  font-size: 13px;
  cursor: pointer;
}

.model-menu-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.model-menu-item.active {
  background: rgba(96, 165, 250, 0.15);
  color: #60a5fa;
}

/* ----------------------------------------- */
/* responsive adjustments                    */
/* ----------------------------------------- */

@media (max-width: 768px) {
  .input-wrapper {
    width: 100%;
  }

  .chat-container {
    padding: 16px 16px 12px;
  }

  .bubble {
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  .chat-container {
    padding: 16px 14px 10px;
  }

  .messages {
    gap: 18px;
  }

  .bubble {
    font-size: 15px;
    padding: 14px 16px;
  }

  .message.user {
    max-width: 92%;
  }
}

/* hover effects for larger screens */
@media (min-width: 769px) {
  .message.ai:hover .bubble {
    border-color: rgba(96, 165, 250, 0.2);
  }

  .message.user:hover .bubble {
    border-color: rgba(255, 255, 255, 0.15);
  }
}

/* ----------------------------------------- */
/* scrollbar styling                         */
/* ----------------------------------------- */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}