/* AI Chat Bubble Styles */
:root {
  --aichat-bg: #0b111c;
  --aichat-border: rgba(255, 255, 255, 0.08);
  --aichat-accent: #00ffcc;
  --aichat-accent2: #00d4ff;
  --aichat-text: #f8fafc;
  --aichat-muted: #94a3b8;
}

.aichat-bubble {
  position: fixed;
  bottom: 30px;
  right: 30px;
  min-width: 62px;
  height: 62px;
  border-radius: 31px; /* Pill shape */
  background: #0b111c;
  border: 1px solid rgba(0, 255, 204, 0.3);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 15px rgba(0, 255, 204, 0.1);
  cursor: pointer;
  z-index: 9999;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.aichat-bubble-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.aichat-bubble-text {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.aichat-bubble::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 33px;
  background: linear-gradient(135deg, var(--aichat-accent), var(--aichat-accent2));
  z-index: -1;
  opacity: 0.2;
  transition: opacity 0.3s;
}

.aichat-bubble:hover::before {
  opacity: 0.5;
}

.aichat-bubble.pulse {
  animation: aichat-pulse 2s infinite;
}

@keyframes aichat-pulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 255, 204, 0.4); }
  70% { box-shadow: 0 0 0 15px rgba(0, 255, 204, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 255, 204, 0); }
}

.aichat-bubble:hover {
  transform: scale(1.05) translateY(-5px);
  border-color: var(--aichat-accent);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6), 0 0 25px rgba(0, 255, 204, 0.3);
}

.aichat-bubble img {
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  flex-shrink: 0;
}

.aichat-window {
  position: fixed;
  bottom: 100px;
  right: 30px;
  width: min(380px, calc(100vw - 60px));
  height: min(600px, calc(100vh - 140px));
  background: rgba(11, 17, 28, 0.98);
  backdrop-filter: blur(25px);
  border: 1px solid var(--aichat-border);
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  z-index: 10000;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: bottom right;
}

.aichat-window.hidden {
  opacity: 0;
  transform: translateY(40px) scale(0.8);
  visibility: hidden;
  pointer-events: none;
}

.aichat-header {
  padding: 20px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--aichat-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.aichat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.aichat-logo-mini {
  width: 36px;
  height: 36px;
  background: rgba(0, 255, 204, 0.1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 255, 204, 0.2);
}

.aichat-logo-mini img {
  width: 24px;
  height: 24px;
}

.aichat-title {
  display: block;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
}

.aichat-header-text {
  min-width: 0;
}

.aichat-subtitle {
  display: block;
  max-width: 230px;
  color: var(--aichat-muted);
  font-size: 11.5px;
  line-height: 1.35;
  margin-top: 2px;
}

.aichat-status {
  font-size: 11px;
  color: var(--aichat-accent);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
}

.aichat-status::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--aichat-accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--aichat-accent);
}

.aichat-close {
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
  transition: background 0.2s;
}

.aichat-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.aichat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.aichat-message {
  padding: 12px 16px;
  border-radius: 18px;
  max-width: 85%;
  font-size: 14.5px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap; /* Preserve new lines */
  animation: aichat-msg-in 0.3s ease forwards;
}

@keyframes aichat-msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.aichat-message.ai {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.aichat-message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--aichat-accent), var(--aichat-accent2));
  color: #041018;
  font-weight: 700;
  border-bottom-right-radius: 4px;
}

.aichat-message a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: opacity 0.2s;
}

.aichat-message.ai a {
  color: var(--aichat-accent);
}

.aichat-message a:hover {
  opacity: 0.8;
}

.aichat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -2px;
  animation: aichat-msg-in 0.3s ease forwards;
}

.aichat-suggestion {
  border: 1px solid rgba(0, 255, 204, 0.18);
  background: rgba(0, 255, 204, 0.07);
  color: var(--aichat-text);
  border-radius: 999px;
  padding: 8px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.aichat-suggestion:hover,
.aichat-suggestion:focus-visible {
  border-color: rgba(0, 255, 204, 0.45);
  background: rgba(0, 255, 204, 0.14);
  outline: none;
  transform: translateY(-1px);
}

.aichat-form {
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid var(--aichat-border);
}

.aichat-input-wrapper {
  position: relative;
  display: flex;
  width: 100%;
}

.aichat-form textarea {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--aichat-border);
  border-radius: 12px;
  padding: 11px 48px 11px 16px;
  color: #fff;
  font-size: 14px;
  transition: all 0.2s;
  width: 100%;
  resize: none;
  height: 44px; /* Fixed initial height */
  min-height: 44px;
  max-height: 120px;
  line-height: 20px;
  font-family: inherit;
  display: block;
  overflow-y: hidden;
}

.aichat-form textarea:focus {
  outline: none;
  border-color: var(--aichat-accent2);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 15px rgba(0, 212, 255, 0.15);
}

.aichat-send {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--aichat-accent);
  color: #041018;
  border: none;
  border-radius: 10px;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 2;
}

.aichat-send-icon {
  display: block;
  width: 18px;
  height: 18px;
  max-width: none;
  color: #041018;
  fill: currentColor;
  flex-shrink: 0;
  pointer-events: none;
}

.aichat-send:hover {
  transform: translateY(-50%) scale(1.05);
  background: #fff;
}

.aichat-send:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: translateY(-50%);
}

.aichat-hint {
  margin: 8px 2px 0;
  color: var(--aichat-muted);
  font-size: 11px;
  line-height: 1.3;
}

.aichat-typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  margin: 0 2px;
  animation: aichat-typing-dots 1.4s infinite;
  opacity: 0.4;
}

.aichat-typing span:nth-child(2) { animation-delay: 0.2s; }
.aichat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aichat-typing-dots {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 720px) {
  .aichat-bubble {
    bottom: 20px;
    right: 20px;
    height: 54px;
    min-width: 54px;
    padding: 0 12px;
    border-radius: 27px;
  }
  .aichat-bubble img {
    width: 28px;
    height: 28px;
  }
  .aichat-bubble-text {
    font-size: 14px;
  }
  .aichat-window {
    bottom: 85px;
    right: 15px;
    width: calc(100vw - 30px);
    height: calc(100vh - 100px);
  }
  .aichat-header {
    padding: 16px;
  }
  .aichat-subtitle {
    max-width: 190px;
  }
  .aichat-suggestions {
    gap: 7px;
  }
  .aichat-suggestion {
    padding: 8px 9px;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
