/* ==========================================================================
   Portfolio Chatbot Widget Styles
   Color scheme matched to site: navy/blue theme
   ========================================================================== */

/* ─── CSS Variables ─── */
.chatbot-widget {
  --chat-bg: #0c1d64;
  --chat-header-bg: #0c1d64;
  --chat-header-border: #1a2d74;
  --chat-input-bg: #0a1850;
  --chat-border: #1a2d74;
  --chat-bubble-user: #3771f4;
  --chat-bubble-assistant: #1a2d74;
  --chat-text-primary: #f4f4f4;
  --chat-text-secondary: #d0d8e8;
  --chat-text-muted: #8898b8;
  --chat-accent: #5DADE2;
  --chat-error: #e74c3c;
  --chat-radius-panel: 16px;
  --chat-radius-bubble: 16px;
  --chat-radius-button: 50%;
  --chat-width: 713px;
  --chat-height: 530px;
  --chat-z-index: 9999;
}

/* ─── Toggle Button ─── */
.chatbot-toggle {
  position: fixed;
  bottom: 40px;
  right: 40px;
  width: 56px;
  height: 56px;
  border-radius: var(--chat-radius-button);
  background: var(--chat-bg);
  border: 2px solid var(--chat-border);
  cursor: pointer;
  z-index: var(--chat-z-index);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.chatbot-toggle:focus-visible {
  outline: 2px solid var(--chat-accent);
  outline-offset: 2px;
}

.chatbot-toggle-icon {
  font-size: 24px;
  color: var(--chat-text-primary);
  line-height: 1;
}

.chatbot-toggle-tooltip {
  position: absolute;
  right: 70px;
  background: var(--chat-bg);
  color: var(--chat-text-primary);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.chatbot-toggle:hover .chatbot-toggle-tooltip {
  opacity: 1;
}

/* Pulse animation on load */
@keyframes chatbot-pulse {
  0%, 100% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); }
  50% { box-shadow: 0 4px 20px rgba(93, 173, 226, 0.5); }
}

.chatbot-toggle.pulse {
  animation: chatbot-pulse 2s ease-in-out;
}

/* ─── Chat Panel ─── */
.chatbot-panel {
  position: fixed;
  bottom: 110px;
  right: 40px;
  width: var(--chat-width);
  height: var(--chat-height);
  background: var(--chat-bg);
  border-radius: var(--chat-radius-panel);
  border: 1px solid var(--chat-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: var(--chat-z-index);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.chatbot-panel.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ─── Header ─── */
.chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: linear-gradient(135deg, var(--chat-header-bg), var(--chat-header-border));
  border-bottom: 1px solid var(--chat-border);
  flex-shrink: 0;
}

.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chatbot-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.chatbot-header-text h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--chat-text-primary);
}

.chatbot-header-text p {
  margin: 2px 0 0 0;
  font-size: 12px;
  color: var(--chat-text-muted);
}

.chatbot-close {
  background: none;
  border: none;
  color: var(--chat-text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.2s ease, background 0.2s ease;
}

.chatbot-close:hover {
  color: var(--chat-text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.chatbot-close:focus-visible {
  outline: 2px solid var(--chat-accent);
}

/* ─── Messages Container ─── */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ─── Welcome Screen ─── */
.chatbot-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  height: 100%;
}

.chatbot-welcome-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.chatbot-welcome h4 {
  margin: 0 0 8px 0;
  font-size: 18px;
  color: var(--chat-text-primary);
}

.chatbot-welcome p {
  margin: 0 0 20px 0;
  font-size: 14px;
  color: var(--chat-text-secondary);
}

.chatbot-starters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.chatbot-starter {
  background: var(--chat-bubble-assistant);
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  padding: 12px;
  font-size: 13px;
  color: var(--chat-text-secondary);
  cursor: pointer;
  text-align: left;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.chatbot-starter:hover {
  background: var(--chat-border);
  border-color: var(--chat-accent);
}

.chatbot-starter:focus-visible {
  outline: 2px solid var(--chat-accent);
}

/* ─── Message Bubbles ─── */
.chatbot-message {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: chatbot-fadeIn 0.2s ease;
}

@keyframes chatbot-fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chatbot-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chatbot-message.assistant {
  align-self: flex-start;
}

.chatbot-message-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

div.chatbot-message-avatar {
  background: var(--chat-bubble-user);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.chatbot-message-content {
  padding: 10px 14px;
  border-radius: var(--chat-radius-bubble);
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.chatbot-message.user .chatbot-message-content {
  background: var(--chat-bubble-user);
  color: var(--chat-text-primary);
  border-bottom-right-radius: 4px;
}

.chatbot-message.assistant .chatbot-message-content {
  background: var(--chat-bubble-assistant);
  color: var(--chat-text-secondary);
  border-bottom-left-radius: 4px;
}

.chatbot-message.error .chatbot-message-content {
  background: rgba(231, 76, 60, 0.2);
  border: 1px solid var(--chat-error);
  color: #f5b7b1;
}

/* ─── Typing Indicator ─── */
.chatbot-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--chat-bubble-assistant);
  border-radius: var(--chat-radius-bubble);
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.chatbot-typing-dot {
  width: 8px;
  height: 8px;
  background: var(--chat-text-muted);
  border-radius: 50%;
  animation: chatbot-bounce 1.2s infinite;
}

.chatbot-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.chatbot-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes chatbot-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-6px);
  }
}

/* ─── Input Area ─── */
.chatbot-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--chat-input-bg);
  border-top: 1px solid var(--chat-border);
  flex-shrink: 0;
}

.chatbot-input {
  flex: 1;
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--chat-text-primary);
  outline: none;
  transition: border-color 0.2s ease;
  font-family: inherit;
  resize: none;
}

.chatbot-input::placeholder {
  color: var(--chat-text-muted);
}

.chatbot-input:focus {
  border-color: var(--chat-accent);
}

.chatbot-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chatbot-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--chat-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}

.chatbot-send:hover:not(:disabled) {
  background: #4a9fd4;
  transform: scale(1.05);
}

.chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chatbot-send:focus-visible {
  outline: 2px solid var(--chat-text-primary);
  outline-offset: 2px;
}

.chatbot-send-icon {
  font-size: 18px;
  color: var(--chat-bg);
  margin-left: 2px;
}

/* ─── Mobile Styles ─── */
@media (max-width: 640px) {
  .chatbot-toggle {
    width: 48px;
    height: 48px;
    bottom: 16px;
    right: 16px;
  }

  .chatbot-toggle-icon {
    font-size: 20px;
  }

  .chatbot-toggle-tooltip {
    display: none;
  }

  .chatbot-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
  }

  .chatbot-panel.open {
    transform: translateY(0);
  }

  .chatbot-header {
    padding: 12px 16px;
  }

  .chatbot-close {
    font-size: 28px;
    padding: 8px;
  }

  .chatbot-starters {
    grid-template-columns: 1fr;
  }
}

/* ─── Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
  .chatbot-toggle,
  .chatbot-panel,
  .chatbot-message,
  .chatbot-typing-dot {
    animation: none;
    transition: none;
  }

  .chatbot-panel.open {
    opacity: 1;
    transform: none;
  }
}

/* ─── Scrollbar Styling ─── */
.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--chat-border);
  border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: var(--chat-text-muted);
}
