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

body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-gradient {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  animation: gradientShift 10s ease infinite;
}

@keyframes gradientShift {
  0%, 100% { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
  50% { background: linear-gradient(135deg, #764ba2 0%, #667eea 100%); }
}

/* Glassmorphism Effect */
.glass-card {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.25);
  transition: all 0.3s ease;
}

.glass-card:hover {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.35);
}

.main-container {
  width: 90%;
  max-width: 1200px;
}

/* AI Selection Screen */
.ai-selection {
  animation: fadeInUp 0.8s ease-out;
  text-align: center;
  max-width: 1000px;
  margin: 0 auto;
}

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

.ai-card {
  cursor: pointer;
  transition: all 0.4s ease;
  border: 2px solid transparent;
  min-height: 300px;
  position: relative;
  overflow: hidden;
  margin: 0 auto;
  max-width: 350px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
}

.ai-card::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.5s;
}

.ai-card:hover::before {
  left: 100%;
}

.ai-card:hover {
  transform: translateY(-10px) scale(1.05);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.15);
}

.ai-card .card-body {
  padding: 2.5rem 2rem;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.ai-card .features {
  margin-top: 1.5rem;
  opacity: 0.8;
  transition: opacity 0.3s ease;
  line-height: 1.6;
}

.ai-card:hover .features {
  opacity: 1;
}

.ai-card h4 {
  margin: 1rem 0 0.5rem 0;
  font-weight: 600;
}

.ai-card p {
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

/* Chat Container */
.chat-container {
  width: 100%;
  max-width: 500px;
  height: 600px;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.5s ease-out;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.title {
  padding: 20px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: white;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  border-radius: 20px 20px 0 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.chat-body {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.chat-body::-webkit-scrollbar {
  width: 6px;
}

.chat-body::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.chat-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.chat-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

.msg {
  max-width: 75%;
  margin-bottom: 12px;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  animation: fadeInScale 0.3s ease-out;
  position: relative;
  word-wrap: break-word;
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.msg.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border-bottom-left-radius: 4px;
  backdrop-filter: blur(5px);
}

.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.msg.typing {
  opacity: 0.7;
}

.msg.typing::after {
  content: '...';
  animation: typing 1.5s infinite;
}

@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}

.chat-footer {
  padding: 20px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0 0 20px 20px;
}

.input-group {
  display: flex;
  gap: 10px;
}

.chat-footer input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 25px;
  outline: none;
  font-size: 14px;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  backdrop-filter: blur(5px);
}

.chat-footer input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.chat-footer input:focus {
  border-color: #4facfe;
  background: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.2);
}

.chat-footer button {
  padding: 12px 20px;
  border: none;
  border-radius: 25px;
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
}

.chat-footer button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79, 172, 254, 0.4);
}

.chat-footer button:active {
  transform: translateY(0);
}

#clear-chat, #back-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
}

#clear-chat:hover, #back-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

/* AI-specific input colors */
.calculator-mode {
  color: #28a745 !important;
  background: rgba(40, 167, 69, 0.2) !important;
  border-color: #28a745 !important;
}

.food-mode {
  color: #fd7e14 !important;
  background: rgba(253, 126, 20, 0.2) !important;
  border-color: #fd7e14 !important;
}

.search-mode {
  color: #2196f3 !important;
  background: rgba(33, 150, 243, 0.2) !important;
  border-color: #2196f3 !important;
}

/* Transition animations */
.chat-body {
  transition: opacity 0.3s ease;
}

.title span {
  transition: all 0.3s ease;
}

/* Wikipedia Container */
.wikipedia-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.wikipedia-content {
  width: 90%;
  max-width: 800px;
  height: 80vh;
  max-height: 600px;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease-out;
}

.wikipedia-header {
  padding: 20px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: white;
  border-radius: 20px 20px 0 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wikipedia-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.btn-close-wiki {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.btn-close-wiki:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.wikipedia-body {
  flex: 1;
  padding: 0;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(5px);
}

.wikipedia-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 10px;
}

.wikipedia-footer {
  padding: 20px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 0 0 20px 20px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.wikipedia-footer input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 25px;
  outline: none;
  font-size: 14px;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  backdrop-filter: blur(5px);
}

.wikipedia-footer input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.wikipedia-footer input:focus {
  border-color: #4facfe;
  background: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.2);
}

.wikipedia-footer button {
  padding: 12px 20px;
  border: none;
  border-radius: 25px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.wikipedia-footer .btn-primary {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(79, 172, 254, 0.3);
}

.wikipedia-footer .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(79, 172, 254, 0.4);
}

.wikipedia-footer .btn-secondary {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.wikipedia-footer .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

/* AI Background Images — always present, toggled via .active */
.ai-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(4px);
  -webkit-filter: blur(4px);
  transform: scale(1.05); /* prevents blurred edges from showing */
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.ai-bg.active {
  opacity: 1;
}

.ai-bg-calculator {
  background-image: url('./images/calculator.png');
}

.ai-bg-food {
  background-image: url('./images/food.png');
}

.ai-bg-normal {
  background-image: url('./images/wikipedia.png');
}

/* Responsive Design */
@media (max-width: 768px) {
  .main-container {
    width: 95%;
    margin: 10px;
  }
  
  .ai-card {
    min-height: 240px;
  }
  
  .ai-card .card-body {
    padding: 1.5rem;
  }
  
  .chat-container {
    height: 80vh;
    max-height: 600px;
  }
  
  .title {
    font-size: 16px;
    padding: 15px;
  }
  
  .chat-body {
    padding: 15px;
  }
  
  .msg {
    max-width: 80%;
    font-size: 13px;
  }
  
  .chat-footer {
    padding: 15px;
  }
  
  .chat-footer input {
    padding: 10px 14px;
    font-size: 13px;
  }
  
  .chat-footer button {
    padding: 10px 16px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .ai-card {
    min-height: 200px;
  }
  
  .ai-card .card-body {
    padding: 1rem;
  }
  
  .ai-card i {
    font-size: 2.5rem !important;
  }
  
  .chat-container {
    height: 100vh;
    border-radius: 0;
    max-height: none;
  }
  
  .msg {
    max-width: 85%;
  }
}

/* Loading animation */
.loading-dots {
  display: inline-flex;
  gap: 4px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  background: currentColor;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

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