body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: all 0.3s ease;
  
}

.article-images {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 20px;
}

.article-images img {
  max-width: 20%;
  margin: 10px;
  cursor: pointer;
}

/* Add styles for the article header and metadata */
.article-header {
  margin-bottom: 20px;
}

.metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 20px;
}

.metadata-item {
  flex: 1 1 200px;
  color: var(--text-color);
}

.metadata-item strong {
  display: inline-block;
  margin-right: 5px;
}

.sentiment-tag {
  display: inline-block;
  padding: 5px 10px;
  background-color: #28a745; /* Green for "Very Positive" */
  color: white;
  border-radius: 5px;
  font-size: 0.9rem;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 5px; /* Add 5px gap between .header-left and .header-right */
}

.header-left {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-direction: row; /* Ensure horizontal layout on desktop */
}

.header-logo {
  width: 80px;
  height: 80px;
  display: block;
}

.header-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 15px;
}

.search-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.search-filter select {
  padding: 10px;
  border: 1px solid var(--button-bg);
  border-radius: 5px;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-size: 1rem;
}

.search-filter input {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--button-bg);
  border-radius: 5px;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-size: 1rem;
}

.topics {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
  gap: 4px; /* Add 4px space between buttons */
}

.topics select {
  display: none; /* Hidden by default, shown on mobile */
  padding: 10px;
  border: 1px solid var(--button-bg);
  border-radius: 5px;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-size: 1rem;
  width: 100%;
  max-width: 300px;
}

.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.article-grid .article-card {
  background-color: var(--bg-color);
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: all 0.3s ease;
}

.article-card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
}

.article-card h2 {
  font-size: 1.2em;
  margin: 10px;
  color: var(--text-color);
}

.article-card p {
  margin: 0 10px 10px;
  color: var(--text-color);
  opacity: 0.8;
}

.article-card button {
  display: block;
  width: calc(100% - 20px);
  margin: 0 10px 10px;
  padding: 10px;
  border: none;
  background-color: var(--highlight-bg);
  color: var(--highlight-text);
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.article-card button:hover {
  opacity: 0.9;
}

.article-body img {
  width: 50%;
  height: auto;
  display: block;
  margin: 10px auto;
}

.article-body a {
  color: var(--highlight-bg);
  text-decoration: none;
  transition: color 0.3s ease;
}

.article-body a:hover {
  text-decoration: underline;
}

.remaining-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 2.0s ease-in-out;
}

.remaining-content.expanded {
  max-height: 10000px; /* A large value to ensure all content is visible; adjust if needed */
}

.article-content {
  background-color: var(--bg-color);
  padding: 20px;
  border-radius: 5px;
}

.article-content h1 {
  font-size: 2em;
  margin-bottom: 20px;
  color: var(--text-color);
}

.article-content img {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  margin-bottom: 20px;
}

.article-content div {
  margin-bottom: 20px;
  line-height: 1.6;
  color: var(--text-color);
}

.article-content p {
  margin-bottom: 20px;
  color: var(--text-color);
  opacity: 0.8;
}

.article-content a {
  display: inline-block;
  margin-bottom: 20px;
  color: var(--highlight-bg);
  text-decoration: none;
  font-weight: bold;
}

#grok-chat {
  margin-top: 20px;
  border-top: 1px solid var(--button-bg);
  padding-top: 20px;
}

#grok-chat h3 {
  margin-top: 0;
  color: var(--text-color);
}

#grok-chat p {
  color: var(--text-color);
}

#grok-chat input {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid var(--button-bg);
  border-radius: 5px;
  background-color: var(--bg-color);
  color: var(--text-color);
}

#grok-chat textarea {
  width: 100%;
  height: 150px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--button-bg);
  border-radius: 5px;
  background-color: var(--bg-color);
  color: var(--text-color);
  resize: vertical;
}

.loading-spinner {
  text-align: center;
  padding: 20px;
  color: var(--text-color);
}

#back-to-top {
  position: fixed;
  bottom: 90px;
  right: 20px;
  padding: 10px 20px;
  display: none; /* Initially hidden */
  background-color: rgba(0, 0, 0, 0.7); /* Semi-transparent black background */
  color: var(--text-color);
  border-radius: 5px; /* Match pill shape */
}

/* Base Button Styles (excluding article grid buttons) */
button:not(.article-card button),
a.button,
.generate-summary,
.view-full-text {
  height: 2.5rem;
  font-size: 1rem;
  background: var(--button-bg);
  color: var(--button-text);
  border: 3px solid var(--button-border);
  border-radius: 5px;
  cursor: pointer;
  padding: 0 1rem;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

button:not(.article-card button):hover,
a.button:hover,
.generate-summary:hover,
.view-full-text:hover {
  background: var(--highlight-bg);
  color: var(--highlight-text);
  border-color: var(--highlight-bg);
}

button:not(.article-card button):disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Media query for mobile screens (below 768px) */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px; /* Vertical gap between stacked elements */
  }

  .header-left {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
  }

  .header-left .logo-language {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
  }

  .search-filter {
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }

  .search-filter select {
    width: auto;
    flex: 0 0 auto;
  }

  .search-filter input {
    flex: 1;
    width: 100%;
  }

  .search-filter button.search-button {
    padding: 8px 16px; /* Slightly smaller padding for mobile */
    font-size: 0.9rem; /* Slightly smaller font size */
    width: 100%;
    max-width: 200px; /* Limit button width */
    margin: 0 auto;
  }

  .header-right {
    flex-direction: row;
    justify-content: center;
    gap: 10px;
    width: 100%;
  }

  .header-right button {
    padding: 8px 16px; /* Slightly smaller padding for mobile */
    font-size: 0.9rem; /* Slightly smaller font size */
    flex: 1;
    max-width: 150px; /* Limit button width */
  }

  .topics button {
    display: none !important; /* Hide the topic buttons on mobile */
  }

  .topics select {
    display: block !important; /* Show the dropdown on mobile */
    margin: 0 auto; /* Center the dropdown */
  }
}

/* Media query for tablets (768px to 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .header {
    flex-direction: row;
    align-items: center;
    gap: 5px;
  }

  .header-left {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    width: auto;
  }

  .header-left .logo-language {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .search-filter {
    flex-direction: row;
    gap: 10px;
    flex: 1;
  }

  .search-filter select {
    width: auto;
    flex: 0 0 auto;
  }

  .search-filter input {
    flex: 1;
    width: 100%;
  }

  .search-filter button.search-button {
    padding: 10px 20px;
    font-size: 1rem;
  }

  .header-right {
    flex-direction: row;
    justify-content: flex-end;
    gap: 15px;
    width: auto;
  }

  .header-right button {
    padding: 10px 20px;
    font-size: 1rem;
  }

  .topics button {
    display: flex !important; /* Show topic buttons on tablets */
  }

  .topics select {
    display: none !important; /* Hide dropdown on tablets */
  }
}