/* CSS Variables for theming */
:root {
  --bg-color: #ffffff;
  --text-color: #333333;
  --header-bg: #f8f9fa;
  --border-color: #e0e0e0;
  --feed-bg: #f8f9fa;
  --feed-hover-bg: #e9ecef;
  --article-bg: #ffffff;
  --article-border: #e9ecef;
  --button-bg: #007bff;
  --button-hover-bg: #0056b3;
  --error-color: #dc3545;
  --success-color: #28a745;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Dark theme variables */
[data-theme="dark"] {
  --bg-color: #1a1a1a;
  --text-color: #e0e0e0;
  --header-bg: #2d2d2d;
  --border-color: #404040;
  --feed-bg: #2d2d2d;
  --feed-hover-bg: #3d3d3d;
  --article-bg: #2d2d2d;
  --article-border: #3d3d3d;
  --button-bg: #0d6efd;
  --button-hover-bg: #0b5ed7;
  --error-color: #ff6b6b;
  --success-color: #4cd964;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  transition: background-color 0.3s, color 0.3s;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  margin-bottom: 30px;
  border-bottom: 1px solid var(--border-color);
}

h1 {
  font-size: 2rem;
  font-weight: 600;
}

.theme-toggle {
  background: var(--button-bg);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s;
}

.theme-toggle:hover {
  background: var(--button-hover-bg);
}

main {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 30px;
}

.feed-section {
  background: var(--feed-bg);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.feed-section h2 {
  margin-bottom: 20px;
  font-size: 1.4rem;
}

.feed-input-container {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

#feed-url {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  background: var(--article-bg);
  color: var(--text-color);
}

#add-feed {
  padding: 12px 20px;
  background: var(--button-bg);
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.3s;
}

#add-feed:hover {
  background: var(--button-hover-bg);
}

.feeds-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feed-item {
  padding: 15px;
  background: var(--article-bg);
  border: 1px solid var(--article-border);
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.feed-item:hover {
  background: var(--feed-hover-bg);
}

.feed-item.active {
  border-color: var(--button-bg);
  background: var(--feed-hover-bg);
}

.feed-item .feed-title {
  font-weight: 500;
  flex: 1;
}

.feed-item .remove-feed {
  background: none;
  border: none;
  color: var(--error-color);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 5px;
  transition: transform 0.2s;
}

.feed-item .remove-feed:hover {
  transform: scale(1.2);
}

.articles-section {
  background: var(--article-bg);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
  overflow-y: auto;
  max-height: 80vh;
}

.articles-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.article {
  padding: 20px;
  border: 1px solid var(--article-border);
  border-radius: 8px;
  background: var(--bg-color);
  transition: transform 0.3s;
}

.article:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.article h3 {
  margin-bottom: 10px;
  font-size: 1.3rem;
}

.article .article-meta {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
  font-size: 0.9rem;
  color: #666;
}

.article .article-description {
  margin-bottom: 15px;
  line-height: 1.6;
}

.article .article-link {
  display: inline-block;
  color: var(--button-bg);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s;
  margin-top: 10px;
  padding: 8px 16px;
  background: var(--button-bg);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
}

.article .article-link:hover {
  color: white;
  background: var(--button-hover-bg);
}

.article .article-link:hover {
  color: var(--button-hover-bg);
}

.placeholder-text {
  text-align: center;
  color: #666;
  font-style: italic;
  padding: 40px 20px;
}

.error-message {
  background: var(--error-color);
  color: white;
  padding: 15px;
  border-radius: 5px;
  margin: 10px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.loading {
  text-align: center;
  padding: 20px;
  color: #666;
}

/* Modal styles */
.article-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-content {
  background: var(--bg-color);
  border-radius: 10px;
  width: 100%;
  max-width: 1200px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.modal-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--header-bg);
}

.modal-header h2 {
  font-size: 1.4rem;
  margin: 0;
  color: var(--text-color);
}

.close-modal {
  background: none;
  border: none;
  font-size: 2rem;
  cursor: pointer;
  color: var(--text-color);
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.3s;
}

.close-modal:hover {
  background: var(--border-color);
}

.modal-body {
  flex: 1;
  overflow: hidden;
  padding: 0;
  position: relative;
}

.modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.iframe-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.8);
  padding: 20px;
  border-radius: 5px;
  z-index: 10;
}

.modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
}

/* Search functionality styles */
.search-container {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

#search-input {
  flex: 1;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  background: var(--article-bg);
  color: var(--text-color);
}

#search-button {
  padding: 12px 20px;
  background: var(--button-bg);
  color: white;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.3s;
}

#search-button:hover {
  background: var(--button-hover-bg);
}

.search-results {
  margin-top: 15px;
}

.search-result-item {
  padding: 12px;
  background: var(--article-bg);
  border: 1px solid var(--article-border);
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-result-item:hover {
  background: var(--feed-hover-bg);
}

.search-result-title {
  font-weight: 500;
  flex: 1;
}

.search-result-url {
  font-size: 0.8rem;
  color: #666;
  margin-top: 5px;
  word-break: break-all;
}

/* Responsive design */
@media (max-width: 768px) {
  .container {
    padding: 10px;
  }
  
  main {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  header {
    flex-direction: column;
    gap: 15px;
    text-align: center;
  }
  
  .feed-input-container {
    flex-direction: column;
  }
  
  .feed-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  
  .feed-item .remove-feed {
    align-self: flex-end;
  }
  
  .modal-content {
    height: 95vh;
    width: 95%;
  }
}

@media (max-width: 480px) {
  .article {
    padding: 15px;
  }
  
  .article h3 {
    font-size: 1.1rem;
  }
  
  .modal-header h2 {
    font-size: 1.2rem;
  }
}