:root {
  /* Light theme colors */
  --background-color: #f9f7f4;
  --text-color: #333333;
  --primary-color: #6366f1;
  --secondary-color: #4f46e5;
  --perspective-left-color: #d1fae5;
  --perspective-right-color: #dbeafe;
  --perspective-left-border: #10b981;
  --perspective-right-border: #3b82f6;
  --header-background: #ffffff;
  --input-background: #ffffff;
  --button-text: #ffffff;
  --header-shadow: rgba(0, 0, 0, 0.05);
  --card-background: #ffffff;
  --card-shadow: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
  /* Dark theme colors - darker, not blue */
  --background-color: #121212;
  --text-color: #e2e8f0;
  --primary-color: #8b5cf6;
  --secondary-color: #7c3aed;
  --perspective-left-color: #064e3b;
  --perspective-right-color: #1e293b;
  --perspective-left-border: #059669;
  --perspective-right-border: #4f46e5;
  --header-background: #1c1c1c;
  --input-background: #2d2d2d;
  --button-text: #ffffff;
  --header-shadow: rgba(0, 0, 0, 0.2);
  --card-background: #242424;
  --card-shadow: rgba(0, 0, 0, 0.2);
}

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

body {
  font-family: 'Bricolage Grotesque', sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  width: 100%;
}

.app-container {
  min-height: 100vh;
  max-width: 100%;
  width: 100%;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding-bottom: 60px; /* Ensure space for footer */
}

.app-controls {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 90;
  display: flex;
  gap: 10px;
  align-items: center;
}

.dark-mode-toggle button {
  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;
  background-color: var(--header-background);
  box-shadow: 0 2px 5px var(--header-shadow);
  transition: transform 0.2s ease;
}

.dark-mode-toggle button:hover {
  transform: scale(1.1);
}

.dark-mode-toggle .sun {
  display: none;
}

.dark-mode-toggle .moon {
  display: block;
}

[data-theme="dark"] .dark-mode-toggle .sun {
  display: block;
}

[data-theme="dark"] .dark-mode-toggle .moon {
  display: none;
}

/* Language selector */
.language-selector select {
  padding: 5px 8px;
  border-radius: 20px;
  border: 1px solid var(--primary-color);
  background-color: var(--header-background);
  color: var(--text-color);
  font-family: inherit;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  outline: none;
  box-shadow: 0 2px 5px var(--header-shadow);
  appearance: none;
  padding-right: 25px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236366f1' d='M6 8.5l-4-4h8z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.language-selector select:hover {
  border-color: var(--secondary-color);
  transform: translateY(-1px);
}

.language-selector select:focus {
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

/* Page transitions */
.page {
  display: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  width: 100%;
}

.page.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 1;
  width: 100%;
}

/* Home Page Styles */
header {
  text-align: center;
  padding: 4rem 1rem;
  background-color: var(--header-background);
  box-shadow: 0 4px 6px var(--header-shadow);
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.logo {
  font-size: 3.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
  letter-spacing: -1px;
  color: var(--primary-color);
}

.tagline {
  font-size: 1.2rem;
  opacity: 0.8;
}

.home-content {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 50vh;
  padding: 2rem 1rem;
  width: 100%;
}

.topic-input-container {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

input[type="text"] {
  padding: 1rem;
  font-size: 1.1rem;
  border-radius: 8px;
  border: 1px solid #ddd;
  width: 100%;
  font-family: inherit;
  background-color: var(--input-background);
  color: var(--text-color);
  transition: border-color 0.3s ease;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-color);
}

button {
  padding: 1rem;
  background-color: var(--primary-color);
  color: var(--button-text);
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.3s ease, transform 0.1s ease;
}

.ai-notice {
  font-size: 0.9rem;
  color: var(--text-color);
  opacity: 0.7;
  margin-top: 1rem;
  text-align: center;
}

button:hover {
  background-color: var(--secondary-color);
}

button:active {
  transform: scale(0.98);
}

.debate-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  position: sticky;
  top: 0;
  z-index: 90;
  background-color: var(--header-background);
  box-shadow: 0 2px 5px var(--header-shadow);
  width: 100%;
  flex-direction: row;
  flex-wrap: nowrap;
}

.debate-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.debate-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center; /* Ensure vertical alignment */
}

.back-button {
  padding: 0.5rem 1rem;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px; /* Fixed height for better alignment */
}

.debate-topic-container {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 40%;
  overflow: hidden;
}

.debate-topic {
  text-align: center;
  margin: 0;
  font-size: 1.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-logo {
  font-family: 'Instrument Serif', serif;
  font-size: 1.3rem;
  color: var(--primary-color);
  margin: 0;
}

.new-topic-button, .export-button {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px; /* Fixed height for better alignment */
}

.debate-container {
  padding: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.debate-columns {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
  width: 100%;
}

.left-column, .right-column {
  width: 48%;
  text-align: center;
}

.group-header {
  font-weight: 600;
  font-size: 1.2rem;
  padding: 0.5rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  background-color: rgba(99, 102, 241, 0.1); /* Subtle background to make headers stand out */
  border-radius: 20px;
  transition: opacity 0.3s ease;
}

.debate-content {
  position: relative;
  width: 100%;
}

/* Perspective cards */
.perspective-card {
  background-color: var(--card-background);
  border-radius: 12px;
  box-shadow: 0 4px 8px var(--card-shadow);
  margin-bottom: 2rem;
  overflow: hidden;
  transform: translateY(20px);
  opacity: 0;
  animation: fadeInUp 0.5s forwards;
}

.perspective-header {
  padding: 1rem;
  background-color: var(--primary-color);
  color: white;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.subtopic-title {
  margin: 0;
  font-size: 1.1rem;
}

.perspectives-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
}

.perspective {
  padding: 1rem;
  border-radius: 8px;
  display: flex;
  align-items: flex-start;
}

.perspective-left {
  background-color: var(--perspective-left-color);
  border-left: 3px solid var(--perspective-left-border);
}

.perspective-right {
  background-color: var(--perspective-right-color);
  border-right: 3px solid var(--perspective-right-border);
  text-align: right;
}

.perspective-emoji {
  font-size: 1.5rem;
  margin-right: 0.5rem;
}

.perspective-right .perspective-emoji {
  margin-right: 0;
  margin-left: 0.5rem;
  order: 2;
}

.perspective-content {
  flex: 1;
}

.perspective-group {
  font-size: 0.8rem;
  margin-top: 0.5rem;
  opacity: 0.7;
  font-style: italic;
}

.more-ideas-button {
  width: 100%;
  padding: 0.75rem;
  background-color: transparent;
  border: 1px dashed var(--primary-color);
  color: var(--primary-color);
  margin-top: 1rem;
  transition: background-color 0.3s ease;
}

.more-ideas-button:hover {
  background-color: rgba(99, 102, 241, 0.1);
}

.more-ideas-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

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

/* Additional perspective animation */
.additional-perspective {
  animation: slideIn 0.4s forwards;
  transform: translateX(-20px);
  opacity: 0;
}

.perspective-right.additional-perspective {
  transform: translateX(20px);
}

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

/* Loading animation */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-left-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

[data-theme="dark"] .loading-spinner {
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: var(--primary-color);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Error message styles */
.error-message {
  padding: 2rem;
  margin: 2rem auto;
  max-width: 600px;
  background-color: rgba(254, 202, 202, 0.2);
  border-left: 4px solid #ef4444;
  border-radius: 8px;
  text-align: center;
}

.error-message h3 {
  font-size: 1.5rem;
  color: #b91c1c;
  margin-bottom: 1rem;
}

.error-message p {
  margin-bottom: 1rem;
}

.error-details {
  font-size: 0.9rem;
  padding: 0.75rem;
  background-color: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
  margin-top: 1rem;
  white-space: pre-wrap;
  text-align: left;
  font-family: monospace;
}

.retry-button {
  margin-top: 1.5rem;
  padding: 0.5rem 1.5rem;
  background-color: #ef4444;
}

.retry-button:hover {
  background-color: #dc2626;
}

/* Responsive design */
@media (max-width: 900px) {
  .debate-columns {
    flex-direction: row; /* Keep horizontal layout */
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
  }
  
  .left-column, .right-column {
    width: auto;
    min-width: 45%; /* Allow some spacing between */
    margin-bottom: 0.5rem;
  }
  
  .group-header {
    white-space: nowrap; /* Prevent text wrapping */
    padding: 0.5rem 1rem; /* Add more padding to fit content */ /* Rounded corners for better appearance */
  }
  
  .debate-header {
    flex-direction: row; /* Maintain horizontal layout */
    flex-wrap: nowrap; /* Prevent wrapping */
    justify-content: space-between;
  }
  
  .debate-controls {
    width: auto; /* Change to auto instead of 100% */
    margin-top: 0;
    display: flex;
    gap: 0.5rem;
  }
  
  .debate-topic-container {
    max-width: 90%;
  }
}

@media (max-width: 600px) {
  .app-controls {
    top: 10px;
    right: 10px;
    gap: 5px;
  }
  
  .language-selector select {
    font-size: 0.8rem;
    padding: 4px 20px 4px 6px;
    background-position: right 6px center;
  }
  
  .logo {
    font-size: 2.5rem;
  }
  
  .debate-columns {
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    margin-bottom: 0.5rem;
  }
  
  .left-column, .right-column {
    width: auto;
    margin-bottom: 0.5rem;
  }
  
  .group-header {
    font-size: 0.9rem;
    padding: 0.3rem 0.8rem;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    display: inline-block;
  }
  
  .debate-topic-container {
    order: 1;
    width: 100%;
    max-width: 100%;
    margin: 0.5rem 0;
    flex-direction: column;
    align-items: center;
  }
  
  .ai-topic-chip {
    margin-left: 0;
    margin-top: 0.3rem;
  }
  
  .back-button, .new-topic-button, .export-button {
    padding: 0.4rem;
    font-size: 0.75rem;
    height: 32px; /* Smaller height for mobile */
  }
  
  .debate-header {
    padding: 0.6rem;
    flex-direction: row; /* Maintain horizontal layout even on small screens */
    justify-content: space-between;
    flex-wrap: wrap; /* Only allow wrapping on very small screens */
    gap: 0.5rem;
  }
  
  .debate-header-left {
    order: 0;
    width: auto;
  }
  
  .debate-controls {
    order: 2;
    width: 100%;
    justify-content: space-between;
    margin-top: 0.5rem;
  }
  
  .topbar-logo {
    font-size: 1.1rem;
  }
  
  .perspective {
    padding: 0.8rem;
  }
  
  .perspective-emoji {
    font-size: 1.3rem;
  }
  
  .perspective-content p {
    font-size: 0.9rem;
  }
  
  .app-footer {
    padding: 0.8rem 0;
  }
  
  .footer-logo {
    font-size: 1.2rem;
  }
  
  .version {
    font-size: 0.7rem;
  }
}

/* For very small screens */
@media (max-width: 380px) {
  .debate-header-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }
  
  .topbar-logo {
    display: none; /* Hide on very small screens to save space */
  }
  
  .back-button, .new-topic-button, .export-button {
    padding: 0.3rem 0.5rem;
    font-size: 0.7rem;
  }
  
  .group-header {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
  }
}

/* Adding CSS for the TOS modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease;
}

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

.modal-container {
  background-color: var(--card-background);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 2rem;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(-20px);
  transition: transform 0.3s ease;
  position: relative;
}

.modal-overlay.active .modal-container {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--primary-color);
  padding-bottom: 1rem;
}

.modal-header h2 {
  font-size: 1.5rem;
  color: var(--primary-color);
  margin: 0;
}

.modal-content {
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.eu-flag {
  width: 50px;
  height: auto;
  margin-right: 10px;
  border-radius: 5px;
}

.modal-title-container {
  display: flex;
  align-items: center;
}

/* Hide perspectives while loading */
.hide-perspectives {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.show-perspectives {
  opacity: 1;
}

/* Footer style */
.app-footer {
  width: 100%;
  padding: 1rem 0;
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  bottom: 0;
  left: 0;
  background-color: var(--header-background);
  box-shadow: 0 -2px 5px var(--header-shadow);
  z-index: 5;
}

.footer-content {
  width: 100%;
  max-width: 1200px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1rem;
}

.footer-left {
  display: flex;
  align-items: center;
}

.footer-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.footer-logo {
  font-family: 'Instrument Serif', serif;
  font-size: 1.5rem;
  color: var(--primary-color);
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.copyright {
  font-size: 0.9rem;
  opacity: 0.7;
}

.copyright a {
  color: var(--primary-color);
  text-decoration: none;
  transition: opacity 0.3s ease;
}

.copyright a:hover {
  opacity: 1;
  text-decoration: underline;
}

.version {
  font-size: 0.8rem;
  opacity: 0.7;
  font-family: 'Bricolage Grotesque', sans-serif;
}

/* Add styles for the advertisement container */
.ads-container {
  margin-top: 2rem;
  background-color: var(--card-background);
  border-radius: 12px;
  box-shadow: 0 4px 8px var(--card-shadow);
  padding: 1rem;
  width: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
}

.ads-container iframe {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  max-width: 100%;
}

.ads-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-color);
  opacity: 0.7;
}

/* Responsive styling for footer and ads */
@media (max-width: 600px) {
  .footer-content {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
  
  .footer-left, .footer-right {
    justify-content: center;
  }
  
  .footer-logo {
    font-size: 1.2rem;
  }
  
  .copyright {
    font-size: 0.8rem;
  }
  
  .ads-container {
    padding: 0.5rem;
  }
  
  .ads-container iframe {
    transform: scale(0.9);
    transform-origin: center top;
  }
}

/* Adding styles for the AI topic chip */
.ai-topic-chip {
  display: inline-flex;
  align-items: center;
  background-color: var(--primary-color);
  color: var(--button-text);
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  border-radius: 1rem;
  margin-left: 0.5rem;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-topic-chip-icon {
  margin-right: 0.3rem;
  font-size: 0.9rem;
}

/* Advanced settings styles */
.advanced-settings-toggle {
  margin-top: 0.75rem;
  display: flex;
  justify-content: center;
}

.advanced-settings-toggle button {
  background: none;
  border: none;
  color: var(--primary-color);
  font-size: 0.9rem;
  padding: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.2s ease;
}

.advanced-settings-toggle button:hover {
  color: var(--secondary-color);
  background: none;
}

.toggle-icon {
  font-size: 1rem;
}

.advanced-settings-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.3s ease, margin 0.3s ease;
  opacity: 0;
  margin-top: 0;
  width: 100%;
}

.advanced-settings-panel.active {
  max-height: 500px; /* Adjust based on content */
  opacity: 1;
  margin-top: 1rem;
}

.settings-section {
  background-color: var(--card-background);
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--card-shadow);
  padding: 1rem;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.setting-group {
  margin-bottom: 1rem;
}

.setting-group:last-child {
  margin-bottom: 0;
}

.setting-header {
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.setting-header label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.setting-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-left: 1.5rem;
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

.setting-controls.active {
  opacity: 1;
}

.input-group {
  width: 100%;
}

.input-group input {
  font-size: 0.9rem;
  padding: 0.75rem;
}

/* Responsive styles for advanced settings */
@media (max-width: 600px) {
  .advanced-settings-panel.active {
    max-height: 650px; /* More height for mobile layout */
  }
}