:root {
  --text-color: #333;
  --bg-color: #fff;
  --bg-secondary: #f5f5f5;
  --heading-color: #6b46c1;
  --link-color: #3b82f6;
  --border-color: #e5e7eb;
}

[data-theme="dark"] {
  --text-color: #e5e7eb;
  --bg-color: #1f2937;
  --bg-secondary: #111827;
  --heading-color: #a78bfa;
  --link-color: #60a5fa;
  --border-color: #374151;
}

body {
  font-family: 'Noto Serif JP', serif;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bg-color);
  color: var(--text-color);
  text-transform: lowercase;
}

main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
}

#theme-switcher {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

#theme-switcher:hover {
  transform: scale(1.1);
}

.search-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  transition: max-width 0.3s ease;
}

.search-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* Enhanced search bar styling */
.search-bar {
  width: 100%;
  padding: 16px 20px;
  border: 1px solid var(--border-color);
  border-radius: 30px;
  background-color: var(--bg-secondary);
  color: var(--text-color);
  transition: all 0.3s ease;
  font-size: 1.1rem;
  
  /* These properties ensure proper placeholder display */
  text-align: center;
  min-height: 70px; /* Increased height for two lines */
  line-height: 1.5;
}

/* Placeholder styling for two lines */
.search-bar::placeholder {
  text-align: center;
  white-space: pre-line; /* This preserves the line break */
  color: var(--placeholder-color, rgba(150, 150, 150, 0.8));
  font-size: 1.1rem;
  line-height: 1.5;
}

.search-bar:focus::placeholder {
  opacity: 0.5;
}

.search-container h1 {
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
  letter-spacing: 0.05em;
  transition: all 0.3s ease;
  text-align: center; /* Ensure center alignment */
  width: 100%; /* Take full width of container */
}

.formatted-answer {
  margin-top: 20px;
  text-align: left;
  font-size: 1.1em;
  background: rgba(var(--accent-rgb), 0.03);
  border-radius: 12px;
  padding: 1.5rem;
  margin-top: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.formatted-answer:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.formatted-answer h2 {
  margin-bottom: 10px;
  font-size: 1.4em;
}

.formatted-answer p {
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 1em;
}

/* Remove the default syntax highlighting colors */
.formatted-answer pre code,
.formatted-answer code {
  background-color: var(--bg-secondary) !important; /* Match your secondary background */
  color: var(--text-color) !important; /* Match your text color */
  border: 1px solid var(--border-color) !important;
  border-radius: 6px;
  padding: 0.75rem !important;
}

/* Also remove specific syntax highlighting classes */
.hljs-keyword, 
.hljs-string,
.hljs-number,
.hljs-comment,
.hljs-function,
.hljs-title,
.hljs-params,
.hljs-built_in,
.hljs-literal,
.hljs-type,
.hljs-tag,
.hljs-attribute,
.hljs-symbol,
.hljs-bullet,
.hljs-addition,
.hljs-variable,
.hljs-template-tag,
.hljs-template-variable {
  color: inherit !important;
  font-weight: normal !important;
}

/* Improve code block readability without highlighting */
.formatted-answer pre {
  background-color: var(--bg-secondary);
  border-radius: 8px;
  padding: 0 !important;
  margin: 1.5rem 0;
  overflow-x: auto;
}

.highlight {
  background-color: rgba(255, 255, 0, 0.2); /* Subtle yellow highlight */
  border-radius: 2px;
  padding: 0 2px;
}

.citation {
  color: var(--accent-color);
  font-weight: bold;
  cursor: pointer;
}

.citation:hover {
  text-decoration: underline;
}

.followup-questions {
  margin-top: 30px;
  padding: 20px;
  background-color: var(--secondary-bg);
  border-radius: 5px;
}

.followup-question {
  display: inline-block;
  margin: 5px;
  padding: 8px 12px;
  background-color: var(--bg-color);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.followup-question:hover {
  background-color: var(--accent-color);
  color: var(--bg-color);
}

.feedback-section {
  margin-top: 30px;
  padding: 25px;
  background-color: rgba(var(--secondary-bg-rgb, 30, 30, 30), 0.5);
  border-radius: 15px;
  border: 1px solid var(--border-color);
}

/* Add these styles for cleaner feedback buttons */
.feedback-buttons {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.feedback-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.feedback-btn:hover {
  transform: scale(1.1);
  background: rgba(127, 127, 127, 0.1);
}

.feedback-btn.selected {
  background-color: #e1e1e1; /* Light grey instead of green */
  border-color: #999;
}

.thumbs-up:hover {
  background-color: rgba(76, 175, 80, 0.3);
}

.thumbs-down:hover {
  background-color: rgba(244, 67, 54, 0.3);
}

.notes-section {
  margin-bottom: 20px;
}

.notes-input {
  width: 100%;
  min-height: 100px;
  padding: 10px;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  border-radius: 5px;
  margin-bottom: 10px;
}

.copy-notes {
  background-color: var(--accent-color);
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  color: var(--bg-color);
  transition: all 0.2s;
}

.copy-notes:hover {
  opacity: 0.9;
}

#followup-query {
  flex: 1;
  padding: 12px 18px;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  border-radius: 25px;
  font-size: 1rem;
  height: 45px;
  transition: all 0.2s ease;
}

#followup-query:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
  outline: none;
}

#submit-followup {
  background-color: transparent;
  border: 1px solid var(--border-color);
  padding: 10px 20px;
  border-radius: 25px;
  cursor: pointer;
  color: var(--text-color);
  font-size: 0.95rem;
  height: 45px;
  min-width: 80px;
  transition: all 0.3s ease;
}

#submit-followup:hover {
  border-color: var(--accent-color);
  background-color: rgba(76, 175, 80, 0.1);
  transform: translateY(-2px);
}

.formatted-sources {
  margin-top: 20px;
  padding-left: 0;
  font-size: 1.1em;
}

.formatted-sources li {
  margin-bottom: 20px;
  padding: 15px;
  background-color: var(--secondary-bg);
  border-radius: 5px;
}

.formatted-sources a {
  color: var(--text-color);
  text-decoration: none;
}

.formatted-sources a:hover {
  text-decoration: underline;
}

.loading-indicator {
  display: none;
  margin-top: 20px;
  font-style: italic;
  font-size: 1.1em;
}

footer {
  background-color: var(--bg-color);
  text-align: center;
  padding: 20px 0;
  margin-top: 40px;
  color: var(--text-color);
}

/* Fix for footer links to respect theme */
footer, .footer-links {
  background-color: var(--bg-color);
  color: var(--text-color);
}

.footer-links a {
  color: var(--text-color);
}

.footer-links a:hover {
  color: var(--link-color);
}

.footer-links {
  margin-bottom: 15px;
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.footer-link, 
footer a {
  color: var(--text-color);
  text-decoration: none;
  transition: color 0.2s;
  font-size: 0.95rem;
}

.footer-link:hover,
footer a:hover {
  color: var(--heading-color);
}

footer p {
  font-size: 0.85rem;
  color: var(--text-color);
  opacity: 0.7;
}

/* Improved TTS controls layout */
.tts-controls {
  display: flex;
  align-items: center;
  margin-top: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.tts-button {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tts-button:hover:not(:disabled) {
  background: rgba(var(--accent-rgb), 0.1);
  transform: translateY(-2px);
}

.tts-status {
  margin-left: 10px;
  font-size: 14px;
  color: var(--secondary-text-color);
  min-width: 90px;
}

/* Center content on all pages */
.page-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 30px 20px;
  text-align: center;
}

/* Content styling */
.page-container h1 {
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
  color: var(--heading-color); /* Use purple instead of green */
}

.page-container h2 {
  font-size: 1.6rem;
  margin: 2rem 0 1rem;
  color: var(--heading-color); /* Use purple instead of green */
}

.page-container p {
  margin-bottom: 1.5rem;
  line-height: 1.7;
  font-size: 1.1rem;
}

/* List styling */
.page-container ul, .page-container ol {
  text-align: left;
  margin: 1.5rem auto;
  padding-left: 2rem;
  max-width: 90%;
}

.page-container li {
  margin-bottom: 0.8rem;
  line-height: 1.5;
}

/* Home link styling */
.home-link {
  display: inline-block;
  margin-top: 30px;
  padding: 10px 20px;
  border: 1px solid var(--border-color);
  border-radius: 25px;
  text-decoration: none;
  color: var(--text-color);
  transition: all 0.3s ease;
}

.home-link:hover {
  border-color: var(--accent-color);
  background-color: rgba(var(--accent-rgb), 0.1);
  transform: translateY(-2px);
}

/* Fix list alignment for terms page */
.page-container ul {
  display: inline-block; /* This allows the list to be centered */
  text-align: left; /* Keep the text within each list item left-aligned for readability */
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem; /* Reduced padding for better visual centering */
}

.page-container li {
  margin-bottom: 15px; /* Add space between list items */
}

/* Make sure paragraphs are nicely spaced */
.page-container p {
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

/* Responsive adjustments */
@media (min-width: 768px) {
  .search-container {
    max-width: 90%; /* Increased from 85% */
  }
  
  .formatted-answer p {
    font-size: 1.2rem;
    line-height: 1.7;
  }
  
  .search-container h1 {
    font-size: 3.5rem;
    margin-bottom: 2rem;
  }
  
  .search-bar {
    font-size: 1.2rem;
    min-height: 80px;
  }
  
  .search-bar::placeholder {
    font-size: 1.2rem;
  }

  #followup-query {
    font-size: 1.1rem;
    padding: 15px 20px;
    height: 50px;
  }
  
  #submit-followup {
    font-size: 1.1rem;
    padding: 12px 25px;
    height: 50px;
  }
}

@media (min-width: 1200px) {
  .search-container {
    max-width: 90%; /* Increased from 75% */
  }
  
  .formatted-answer {
    padding: 2rem;
  }
  
  .formatted-answer p {
    font-size: 1.3rem; /* Larger text on big screens */
  }
  
  .search-container h1 {
    font-size: 4.5rem;
    margin-bottom: 2.5rem;
  }
  
  .search-bar {
    font-size: 1.3rem;
    max-width: 80%;
    margin: 0 auto;
    min-height: 75px;
  }
  
  .search-bar::placeholder {
    font-size: 1.3rem;
  }
}

@media (min-width: 1600px) {
  .search-container {
    max-width: 95%; /* Increased from 65% - now using almost all screen space */
    padding: 0 2rem;
  }
  
  .formatted-answer {
    padding: 2.5rem;
  }
  
  .formatted-answer p {
    font-size: 1.4rem; /* Even larger text on very big screens */
    line-height: 1.8;
  }
}

/* Improved follow-up section styling */
.followup-input {
  display: flex;
  margin-top: 20px;
  width: 100%;
  gap: 10px;
  align-items: center;
}

[data-theme="dark"] .highlight {
  background-color: rgba(255, 255, 150, 0.15); /* Darker theme-friendly highlight */
}

[data-theme="dark"] .feedback-btn.selected {
  background-color: #444; /* Dark grey for dark mode */
  border-color: #666;
}
