/* ================= GLOBAL SETUP ================= */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Outfit", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

/* ================= HIDE SCROLLBARS ================= */

/* For Webkit browsers (Chrome, Safari, Edge, Opera) */
.chat-list::-webkit-scrollbar,
.suggestion-list::-webkit-scrollbar {
  display: none;
}

/* For Firefox, IE and Edge */
.chat-list,
.suggestion-list {
  -ms-overflow-style: none;
  /* IE and Edge */
  scrollbar-width: none;
  /* Firefox */
}

:root {
  /* Dark Mode (Gemini Default) */

  --bg-color: #131314;
  --surface-color: #1e1f20;
  --text-primary: #e3e3e3;
  --text-secondary: #c4c7c5;
  --user-bubble: #282a2c;
  --input-bg: #1e1f20;
  --border-color: #444746;
  --accent-gradient: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
}

.light_mode {
  /* Light Mode */
  --bg-color: #ffffff;
  --surface-color: #f0f4f9;
  --text-primary: #1f1f1f;
  --text-secondary: #444746;
  --user-bubble: #f0f4f9;
  --input-bg: #f0f4f9;
  --border-color: #e1e3e1;
}

body {
  background: var(--bg-color);
  color: var(--text-primary);
  height: 100vh;
  /* Fallback */
  height: 100dvh;
  /* Dynamic Viewport Height for Mobile */
  display: flex;
  flex-direction: column;
}

/* ================= NAV BAR ================= */

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

.logo-area {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.controls button {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: 0.2s;
}

.controls button:hover {
  background: var(--surface-color);
}

/* ================= MAIN CONTAINER ================= */

.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  overflow: hidden;
}

/* ================= LANDING HEADER ================= */

.header {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem;
  animation: fadeIn 0.5s ease;
}

body.hide-header .header {
  display: none;
}

.title {
  font-size: 3.5rem;
  background: linear-gradient(to right, #4285f4, #d96570);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  width: fit-content;
  line-height: 1.2;
}

.subtitle {
  font-size: 2rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 2rem;
}

/* Suggestion Cards */

.suggestion-list {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 10px;
  scrollbar-width: none;
}

.suggestion {
  background: var(--surface-color);
  min-width: 180px;
  height: 180px;
  border-radius: 12px;
  padding: 1.2rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: background 0.2s;
}

.suggestion:hover {
  background: #5e5e5e32;
}

.suggestion .text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.suggestion .icon {
  align-self: flex-end;
  background: var(--bg-color);
  padding: 10px;
  border-radius: 50%;
  font-size: 1.2rem;
}

/* ================= CHAT LIST ================= */

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1rem 150px 1rem;
  /* Space for bottom bar */
  scroll-behavior: smooth;
}

.message {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  animation: fadeUp 0.3s ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

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

/* --- User Message (The Bubble) --- */

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

.message.outgoing .message-content {
  background: var(--user-bubble);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: 18px 18px 4px 18px;
  max-width: 80%;
  font-size: 1rem;
  line-height: 1.5;
  word-wrap: break-word;
}

/* --- AI Message (Clean Layout) --- */

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

.message.incoming .message-header {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

/* The Sparkle Icon styling */

.message.incoming .gemini-icon {
  width: 24px;
  height: 24px;
  animation: rotateSparkle 4s linear infinite;
}

@keyframes rotateSparkle {
  100% {
    transform: rotate(360deg);
  }
}

.message.incoming .text {
  color: var(--text-primary);
  font-size: 1rem;
  line-height: 1.6;
  width: 100%;
  /* Full width container */
}

/* --- MARKDOWN STYLES (CRITICAL FOR MOBILE) --- */

.text strong {
  font-weight: 600;
  color: #a8c7fa;
}

.light_mode .text strong {
  color: #0b57d0;
}

.text p {
  margin-bottom: 0.8rem;
}

/* Code Blocks - The Fix for Mobile Overflow */

.text pre {
  background: #171717;
  padding: 1rem;
  border-radius: 8px;
  margin: 0.5rem 0;
  overflow-x: auto;
  /* Allow horizontal scrolling */
  max-width: 100%;
  /* Prevent exceeding parent */
  border: 1px solid #333;
}

.text code {
  font-family: "Consolas", "Monaco", monospace;
  font-size: 0.9em;
}

.text :not(pre) > code {
  background: rgba(136, 136, 136, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
}

.text ul,
.text ol {
  margin-left: 1.5rem;
  margin-bottom: 0.8rem;
}

.text li {
  margin-bottom: 0.4rem;
}

/* Table Fix for Mobile */

.text table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  display: block;
  /* Make table scrollable block on mobile if needed */
  overflow-x: auto;
}

.text th,
.text td {
  padding: 10px;
  border: 1px solid var(--border-color);
  min-width: 100px;
}

/* Loading Dots */

.loading-dots {
  display: flex;
  gap: 4px;
}

.dot {
  width: 6px;
  height: 6px;
  background: var(--text-secondary);
  border-radius: 50%;

  animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
  animation-delay: -0.32s;
}

.dot:nth-child(2) {
  animation-delay: -0.16s;
}

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

  40% {
    transform: scale(1);
  }
}

/* ================= TYPING AREA ================= */

.typing-area {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--bg-color);
  padding: 1.5rem 1rem;
  z-index: 100;
}

.typing-form {
  max-width: 900px;
  margin: 0 auto;
}

.input-wrapper {
  background: var(--input-bg);
  border-radius: 32px;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  transition: 0.2s;
}

.input-wrapper:focus-within {
  background: #2a2b2d;
  /* Slightly lighter on focus */
}

.light_mode .input-wrapper:focus-within {
  background: #e9eef6;
}

.action-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
}

.typing-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 1rem;
  padding: 0 10px;
  height: 44px;
  /* Taller touch target */
}

.send-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 1.4rem;
  padding: 5px;
  display: none;
  /* Hidden until text entered */
}

.typing-input:valid ~ .send-btn {
  display: block;
}

.disclaimer-text {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.8rem;
}

/* ================= MOBILE RESPONSIVE TWEAKS ================= */

@media (max-width: 768px) {
  /* Tighten Layout */

  .top-bar {
    padding: 0.8rem 1rem;
  }

  .header {
    padding: 1.5rem 1rem;
  }

  .title {
    font-size: 2.8rem;
  }

  .subtitle {
    font-size: 1.5rem;
  }

  /* Chat List Full Width */

  .chat-list {
    padding: 1rem 1rem 140px 1rem;
  }

  /* User bubble wider on mobile */

  .message.outgoing .message-content {
    max-width: 90%;
    padding: 10px 16px;
  }

  /* Suggestions scroll nicely */

  .suggestion {
    min-width: 160px;
    height: 160px;
  }

  /* Input bar floats closer to bottom on mobile */

  .typing-area {
    padding: 1rem 0.8rem;
  }
}

.action-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  /* click area size */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;

  /* --- ADJUSTMENTS --- */
  font-size: 1.6rem;
  /* Icon size */
  margin-right: 5px;
  /* Push text input away */
  transform: translateY(0px);
  /* Change 0px to -2px to move UP, or 2px to move DOWN */
}
