/* Import theme system */
@import url('theme.css');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

:root {
  --primary-green: #2e7d32;
  --light-green: #4caf50;
  --dark-green: #2e7d32;
  --accent-green: #4caf50;
  --bg-primary: #f0f4f7;
  --bg-secondary: #ffffff;
  --text-primary: #333;
  --text-secondary: #616161;
  --border-light: #e0e0e0;
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

body {
  background-color: var(--bg-secondary, #f0f4f7);
  color: var(--text-primary, #333);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  line-height: 1.6;
}

header {
  background: linear-gradient(to right, #2e7d32, #4caf50);
  color: white;
  padding: 1.5rem 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  position: relative;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo i {
  font-size: 2rem;
  color: white;
  animation: gentle-bounce 3s ease-in-out infinite;
}

@keyframes gentle-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

.logo h1 {
  font-size: 1.8rem;
  font-weight: 600;
  color: white;
}

.nav-back {
  color: white;
  background-color: rgba(255, 255, 255, 0.2);
  padding: 10px 20px;
  border-radius: 50px;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.3s ease;
  border: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-back:hover {
  background-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 2rem 1.5rem;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}

#chat-container {
  background-color: var(--bg-primary, #fff);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  overflow: hidden;
  position: relative;
}

.chat-header {
  padding: 1.2rem;
  background-color: var(--bg-secondary, #e8f5e9);
  border-bottom: 1px solid #c8e6c9;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.chat-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    var(--primary-green),
    var(--light-green),
    var(--primary-green)
  );
}

.chat-header i {
  color: #4caf50;
  font-size: 1.4rem;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.chat-header h2 {
  font-size: 1.3rem;
  color: #2e7d32;
  font-weight: 600;
}

#chat-window {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  background-color: var(--bg-secondary, #fafafa);
  position: relative;
}

#chat-window::-webkit-scrollbar {
  width: 6px;
}

#chat-window::-webkit-scrollbar-track {
  background: transparent;
}

#chat-window::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

#chat-window::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

.message {
  max-width: 80%;
  padding: 1rem 1.2rem;
  border-radius: 18px;
  line-height: 1.5;
  position: relative;
  animation: slideInMessage 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: bottom;
  opacity: 0;
  animation-fill-mode: forwards;
}

@keyframes slideInMessage {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  60% {
    opacity: 0.8;
    transform: translateY(-2px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user {
  background: linear-gradient(135deg, #4caf50, #2e7d32);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
  animation-delay: 0.1s;
  position: relative;
}

.user::after {
  content: '';
  position: absolute;
  right: -8px;
  bottom: 8px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 8px solid #2e7d32;
}

.bot {
  background-color: var(--bg-primary, white);
  border: 1px solid var(--border-light, #e0e0e0);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  color: var(--text-primary, #333);
  animation-delay: 0.3s;
  position: relative;
  backdrop-filter: blur(10px);
}

.bot::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 12px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 8px solid var(--bg-primary, white);
}

.message-header {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 0.9rem;
}

.user .message-header {
  color: rgba(255, 255, 255, 0.9);
}

.bot .message-header {
  color: #4caf50;
}

.message-header i {
  margin-right: 10px;
  font-size: 1.1rem;
}

.timestamp {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: 6px;
  text-align: right;
}

#chat-form {
  display: flex;
  padding: 1.2rem;
  background-color: var(--bg-primary, white);
  border-top: 1px solid #eeeeee;
}

.input-container {
  display: flex;
  flex: 1;
  background: var(--bg-secondary, #f5f5f5);
  border-radius: 30px;
  padding: 0 15px;
  align-items: center;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.input-container:focus-within {
  border-color: var(--primary-green, #4caf50);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
  transform: translateY(-1px);
}

#chat-input {
  flex: 1;
  padding: 0.9rem 0.5rem;
  font-size: 1rem;
  border: none;
  background: transparent;
  outline: none;
  color: var(--text-primary);
  transition: all 0.3s ease;
}

#chat-input::placeholder {
  color: var(--text-secondary);
  transition: all 0.3s ease;
}

#chat-input:focus::placeholder {
  opacity: 0.7;
  transform: translateX(4px);
}

#send-button {
  background: linear-gradient(135deg, #4caf50, #2e7d32);
  color: white;
  border: none;
  border-radius: 30px;
  padding: 0.9rem 1.8rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

#send-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.6s;
}

#send-button:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 25px rgba(76, 175, 80, 0.4);
}

#send-button:hover:not(:disabled)::before {
  left: 100%;
}

#send-button:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

#send-button:disabled {
  background: var(--text-muted, #bdbdbd);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#send-button:disabled::before {
  display: none;
}

.typing-indicator {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background-color: var(--bg-primary, white);
  border-radius: 18px;
  align-self: flex-start;
  border: 1px solid var(--border-light, #e0e0e0);
  margin-top: 8px;
  gap: 6px;
  animation: slideInMessage 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.typing-indicator div {
  color: var(--primary-green, #4caf50);
  font-weight: 500;
  font-size: 0.9rem;
}

.typing-indicator span {
  height: 8px;
  width: 8px;
  background-color: var(--primary-green, #9e9e9e);
  border-radius: 50%;
  display: inline-block;
  animation: typingPulse 1.4s infinite ease-in-out;
  opacity: 0.6;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

.typing-indicator span:nth-child(4) {
  animation-delay: 0.6s;
}

@keyframes typingPulse {
  0%, 60%, 100% {
    transform: translateY(0) scale(1);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-8px) scale(1.2);
    opacity: 1;
  }
}

.welcome-message {
  text-align: center;
  padding: 2rem;
  color: #616161;
}

.welcome-message h3 {
  color: #4caf50;
  margin-bottom: 1rem;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.welcome-message h3 i {
  animation: gentle-bounce 3s ease-in-out infinite;
}

.welcome-message p {
  font-size: 1.1rem;
  margin-bottom: 2rem;
  color: var(--text-primary);
  opacity: 0.8;
  color: var(--primary-green);
  margin-bottom: 1rem;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.welcome-message h3 i {
  color: var(--accent-green);
  animation: gentle-bounce 3s ease-in-out infinite;
}

.welcome-message p {
  font-size: 1.1rem;
  margin-bottom: 2rem;
  color: var(--text-primary);
  opacity: 0.8;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 1.5rem;
}

.suggestion {
  background-color: #e8f5e9;
  color: #2e7d32;
  padding: 0.6rem 1.2rem;
  border-radius: 20px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid #c8e6c9;
}

.suggestion:hover {
  background-color: #c8e6c9;
  transform: translateY(-2px);
}

/* Enhanced Mobile Responsiveness */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    gap: 15px;
    padding: 0 1rem;
  }

  .logo h1 {
    font-size: 1.6rem;
  }

  main {
    padding: 0.5rem;
  }

  #chat-container {
    height: calc(100vh - 140px);
    border-radius: 12px;
    margin: 0;
  }

  .chat-header {
    padding: 1rem;
    border-radius: 12px 12px 0 0;
  }

  .chat-header h2 {
    font-size: 1rem;
    line-height: 1.4;
  }

  #chat-window {
    padding: 0.75rem;
  }

  .message {
    max-width: 85%;
    padding: 0.8rem 1rem;
    font-size: 0.95rem;
  }

  .message-header {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
  }

  #chat-form {
    padding: 0.75rem;
    gap: 8px;
  }

  .input-container {
    padding: 0 12px;
    min-height: 44px; /* Touch-friendly minimum */
  }

  #chat-input {
    padding: 0.7rem 0.4rem;
    font-size: 16px; /* Prevent zoom on iOS */
  }

  #send-button {
    padding: 0.7rem 1.2rem;
    min-width: 44px; /* Touch-friendly minimum */
    min-height: 44px;
  }

  .suggestions {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 0 0.5rem;
  }

  .suggestion {
    padding: 0.8rem 1rem;
    font-size: 0.9rem;
    min-height: 44px; /* Touch-friendly */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  .welcome-message {
    padding: 1.5rem 1rem;
  }

  .welcome-message h3 {
    font-size: 1.3rem;
  }

  .welcome-message p {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 14px;
  }

  .logo i {
    font-size: 1.6rem;
  }

  .logo h1 {
    font-size: 1.3rem;
  }

  .nav-back {
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  #chat-container {
    height: calc(100vh - 120px);
    border-radius: 8px;
  }

  .chat-header {
    padding: 0.8rem;
  }

  .chat-header h2 {
    font-size: 0.9rem;
  }

  #chat-window {
    padding: 0.5rem;
  }

  .message {
    max-width: 90%;
    padding: 0.7rem 0.9rem;
    font-size: 0.9rem;
  }

  #chat-form {
    padding: 0.5rem;
    gap: 6px;
    flex-direction: row;
  }

  .input-container {
    padding: 0 10px;
  }

  #chat-input {
    padding: 0.6rem 0.3rem;
    font-size: 16px;
  }

  #send-button {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    align-self: flex-end;
    width: auto;
    min-width: 60px;
  }

  .typing-indicator {
    padding: 10px 12px;
    margin-top: 6px;
  }

  .typing-indicator div {
    font-size: 0.8rem;
  }

  .welcome-message h3 {
    font-size: 1.2rem;
  }

  .welcome-message p {
    font-size: 0.95rem;
  }

  .suggestion {
    padding: 0.7rem 0.8rem;
    font-size: 0.85rem;
  }
}

/* Additional Smooth Animations */
.message-text {
  animation: fadeInText 0.6s ease 0.2s both;
}

@keyframes fadeInText {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Enhanced suggestion hover effects */
.suggestion {
  background-color: var(--light-green, #e8f5e9);
  color: var(--primary-green, #2e7d32);
  padding: 0.6rem 1.2rem;
  border-radius: 20px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border-light, #c8e6c9);
  position: relative;
  overflow: hidden;
}

.suggestion::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(76, 175, 80, 0.1), transparent);
  transition: left 0.5s;
}

.suggestion:hover {
  background-color: var(--primary-green, #c8e6c9);
  color: white;
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 20px rgba(76, 175, 80, 0.2);
}

.suggestion:hover::before {
  left: 100%;
}

.suggestion:active {
  transform: translateY(-1px) scale(0.98);
}

/* Scroll improvements */
#chat-window {
  scroll-behavior: smooth;
}

#chat-window::-webkit-scrollbar {
  width: 4px;
}

#chat-window::-webkit-scrollbar-track {
  background: transparent;
}

#chat-window::-webkit-scrollbar-thumb {
  background: var(--border-light, #e0e0e0);
  border-radius: 2px;
  transition: background 0.3s ease;
}

#chat-window::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary, #9e9e9e);
}

/* Focus improvements for accessibility */
.suggestion:focus,
#chat-input:focus,
#send-button:focus,
.nav-back:focus {
  outline: 2px solid var(--primary-green, #4caf50);
  outline-offset: 2px;
  border-radius: 30px;
}

/* Performance optimizations */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
