/* Turga AI — ChatGPT-style chat shell over the hero ask box */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.box-ask-wrap {
  transition: max-width 0.35s ease, margin 0.35s ease;
}

.box-ask-wrap .ai-chat-shell {
  display: none;
}

/* Active chat mode — keep original ask-box width (theme: 860px), no tall ChatGPT panel */
.box-ask-wrap.is-chat-active {
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(10, 12, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  overflow: hidden;
  backdrop-filter: blur(14px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.box-ask-wrap.is-chat-active .ai-chat-shell {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.box-ask-wrap.is-chat-active .box-ask {
  border: 0;
  background: transparent;
  box-shadow: none;
  margin: 0;
  border-radius: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.box-ask-wrap.is-chat-active .box-ask .form-ask,
.box-ask-wrap.is-chat-active .box-ask .form-content {
  margin: 0;
}

.box-ask-wrap.is-chat-active .hafl-plus {
  display: none;
}

.box-ask-wrap.is-chat-active .field-bottom .field_left {
  display: none;
}

.box-ask-wrap.is-chat-active .form-content > input.style-2,
.box-ask-wrap.is-chat-active .form-content > input {
  padding-top: 0.85rem;
  padding-bottom: 0.35rem;
}

.ai-chat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.ai-chat-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: #fff;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.ai-chat-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #7eb6ff;
  box-shadow: 0 0 0 4px rgba(126, 182, 255, 0.15);
}

.ai-chat-reset {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.ai-chat-reset:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.28);
}

.ai-chat-messages {
  flex: 1 1 auto;
  overflow: auto;
  max-height: 220px;
  padding: 1.15rem 1.15rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
  text-align: left;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.ai-chat-messages::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.ai-msg {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: min(92%, 640px);
  animation: ai-msg-in 0.28s ease;
}

.ai-msg-user {
  align-self: flex-end;
  align-items: flex-end;
}

.ai-msg-assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.ai-msg-label {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

.ai-msg-bubble {
  border-radius: 14px;
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  line-height: 1.65;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.ai-msg-user .ai-msg-bubble {
  background: rgba(89, 151, 255, 0.18);
  border: 1px solid rgba(89, 151, 255, 0.28);
  color: #f4f7f5;
  border-bottom-right-radius: 4px;
}

.ai-msg-assistant .ai-msg-bubble {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(244, 247, 245, 0.92);
  border-bottom-left-radius: 4px;
}

.ai-msg.is-error .ai-msg-bubble {
  color: #ff9c9c;
  border-color: rgba(255, 120, 120, 0.28);
  background: rgba(80, 20, 20, 0.35);
}

.ai-msg-bubble p {
  margin: 0 0 0.75rem;
}

.ai-msg-bubble p:last-child {
  margin-bottom: 0;
}

.ai-msg-bubble ul,
.ai-msg-bubble ol {
  margin: 0 0 0.75rem;
  padding-left: 1.2rem;
}

.ai-msg-bubble li {
  margin-bottom: 0.3rem;
}

.ai-msg-bubble h3,
.ai-msg-bubble h4,
.ai-msg-bubble h5 {
  color: #fff;
  margin: 0.7rem 0 0.4rem;
  font-size: 1.02rem;
  line-height: 1.35;
}

.ai-msg-bubble h3:first-child,
.ai-msg-bubble h4:first-child,
.ai-msg-bubble h5:first-child {
  margin-top: 0;
}

.ai-code {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.8rem 0.95rem;
  overflow-x: auto;
  margin: 0.65rem 0;
  font-size: 0.85rem;
  line-height: 1.5;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.ai-code::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.ai-inline-code {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  font-size: 0.9em;
}

.ai-typing {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  min-height: 1.2rem;
}

.ai-typing i {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  animation: ai-bounce 1.1s ease-in-out infinite;
}

.ai-typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.ai-typing i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes ai-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@keyframes ai-msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.form-ask .btn-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.box-ask-wrap.is-thinking .btn-submit {
  opacity: 0.55;
}

/* Soften hero title while chatting so the panel reads as the main surface */
.section-hero:has(.box-ask-wrap.is-chat-active) .sect-title {
  opacity: 0.35;
  transform: scale(0.98);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}

@media (max-width: 767.98px) {
  .box-ask-wrap.is-chat-active {
    min-height: min(72vh, 560px);
    border-radius: 14px;
  }

  .ai-chat-messages {
    padding: 0.9rem 0.85rem 0.35rem;
  }

  .ai-msg {
    max-width: 100%;
  }
}
