/* CSS Variables for Light Mode */
:root {
  --bg-primary: #fafafa;
  --bg-secondary: #fff;
  --text-primary: #212121;
  --text-secondary: #666;
  --text-muted: #999;
  --border-color: #e0e0e0;
  --hover-bg: #f5f5f5;
  --active-bg: #eeeeee;
}

/* Dark Mode Variables */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #888;
    --border-color: #333;
    --hover-bg: #2a2a2a;
    --active-bg: #353535;
  }
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  height: 100vh;
}

embed, img {
    max-width: 100%;
  }

.app {
  display: flex;
  height: 100vh;
}

.app-scrollable {
  overflow-y: auto;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 300px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 10px;
}

.beetle-icon {
  width: 24px;
  height: 24px;
  filter: invert(0);
  transition: filter 0.3s ease;
}

@media (prefers-color-scheme: dark) {
  .beetle-icon {
    filter: invert(1);
  }
}

.sidebar-header h1 {
  font-size: 1.2em;
  margin: 0;
}

.sidebar-header h1 sup {
  font-size: 0.6em;
  color: var(--text-muted);
  font-weight: normal;
  vertical-align: super;
  margin-left: 4px;
}

.sidebar-header p {
  font-size: 0.85em;
  opacity: 0.9;
}

.add-feed-section {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
}

.add-feed-section form {
  display: flex;
  gap: 10px;
}

.add-feed-section input {
  flex: 1;
  padding: 5px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  font-size: 14px;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.add-feed-section button {
  background: var(--text-primary);
  color: var(--bg-secondary);
  border: none;
  padding: 7px 15px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.3s;
}

.add-feed-section button:hover {
  opacity: 0.8;
}

.feeds-list-sidebar {
  flex: 1;
  overflow-y: auto;
}

.category-header {
  padding: 8px 12px;
  font-size: 0.75em;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.category-header:hover {
  background: var(--hover-bg);
}

.category-name {
  flex: 1;
}

.category-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.rename-category-btn {
  background: transparent;
  padding: 4px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.rename-category-btn img {
  width: 12px;
  height: 12px;
  opacity: 0.5;
  transition: opacity 0.2s;
  filter: invert(0);
}

@media (prefers-color-scheme: dark) {
  .rename-category-btn img {
    filter: invert(1);
  }
}

.rename-category-btn:hover img {
  opacity: 0.8;
}

.category-toggle {
  font-size: 0.8em;
  transition: transform 0.2s;
  cursor: pointer;
}

.category-content {
  display: block;
}

.category-content .feed-item-title {
  padding-left: 10px;
}

.feed-item {
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.2s;
  border-left: 2px solid transparent;
  border-bottom: 1px solid var(--border-color);
}

.feed-item:hover {
  background: var(--hover-bg);
}

.feed-item.active {
  background: var(--active-bg);
  border-left-color: var(--text-primary);
}

.feed-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.feed-item-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.feed-item-title {
  font-weight: 600;
  font-size: 0.85em;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-item-url {
  font-size: 0.7em;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-item-meta {
  font-size: 0.65em;
  color: var(--text-muted);
}

.unread-badge {
  padding: 0px 6px;
  border-radius: 5px;
  font-size: 0.7em;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.edit-feed-btn,
.delete-feed-btn {
  background: transparent;
  padding: 4px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.edit-feed-btn img,
.delete-feed-btn img {
  width: 12px;
  height: 12px;
  opacity: 0.5;
  transition: opacity 0.2s;
  filter: invert(0);
}

@media (prefers-color-scheme: dark) {
  .edit-feed-btn img,
  .delete-feed-btn img {
    filter: invert(1);
  }
}

.edit-feed-btn:hover img {
  opacity: 0.8;
}

.delete-feed-btn:hover img {
  opacity: 0.9;
}

.empty-feeds {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.9em;
}

/* Main Content - Three Column Layout */
.main-content {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* Middle Column: Articles List */
.articles-column {
  flex: 0 0 30%;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  background: var(--bg-primary);
  overflow: hidden;
  height: 100vh;
}

.articles-header {
  padding: 10px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.articles-header h2 {
  font-size: 1.2em;
  color: var(--text-primary);
}

.articles-header .empty-state {
  color: var(--text-muted);
  font-weight: normal;
}

.articles-list {
  flex: 1;
  overflow-y: auto;
}

/* Right Column: Article Reader */
.reader-column {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: 100vh;
}

.reader-header {
  padding: 0 0 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
}

.reader-content {
  padding: 20px 0 40px;
}

.article-item {
    background: var(--bg-secondary);
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
  }

.article-item.unread {
  border-left-color: var(--text-primary);
  background: var(--hover-bg);
}

.article-title {
  font-size: 1em;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  text-decoration: none;
  display: block;
}

.article-title:hover {
  opacity: 0.8;
}

.article-summary {
  color: var(--text-secondary);
  font-size: 0.85em;
  margin-bottom: 6px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.article-meta {
  display: flex;
  align-items: center;
  font-size: 0.8em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.article-actions {
  display: flex;
  gap: 10px;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.85em;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

.btn-read {
  background: var(--text-secondary);
  color: var(--bg-secondary);
}

.btn-read:hover {
  opacity: 0.8;
}

.btn-unread {
  background: var(--text-primary);
  color: var(--bg-secondary);
}

.btn-unread:hover {
  opacity: 0.8;
}

.error {
  background: var(--hover-bg);
  color: var(--text-primary);
  padding: 15px;
  border-radius: 5px;
  margin: 20px;
  border: 1px solid var(--border-color);
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.hidden {
  display: none;
}

/* Article Reader Styles */
#articleReader {
  margin: 0 auto;
  padding: 0 150px;
}

#articleReader h1,
#articleReader h2,
#articleReader h3,
#articleReader h4,
#articleReader h5,
#articleReader h6 {
  margin-top: 1.5em;
  margin-bottom: 0.75em;
  color: var(--text-primary);
  font-weight: 600;
}

#articleReader p {
  margin-bottom: 1em;
  line-height: 1.8;
  color: var(--text-primary);
}

#articleReader img {
  max-width: 100%;
  height: auto;
  margin: 1.5em 0;
  border-radius: 4px;
}

#articleReader a {
  color: var(--text-primary);
  text-decoration: underline;
}

#articleReader code {
  background: var(--hover-bg);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.9em;
}

#articleReader pre {
  background: var(--hover-bg);
  padding: 15px;
  border-radius: 5px;
  overflow-x: auto;
  margin: 1em 0;
}

#articleReader blockquote {
  border-left: 3px solid var(--border-color);
  padding-left: 20px;
  margin: 1.5em 0;
  color: var(--text-secondary);
  font-style: italic;
}

#articleReader ul,
#articleReader ol {
  margin: 1em 0;
  padding-left: 2em;
}

#articleReader li {
  margin-bottom: 0.5em;
  line-height: 1.6;
}

/* Custom Scrollbar Styles */
/* Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 5px;
  border: 2px solid var(--bg-secondary);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) var(--bg-secondary);
}

/* Desktop: Back buttons should be hidden by default */
.back-button {
  display: none;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
  .app {
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    transition: transform 0.3s ease;
  }

  .sidebar.hidden-mobile {
    transform: translateX(-100%);
  }

  .main-content {
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: relative;
  }

  .articles-column {
    width: 100%;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 9;
    transition: transform 0.3s ease;
    border-right: none;
  }

  .articles-column.hidden-mobile {
    transform: translateX(-100%);
  }

  .articles-header {
    padding: 10px 15px;
  }

  .reader-column {
    width: 100%;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 8;
    transition: transform 0.3s ease;
  }

  .reader-column.hidden-mobile {
    transform: translateX(-100%);
  }

  .reader-column:not(.hidden) {
    display: block !important;
  }

  /* Remove padding from reader container, add to content instead */
  #articleReader {
    padding: 0;
  }

  .reader-header {
    padding: 0 20px 20px;
  }

  .reader-content {
    padding: 40px 20px 80px;
  }

  /* Back button styles on mobile - shown when display is set to block via JS */
  .back-button {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    margin: 10px;
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    gap: 8px;
    color: var(--text-primary);
    transition: background 0.2s;
  }

  .back-button:hover {
    background: var(--active-bg);
  }

  .back-button:before {
    content: '←';
    font-size: 1.2rem;
    margin-right: 5px;
  }
}

