/* Custom CSS to override/extend Tailwind for specific effects */
:root {
  --bg-gradient-start: #1c1c3a;
  --bg-gradient-end: #0c0c1e;
  --card-bg-light: rgba(
    255,
    255,
    255,
    0.05
  ); /* Lighter translucent background for cards */
  --card-bg-dark: rgba(
    0,
    0,
    0,
    0.2
  ); /* Darker translucent background for cards */
  --border-color: rgba(255, 255, 255, 0.1);
  --text-color-light: #e0e0e0;
  --text-color-dark: #b0b0b0;
  --primary-accent: #8e8eec;
  --secondary-accent: #a9a9ed;
  --chat-bubble-user: #555ed4;
  --chat-bubble-agent: #537fc3;
}

body {
  font-family: "Inter", sans-serif;
  background: linear-gradient(
    135deg,
    var(--bg-gradient-start),
    var(--bg-gradient-end)
  );
  color: var(--text-color-light);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden; /* Hide scrollbars */
  margin: 0;
  perspective: 1200px; /* For CSS 3D perspective */
}

/* Particle Background */
.particle-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.particle {
  position: absolute;
  background-color: var(--primary-accent);
  border-radius: 50%;
  opacity: 0;
  animation: particleFadeMove linear infinite;
  box-shadow: 0 0 5px var(--primary-accent);
}

@keyframes particleFadeMove {
  0% {
    transform: translateZ(0) scale(0.5);
    opacity: 0;
  }
  10% {
    opacity: 0.2;
  }
  80% {
    opacity: 0.1;
  }
  100% {
    transform: translate3d(var(--x), var(--y), var(--z)) scale(var(--s));
    opacity: 0;
  }
}

/* Main UI Container */
#content {
  position: relative;
  z-index: 1;
  width: 95%;
  max-width: 800px;
  height: 95vh;
  max-height: 900px;
  background: var(--card-bg-dark); /* Fallback */
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-color);
  border-radius: 30px;
  /* box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), 0 0 40px rgba(142, 223, 236, 0.15); */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-style: preserve-3d;
  animation: fadeInScale 0.8s ease-out;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Header */
.header {
  padding: 20px 30px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card-bg-light); /* Slightly lighter header */
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-radius: 30px 30px 0 0;
  transform: translateZ(20px); /* Lift header slightly */
}

.header h1 {
  font-weight: 600;
  font-size: 1.6rem;
  color: white;
  /* text-shadow: 0 0 5px rgba(142, 223, 236, 0.5); */
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 15px;
}

.action-button {
  background: var(--card-bg-light);
  border: 1px solid var(--border-color);
  border-radius: 15px;
  padding: 8px 15px;
  color: var(--text-color-light);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.action-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--primary-accent);
  color: var(--primary-accent);
  box-shadow: 0 2px 10px rgba(142, 223, 236, 0.2);
  transform: translateY(-2px);
}

/* Chat History */
.chat-history {
  flex-grow: 1;
  padding: 20px 30px;
  overflow-y: auto;
  scroll-behavior: smooth;
  -ms-overflow-style: none; /* IE and Edge */
  scrollbar-width: none; /* Firefox */
  transform: translateZ(10px); /* Lift chat history slightly */
}

.chat-history::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.message-container {
  display: flex;
  margin-bottom: 15px;
  align-items: flex-end;
  position: relative;
  opacity: 0;
  transform: translateY(20px);
  animation: messageFadeIn 0.5s ease-out forwards;
}

@keyframes messageFadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-container.AI {
  justify-content: flex-start;
}

.message-container.user {
  justify-content: flex-end;
}

.message-bubble {
  max-width: 75%;
  padding: 12px 18px;
  border-radius: 20px;
  line-height: 1.5;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  position: relative;
}

.message-container.user .message-bubble {
  background-color: var(--chat-bubble-user);
  color: white;
  border-bottom-right-radius: 5px; /* Tail for user bubble */
}

.message-container.AI .message-bubble {
  background-color: var(--chat-bubble-agent);
  color: var(--text-color-light);
  border-bottom-left-radius: 5px; /* Tail for agent bubble */
}

.message-avatar {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: white;
  margin: 0 10px;
  background: linear-gradient(
    45deg,
    var(--primary-accent),
    var(--secondary-accent)
  );
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
  background-image: url("/static/adambot/adam_ghibli.svg");
  background-size: cover;
  background-repeat: no-repeat;
}
.message-container.AI .message-avatar {
  order: 0;
  background-image: url("/static/adambot/adam_ghibli.svg");
  background-size: cover;
  background-repeat: no-repeat;
}

.loading-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 18px;
  background-color: var(--chat-bubble-agent);
  border-radius: 20px;
  border-bottom-left-radius: 5px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.dot {
  width: 8px;
  height: 8px;
  background-color: var(--text-color-dark);
  border-radius: 50%;
  animation: dotPulse 1.4s infinite ease-in-out both;
}
.dot:nth-child(1) {
  animation-delay: -0.32s;
}
.dot:nth-child(2) {
  animation-delay: -0.16s;
}
.dot:nth-child(3) {
  animation-delay: 0s;
}

@keyframes dotPulse {
  0%,
  80%,
  100% {
    transform: scale(0);
    opacity: 0;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Chat Input Area */
.chat-input-area {
  padding: 20px 30px;
  border-top: 1px solid var(--border-color);
  background: var(--card-bg-light);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-radius: 0 0 30px 30px;
  display: flex;
  gap: 15px;
  align-items: center;
  transform: translateZ(20px); /* Lift input area slightly */
}

.chat-input {
  flex-grow: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 25px;
  padding: 12px 20px;
  color: var(--text-color-light);
  font-size: 1rem;
  outline: none;
  transition: all 0.2s ease-in-out;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

.chat-input:focus {
  border-color: var(--primary-accent);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3),
    0 0 10px rgba(142, 223, 236, 0.3);
}

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

.action-icon-button {
  background: linear-gradient(
    45deg,
    var(--primary-accent),
    var(--secondary-accent)
  );
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  font-size: 1.3rem;
  color: white;
  box-shadow: 0 4px 15px rgba(142, 223, 236, 0.4);
  transition: all 0.2s ease-in-out;
}

.action-icon-button:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 20px rgba(142, 223, 236, 0.6);
}

.action-icon-button:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 5px rgba(142, 223, 236, 0.2);
}

.microphone-button.recording {
  background: linear-gradient(45deg, #ff6b6b, #ff9b9b);
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.6);
  animation: pulseRed 1.2s infinite ease-in-out;
}

@keyframes pulseRed {
  0% {
    transform: scale(1);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.8);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
  }
}

/* Modals (About, GitHub) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: var(--card-bg-dark);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 30px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5), 0 0 50px rgba(142, 223, 236, 0.3);
  text-align: center;
  transform: scale(0.9);
  opacity: 0;
  transition: all 0.3s ease-in-out;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
  opacity: 1;
}

.modal-content h2 {
  font-size: 1.8rem;
  color: var(--primary-accent);
  margin-bottom: 20px;
  text-shadow: 0 0 8px rgba(142, 223, 236, 0.6);
}

.modal-content p {
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 20px;
  color: var(--text-color-light);
}

.modal-content a {
  color: var(--primary-accent);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease-in-out;
  text-shadow: 0 0 5px rgba(142, 223, 236, 0.4);
}

.modal-content a:hover {
  color: var(--secondary-accent);
  text-decoration: underline;
}

.modal-close-button {
  background: linear-gradient(45deg, #ff6b6b, #ff9b9b);
  border: none;
  border-radius: 15px;
  padding: 10px 25px;
  color: white;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  box-shadow: 0 4px 10px rgba(255, 107, 107, 0.4);
  margin-top: 20px;
}

.modal-close-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(255, 107, 107, 0.6);
}
