/* Wavelength-Lore Chatbot Styles */
:root {
  --primary-color: #ffd700;
  --text-color: #e0e0e0;
  --display-font: 'AnimeAce', sans-serif;
  --accent-color: #ff9a8b;
  --gradient-bg: linear-gradient(135deg, #b19cd9, #ff9a8b, #fbc2eb, #a1c4fd);
}

@font-face {
  font-family: 'AnimeAce';
  src: url('./animeace2_reg.ttf') format('truetype');
  src: url('./animeace2_reg.otf') format('opentype');
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'AnimeAce', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--gradient-bg);
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

@media (prefers-reduced-motion: reduce) {
  body {
    animation: none !important;
  }
}

@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

#chat-container {
  width: 100%;
  max-width: 900px;
  height: 700px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  border: 5px solid #333;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.4),
    0 6px 20px rgba(0, 0, 0, 0.19);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#chat-header {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: #333;
  padding: 25px;
  text-align: center;
  border-bottom: 3px solid #333;
}

#chat-header h2 {
  margin-bottom: 8px;
  font-size: 2.2rem;
  font-family: var(--display-font);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  font-weight: bold;
}

#chat-header p {
  font-size: 1rem;
  opacity: 0.8;
  font-family: var(--display-font);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 25px;
  background: rgba(255, 255, 255, 0.8);
  background-image: 
    radial-gradient(circle at 25% 25%, rgba(255, 215, 0, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(255, 154, 139, 0.1) 0%, transparent 50%);
}

.message {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease-in;
}

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

.message-content {
  padding: 15px 20px;
  border-radius: 15px;
  max-width: 80%;
  line-height: 1.6;
  word-wrap: break-word;
  font-family: var(--display-font);
  font-size: 0.95rem;
}

.user-message {
  align-items: flex-end;
}

.user-message .message-content {
  background: linear-gradient(135deg, var(--primary-color), #ffed4e);
  color: #333;
  font-weight: bold;
  border: 2px solid #333;
  box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.2);
}

.assistant-message {
  align-items: flex-start;
}

.assistant-message .message-content {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(240, 240, 240, 0.95));
  color: #333;
  border: 2px solid #333;
  box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.2);
}

.message-sources {
  font-size: 0.8rem;
  color: #555;
  margin-top: 8px;
  padding: 5px 10px;
  background: rgba(255, 215, 0, 0.2);
  border-radius: 10px;
  border: 1px solid rgba(255, 215, 0, 0.4);
  font-family: var(--display-font);
  font-weight: bold;
}

/* Dynamic Link Hover Previews */
.link-preview-popup {
  position: absolute;
  z-index: 1000;
  background: white;
  border: 2px solid #333;
  border-radius: 12px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  padding: 0;
  max-width: 300px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  overflow: hidden;
}

.link-preview-popup.visible {
  opacity: 1;
  transform: translateY(0);
}

.link-preview-image {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
  border-radius: 10px 10px 0 0;
}

.link-preview-content {
  padding: 12px 15px;
}

.link-preview-title {
  font-family: var(--display-font);
  font-weight: bold;
  font-size: 1rem;
  margin: 0 0 6px 0;
  color: #333;
  line-height: 1.2;
}

.link-preview-type {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 8px;
  display: inline-block;
  letter-spacing: 0.5px;
}

.link-preview-type.character {
  background: rgba(76, 175, 80, 0.2);
  color: #2e7d32;
}

.link-preview-type.lore {
  background: rgba(156, 39, 176, 0.2);
  color: #4a148c;
}

.link-preview-type.episode {
  background: rgba(33, 150, 243, 0.2);
  color: #0d47a1;
}

.link-preview-description {
  font-size: 0.85rem;
  color: #666;
  line-height: 1.3;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-preview-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100px;
  font-size: 0.9rem;
  color: #666;
}

.link-preview-error {
  padding: 15px;
  text-align: center;
  color: #666;
  font-size: 0.85rem;
}

/* Arrow pointer for popup */
.link-preview-popup::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 20px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid #333;
}

.link-preview-popup::after {
  content: '';
  position: absolute;
  top: -6px;
  left: 22px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid white;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .link-preview-popup {
    max-width: 250px;
  }
  
  .link-preview-image {
    height: 120px;
  }
  
  .link-preview-content {
    padding: 10px 12px;
  }
  
  .link-preview-title {
    font-size: 0.9rem;
  }
}

/* Dynamic Links in Chat Responses */
.message-content .character-link,
.message-content .lore-link,
.message-content .episode-link,
.message-content .content-link {
  text-decoration: none;
  border-bottom: 1px dotted;
  transition: all 0.2s ease;
  padding: 1px 2px;
  border-radius: 3px;
  font-weight: bold;
}

.message-content .character-link {
  color: #2E7D32;
  border-bottom-color: #4CAF50;
}

.message-content .character-link:hover {
  background: linear-gradient(135deg, #4CAF50, #2E7D32);
  color: white;
  border-bottom: none;
  text-decoration: none;
}

.message-content .lore-link {
  color: #4A148C;
  border-bottom-color: #9C27B0;
}

.message-content .lore-link:hover {
  background: linear-gradient(135deg, #9C27B0, #4A148C);
  color: white;
  border-bottom: none;
  text-decoration: none;
}

.message-content .episode-link {
  color: #0D47A1;
  border-bottom-color: #2196F3;
}

.message-content .episode-link:hover {
  background: linear-gradient(135deg, #2196F3, #0D47A1);
  color: white;
  border-bottom: none;
  text-decoration: none;
}

.message-content .content-link {
  color: #E65100;
  border-bottom-color: #FF9800;
}

.message-content .content-link:hover {
  background: linear-gradient(135deg, #FF9800, #E65100);
  color: white;
  border-bottom: none;
  text-decoration: none;
}

.typing-dots {
  display: flex;
  gap: 6px;
  padding: 15px 20px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(240, 240, 240, 0.95));
  border: 2px solid #333;
  border-radius: 15px;
  box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.2);
}

.typing-dots span {
  width: 10px;
  height: 10px;
  background: var(--accent-color);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

#chat-input-container {
  display: flex;
  gap: 15px;
  padding: 25px;
  background: rgba(255, 255, 255, 0.9);
  border-top: 3px solid #333;
}

#chat-input {
  flex: 1;
  padding: 15px 20px;
  border: 3px solid #333;
  border-radius: 25px;
  font-size: 1rem;
  font-family: var(--display-font);
  outline: none;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.95);
}

#chat-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
  transform: scale(1.02);
}

#chat-input:disabled {
  background: rgba(245, 245, 245, 0.8);
  cursor: not-allowed;
}

#send-button {
  padding: 15px 30px;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: #333;
  border: 3px solid #333;
  border-radius: 25px;
  font-size: 1rem;
  font-family: var(--display-font);
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

#send-button:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 20px rgba(255, 215, 0, 0.4);
}

#send-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#chat-status {
  display: none;
  padding: 10px 20px;
  text-align: center;
  font-size: 13px;
}

.status-info {
  background: #e3f2fd;
  color: #1976d2;
}

.status-error {
  background: #ffebee;
  color: #c62828;
}

/* Scrollbar styling */
#chat-messages::-webkit-scrollbar {
  width: 8px;
}

#chat-messages::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.5);
  border-radius: 10px;
}

#chat-messages::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  border-radius: 10px;
  border: 1px solid #333;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  body {
    padding: 0;
  }
  
  #chat-container {
    height: 100vh;
    border-radius: 0;
    border: none;
    max-width: 100%;
  }
  
  #chat-header h2 {
    font-size: 1.8rem;
  }
  
  #chat-header p {
    font-size: 0.9rem;
  }
  
  .message-content {
    max-width: 85%;
    font-size: 0.9rem;
  }
  
  #chat-input-container {
    padding: 15px;
    gap: 10px;
  }
  
  #chat-input {
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  #send-button {
    padding: 12px 20px;
    font-size: 0.9rem;
  }
}

/* Add some visual flair */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

#send-button:active {
  animation: pulse 0.3s ease;
}
