/* =================================================
   CHAT WIDGET — Matrix Terminal Style
   ================================================= */

/* --- Toggle Button --- */
.chat-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 56px;
  height: 56px;
  background: #00ff41;
  border: none;
  border-radius: 0;
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s;
  color: #000;
  font-size: 1.4rem;
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  box-shadow:
    0 0 20px rgba(0, 255, 65, 0.3),
    0 0 4px rgba(0, 0, 0, 0.5);
}

.chat-toggle:hover {
  background: #39ff72;
  box-shadow:
    0 0 32px rgba(0, 255, 65, 0.5),
    0 0 60px rgba(0, 255, 65, 0.15);
}

.chat-toggle .chat-toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
}

.chat-toggle .chat-toggle-close {
  display: none;
  color: #000;
}

.chat-toggle.active .chat-toggle-icon {
  display: none;
}
.chat-toggle.active .chat-toggle-close {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Notification --- */
.chat-notification {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: #ff0000;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
}

.chat-notification.show {
  display: flex;
}

/* --- Chat Window --- */
.chat-window {
  position: fixed;
  bottom: 96px;
  right: 28px;
  width: 380px;
  height: 520px;
  background: #000;
  border: 1px solid rgba(0, 255, 65, 0.3);
  border-radius: 0;
  display: none;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  box-shadow:
    0 0 30px rgba(0, 255, 65, 0.06),
    0 0 1px #00ff41 inset,
    0 20px 60px rgba(0, 0, 0, 0.7);
}

.chat-window.open {
  display: flex;
}

/* --- Header --- */
.chat-window-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(0, 255, 65, 0.06);
  border-bottom: 1px solid rgba(0, 255, 65, 0.12);
}

.chat-window-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-window-avatar {
  width: 32px;
  height: 32px;
  background: #00ff41;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: #000;
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
}

.chat-window-header-info h4 {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 1px;
  color: #00ff41;
  font-family: "JetBrains Mono", monospace;
  text-shadow: 0 0 6px rgba(0, 255, 65, 0.25);
}

.chat-window-header-info .chat-window-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.65rem;
  color: #005518;
}

.chat-window-header-info .chat-window-status .status-dot {
  width: 5px;
  height: 5px;
  background: #00ff41;
  border-radius: 50%;
  box-shadow: 0 0 6px #00ff41;
}

.chat-window-close {
  background: transparent;
  border: none;
  color: #00ff41;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  font-family: "JetBrains Mono", monospace;
  transition: text-shadow 0.2s;
}

.chat-window-close:hover {
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.5);
}

/* --- Messages --- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #000;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 255, 65, 0.15);
}

/* --- Welcome --- */
.chat-welcome-widget {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 16px;
  height: 100%;
}

.chat-welcome-widget .welcome-widget-icon {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(0, 255, 65, 0.3);
  background: rgba(0, 255, 65, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #00ff41;
  margin-bottom: 12px;
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.3);
}

.chat-welcome-widget h4 {
  font-size: 0.92rem;
  margin-bottom: 6px;
  color: #00ff41;
  font-family: "JetBrains Mono", monospace;
  text-shadow: 0 0 6px rgba(0, 255, 65, 0.25);
}

.chat-welcome-widget p {
  color: #00aa2e;
  font-size: 0.76rem;
  line-height: 1.65;
  max-width: 250px;
  font-family: "JetBrains Mono", monospace;
}

.chat-welcome-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
  justify-content: center;
}

.chat-welcome-suggestions .chat-suggestion-btn {
  padding: 6px 14px;
  background: rgba(0, 255, 65, 0.04);
  border: 1px solid rgba(0, 255, 65, 0.12);
  color: #00ff41;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: "JetBrains Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chat-welcome-suggestions .chat-suggestion-btn:hover {
  border-color: #00ff41;
  background: rgba(0, 255, 65, 0.1);
  box-shadow: 0 0 8px rgba(0, 255, 65, 0.2);
}

/* --- Messages --- */
.chat-message {
  max-width: 85%;
  padding: 10px 14px;
  font-size: 0.82rem;
  line-height: 1.6;
  font-family: "JetBrains Mono", monospace;
}

.chat-message.user {
  background: #00ff41;
  color: #000;
  align-self: flex-end;
  font-weight: 500;
  box-shadow: 0 0 10px rgba(0, 255, 65, 0.25);
}

.chat-message.bot {
  background: rgba(0, 255, 65, 0.04);
  color: #00ff41;
  align-self: flex-start;
  border: 1px solid rgba(0, 255, 65, 0.12);
}

.chat-message .chat-msg-time,
.chat-message .timestamp {
  font-size: 0.6rem;
  opacity: 0.4;
  margin-top: 4px;
  display: block;
}

/* --- Typing --- */
.chat-message.bot.chat-typing,
.chat-message.bot.typing {
  display: flex;
  gap: 5px;
  padding: 14px 16px;
  align-items: center;
}

.chat-message.bot.chat-typing span,
.chat-message.bot.typing span {
  width: 7px;
  height: 7px;
  background: #00ff41;
  border-radius: 50%;
  display: inline-block;
  animation: matrix-chat-type 1.2s infinite;
  box-shadow: 0 0 4px #00ff41;
}

.chat-message.bot.chat-typing span:nth-child(2),
.chat-message.bot.typing span:nth-child(2) {
  animation-delay: 0.2s;
}
.chat-message.bot.chat-typing span:nth-child(3),
.chat-message.bot.typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes matrix-chat-type {
  0%,
  100% {
    opacity: 0.2;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}

/* --- Links --- */
.chat-message a {
  color: #00ff41;
  text-decoration: underline;
  transition: text-shadow 0.2s;
}

.chat-message a:hover {
  text-shadow: 0 0 6px rgba(0, 255, 65, 0.4);
}

/* --- Code --- */
.chat-message code {
  background: rgba(0, 255, 65, 0.06);
  padding: 2px 5px;
  font-size: 0.76rem;
  border: 1px solid rgba(0, 255, 65, 0.12);
  font-family: "JetBrains Mono", monospace;
}

.chat-message pre {
  background: rgba(0, 255, 65, 0.04);
  padding: 10px;
  margin-top: 6px;
  border: 1px solid rgba(0, 255, 65, 0.12);
  overflow-x: auto;
  font-size: 0.76rem;
  font-family: "JetBrains Mono", monospace;
}

/* --- Input --- */
.chat-input-area,
.chat-input-container {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(0, 255, 65, 0.04);
  border-top: 1px solid rgba(0, 255, 65, 0.12);
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid rgba(0, 255, 65, 0.15);
  background: #000;
  color: #00ff41;
  font-size: 0.82rem;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  font-family: "JetBrains Mono", monospace;
  caret-color: #00ff41;
}

.chat-input:focus {
  border-color: #00ff41;
  box-shadow: 0 0 8px rgba(0, 255, 65, 0.2);
}

.chat-input::placeholder {
  color: #005518;
}

.chat-send {
  width: 40px;
  height: 40px;
  background: #00ff41;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: #000;
  font-size: 1rem;
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-send:hover {
  background: #39ff72;
  box-shadow: 0 0 16px rgba(0, 255, 65, 0.4);
}

.chat-send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* --- Footer --- */
.chat-footer {
  text-align: center;
  padding: 6px;
  background: rgba(0, 255, 65, 0.02);
  border-top: 1px solid rgba(0, 255, 65, 0.06);
}

.chat-footer span {
  font-size: 0.6rem;
  color: #005518;
  font-family: "JetBrains Mono", monospace;
}

.chat-footer a {
  color: #00ff41;
  text-decoration: none;
}

/* --- Error --- */
.chat-error {
  padding: 8px 12px;
  background: rgba(255, 0, 0, 0.04);
  border: 1px solid rgba(255, 0, 0, 0.2);
  color: #ff4444;
  font-size: 0.76rem;
  margin: 0 12px 6px;
  font-family: "JetBrains Mono", monospace;
}

/* --- Loading --- */
.chat-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  color: #00aa2e;
  font-size: 0.78rem;
  font-family: "JetBrains Mono", monospace;
}

/* --- Quick Actions --- */
.chat-quick-actions {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(0, 255, 65, 0.02);
  border-top: 1px solid rgba(0, 255, 65, 0.06);
  overflow-x: auto;
}

.chat-quick-actions::-webkit-scrollbar {
  height: 3px;
}
.chat-quick-actions::-webkit-scrollbar-thumb {
  background: rgba(0, 255, 65, 0.15);
}

.chat-quick-action {
  padding: 5px 10px;
  background: transparent;
  border: 1px solid rgba(0, 255, 65, 0.12);
  color: #00aa2e;
  font-size: 0.68rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  font-family: "JetBrains Mono", monospace;
}

.chat-quick-action:hover {
  border-color: #00ff41;
  color: #00ff41;
  box-shadow: 0 0 6px rgba(0, 255, 65, 0.15);
}

/* --- Attachment --- */
.chat-attachment {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: rgba(0, 255, 65, 0.03);
  border: 1px solid rgba(0, 255, 65, 0.1);
  margin: 0 12px 6px;
  font-size: 0.72rem;
  color: #00aa2e;
  font-family: "JetBrains Mono", monospace;
}

.chat-attachment-remove {
  background: transparent;
  border: none;
  color: #00aa2e;
  cursor: pointer;
  font-size: 0.82rem;
  margin-left: auto;
  transition: color 0.2s;
}

.chat-attachment-remove:hover {
  color: #ff4444;
}

/* --- Overlay --- */
.chat-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9997;
}

.chat-overlay.active {
  display: block;
}

/* --- Welcome message (from JS) --- */
.welcome-message {
  text-align: center;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.welcome-message h5 {
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: #00ff41;
  font-family: "JetBrains Mono", monospace;
  text-shadow: 0 0 6px rgba(0, 255, 65, 0.25);
}

.welcome-message p {
  color: #00aa2e;
  font-size: 0.78rem;
  line-height: 1.6;
  max-width: 260px;
  margin: 0 auto 14px;
  font-family: "JetBrains Mono", monospace;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.quick-action {
  padding: 6px 14px;
  background: rgba(0, 255, 65, 0.04);
  border: 1px solid rgba(0, 255, 65, 0.12);
  color: #00ff41;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: "JetBrains Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.quick-action:hover {
  border-color: #00ff41;
  background: rgba(0, 255, 65, 0.1);
  box-shadow: 0 0 8px rgba(0, 255, 65, 0.2);
}

/* =========================
   RESPONSIVE
   ========================= */

@media (max-width: 968px) {
  .chat-window {
    width: 350px;
    height: 480px;
    bottom: 92px;
    right: 20px;
  }

  .chat-toggle {
    width: 52px;
    height: 52px;
    bottom: 24px;
    right: 20px;
  }
}

@media (max-width: 640px) {
  .chat-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border: none;
  }

  .chat-toggle {
    width: 48px;
    height: 48px;
    bottom: 20px;
    right: 20px;
    font-size: 1.2rem;
  }

  .chat-window-header {
    padding: 10px 14px;
  }
  .chat-window-avatar {
    width: 28px;
    height: 28px;
    font-size: 0.8rem;
  }
  .chat-window-header-info h4 {
    font-size: 0.78rem;
  }
  .chat-messages {
    padding: 12px;
    gap: 8px;
  }
  .chat-message {
    max-width: 90%;
    font-size: 0.78rem;
    padding: 8px 12px;
  }
  .chat-input-area,
  .chat-input-container {
    padding: 8px 10px;
    gap: 6px;
  }
  .chat-input {
    padding: 8px 12px;
    font-size: 0.78rem;
  }
  .chat-send {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
  }

  .chat-welcome-widget {
    padding: 16px 12px;
  }
  .chat-welcome-widget .welcome-widget-icon {
    width: 42px;
    height: 42px;
    font-size: 1.2rem;
  }
  .chat-welcome-widget h4 {
    font-size: 0.82rem;
  }
  .chat-welcome-widget p {
    font-size: 0.7rem;
  }
  .chat-welcome-suggestions .chat-suggestion-btn {
    padding: 5px 10px;
    font-size: 0.66rem;
  }
}

@media (max-width: 380px) {
  .chat-toggle {
    width: 44px;
    height: 44px;
    bottom: 16px;
    right: 16px;
  }
  .chat-message {
    max-width: 92%;
    font-size: 0.76rem;
  }
  .chat-input {
    font-size: 0.76rem;
  }
  .chat-send {
    width: 34px;
    height: 34px;
  }
  .chat-welcome-suggestions {
    flex-direction: column;
  }
  .chat-welcome-suggestions .chat-suggestion-btn {
    width: 100%;
  }
}
