/* Chat Widget Styles */
:root {
  --chat-primary: #D4AF37;
  /* Gold */
  --chat-bg: #1a1a1a;
  --chat-surface: #2a2a2a;
  --chat-text: #eaeaea;
  --chat-bot-bg: #2d3748;
}

#chat-widget-container {
  font-family: 'Poppins', sans-serif;
  z-index: 10000;
  position: fixed;
  bottom: 20px;
  right: 20px;
}

/* Toggle Button */
.chat-toggle-btn {
  background: var(--chat-primary);
  color: #000;
  border: none;
  border-radius: 50px;
  /* Pill shape */
  padding: 6px 20px 6px 8px;
  height: auto;
  min-height: 80px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.2s, background 0.2s;
  overflow: visible;
  width: auto;
}

.chat-toggle-btn:hover {
  transform: scale(1.05);
  background: #f1c40f;
  /* Brighter Gold */
}

.chat-toggle-label {
  font-size: 18px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.chat-toggle-icon {
  width: 65px;
  height: 65px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid #000;
}

/* Chat Window */
.chat-window {
  position: fixed;
  /* Fixed to utilize full viewport height relative */
  bottom: 100px;
  right: 20px;
  width: 380px;
  height: 75vh;
  /* Full height */
  max-height: 800px;
  background: var(--chat-bg);
  border: 1px solid #333;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  transition: opacity 0.3s, transform 0.3s;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px);
}

.chat-window.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* Header */
.chat-header {
  background: var(--chat-surface);
  padding: 15px;
  border-bottom: 1px solid #333;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

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

.chat-close {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.chat-options-bar {
  background: var(--chat-surface);
  padding: 8px 15px;
  border-top: 1px solid #333;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.settings-link {
  text-decoration: none;
  font-size: 18px;
  cursor: pointer;
  margin-right: 15px;
  color: #888;
}

.settings-link:hover {
  color: var(--chat-primary);
}

/* Messages Area */
.chat-messages {
  flex: 1;
  padding: 15px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Message Item */
.message-row {
  display: flex;
  gap: 10px;
  max-width: 90%;
}

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

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #444;
  /* Fallback */
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.message-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
  color: #888;
}

.message-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  margin-left: 8px;
  padding: 0;
  opacity: 0.4;
  transition: opacity 0.2s;
}

.message-delete-btn:hover {
  opacity: 1;
  transform: scale(1.1);
}

.message-row.self .message-header {
  justify-content: flex-end;
}

.message-name {
  font-weight: 600;
  color: #aaa;
}

.message-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  color: #eaeaea;
}

.message-row.self .message-bubble {
  background: var(--chat-primary);
  color: #121212;
  border-bottom-right-radius: 2px;
}

.message-row.other .message-bubble {
  background: var(--chat-surface);
  border-bottom-left-radius: 2px;
}

.message-row.bot .message-bubble {
  background: var(--chat-bot-bg);
  border: 1px solid var(--chat-primary);
  color: #fff;
}

/* Input Area */
.chat-input-area {
  padding: 15px;
  background: var(--chat-surface);
  border-top: 1px solid #333;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.ask-toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #bbb;
  cursor: pointer;
  white-space: nowrap;
}

.ask-toggle-label input {
  accent-color: var(--chat-primary);
}

.ask-helper-text {
  font-size: 10px;
  color: #888;
  font-weight: normal;
  margin-left: 4px;
}

#chat-input {
  flex: 1;
  background: #181818;
  border: 1px solid #444;
  color: #fff;
  padding: 10px;
  border-radius: 8px;
  outline: none;
}

#chat-input:focus {
  border-color: var(--chat-primary);
}

#chat-send {
  background: var(--chat-primary);
  border: none;
  color: #000;
  padding: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

#chat-login-btn.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background-color: #ffffff;
  color: #3c4043;
  border: 1px solid #dadce0;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin: 30px auto;
  transition: background-color 0.2s, box-shadow 0.2s;
  width: fit-content;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#chat-login-btn.google-btn:hover {
  background-color: #f7f8f8;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.google-icon {
  width: 24px;
  height: 24px;
}

.hidden {
  display: none !important;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 3px;
}

@media (max-width: 768px) {
  .chat-toggle-btn {
    min-height: 50px;
    padding: 6px 16px 6px 6px;
    gap: 8px;
  }

  .chat-toggle-icon {
    width: 40px;
    height: 40px;
  }

  .chat-toggle-label {
    font-size: 14px;
  }

  .chat-window {
    width: 90%;
    right: 5%;
    bottom: 80px;
    height: 60vh;
  }
}