/* GoRSS - Unified Responsive Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #333333;
  --text-muted: #888888;
  --border: #e0e0e0;
  --unread: #1a73e8;
  --sidebar-width: 280px;
  --shadow: rgba(0,0,0,0.08);
  --shadow-hover: rgba(0,0,0,0.12);
  --overlay: rgba(0,0,0,0.5);
  --header-btn-hover: rgba(255,255,255,0.2);
  --cat-hover: rgba(0,0,0,0.04);
  --mark-read-hover-bg: rgba(0,0,0,0.06);
}

/* Dark theme - soft/comfortable for night reading */
[data-theme="dark"] {
  --primary: #7bafe8;
  --primary-dark: #6a9fd8;
  --bg: #2b2d31;
  --card-bg: #36393f;
  --text: #dcddde;
  --text-muted: #96989d;
  --border: #44474d;
  --unread: #7bafe8;
  --shadow: rgba(0,0,0,0.2);
  --shadow-hover: rgba(0,0,0,0.35);
  --overlay: rgba(0,0,0,0.6);
  --header-btn-hover: rgba(255,255,255,0.12);
  --cat-hover: rgba(255,255,255,0.04);
  --mark-read-hover-bg: rgba(255,255,255,0.06);
}

/* Prevent flash of wrong theme on load - respect OS preference as fallback */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #7bafe8;
    --primary-dark: #6a9fd8;
    --bg: #2b2d31;
    --card-bg: #36393f;
    --text: #dcddde;
    --text-muted: #96989d;
    --border: #44474d;
    --unread: #7bafe8;
    --shadow: rgba(0,0,0,0.2);
    --shadow-hover: rgba(0,0,0,0.35);
    --overlay: rgba(0,0,0,0.6);
    --header-btn-hover: rgba(255,255,255,0.12);
    --cat-hover: rgba(255,255,255,0.04);
    --mark-read-hover-bg: rgba(255,255,255,0.06);
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* App Layout */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

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

.sidebar-header {
  background: var(--primary);
  color: white;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1;
}

.sidebar-logo {
  font-size: 22px;
  font-weight: 600;
  color: white;
  text-decoration: none;
}

.sidebar-logo:hover {
  text-decoration: underline;
}

.sidebar-version {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.sidebar-version:hover {
  color: white;
  text-decoration: underline;
}

svg.github-icon {
  width: 12px !important;
  height: 12px !important;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.header-actions {
  display: flex;
  gap: 4px;
}

.header-btn {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  padding: 8px;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s;
}

.header-btn:hover, .header-btn:active {
  background: var(--header-btn-hover);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.nav-section {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.nav-section:last-child {
  border-bottom: none;
}

.nav-section-title {
  padding: 8px 16px 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.2s;
  gap: 12px;
}

.nav-item:hover, .nav-item:active {
  background: var(--bg);
}

.nav-item.active {
  background: rgba(26, 115, 232, 0.1);
  color: var(--primary);
}

.nav-item .icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.nav-item .label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item .count {
  background: var(--bg);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

/* Category grouping */
.feed-category {
  margin-bottom: 2px;
}

.category-header {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  user-select: none;
}

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

.category-toggle {
  margin-right: 6px;
  font-size: 11px;
  width: 12px;
  text-align: center;
}

.cat-header {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 4px;
}

.cat-header:hover {
  color: var(--primary);
}

.cat-header.active {
  color: var(--primary);
  font-weight: 700;
}

.category-header .count {
  background: var(--bg);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
}

.cat-mark-read {
  margin-left: 4px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.5;
  padding: 2px 4px;
  border-radius: 4px;
}

/* Desktop: hide by default, show on hover */
@media (hover: hover) {
  .cat-mark-read {
    opacity: 0;
    transition: opacity 0.15s;
  }
  .category-header:hover .cat-mark-read {
    opacity: 0.6;
  }
  .cat-mark-read:hover {
    opacity: 1 !important;
    color: var(--primary);
    background: var(--mark-read-hover-bg);
  }
}

.category-feeds .nav-item {
  padding-left: 36px;
  font-size: 13px;
}

/* Drag and drop */
.dragging {
  opacity: 0.4;
}

.drag-over {
  border-top: 2px solid var(--primary);
}

[draggable="true"] {
  cursor: grab;
}

[draggable="true"]:active {
  cursor: grabbing;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: var(--bg);
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.btn-icon:hover {
  background: var(--border);
}

/* Main Content */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.main-header {
  background: var(--primary);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.menu-btn {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
}

.main-title {
  font-size: 20px;
  font-weight: 500;
  flex: 1;
}

.main-title #current-view.editable {
  cursor: pointer;
  border-bottom: 1px dashed rgba(255,255,255,0.4);
  padding-bottom: 2px;
}

.main-title #current-view.editable:hover {
  border-bottom-color: rgba(255,255,255,0.8);
}

/* Edit Feed Modal */
.modal-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-content input[type="text"] {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 15px;
  margin-bottom: 16px;
  background: var(--bg);
  color: var(--text);
}

.modal-content input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.2);
}

.modal-error {
  color: #e53935;
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 18px;
}

.header-sort,
.header-mark-read {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background 0.15s;
  flex-shrink: 0;
}

.header-sort:hover,
.header-mark-read:hover {
  background: rgba(255,255,255,0.35);
}

.articles-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}


/* Article Cards */
.article {
  background: var(--card-bg);
  border-radius: 8px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.article:hover {
  box-shadow: 0 2px 8px var(--shadow-hover);
}

.article.unread {
  border-left: 3px solid var(--unread);
}

.article.selected {
  box-shadow: 0 0 0 2px var(--primary);
}

.article-header {
  padding: 12px 16px;
  cursor: pointer;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.article-feed {
  background: var(--primary);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.article-time {
  color: var(--text-muted);
  font-size: 12px;
}

.article-author {
  color: var(--text-muted);
  font-size: 12px;
}

.article-title {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text);
  text-decoration: none;
  display: block;
}

.article.unread .article-title {
  color: var(--unread);
}

.article-actions {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.article-btn {
  background: var(--card-bg);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: inherit;
}

.article-btn:hover {
  background: var(--border);
}

.article-content {
  padding: 0 16px 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  display: none;
  overflow-x: hidden;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.article.expanded .article-content {
  display: block;
}

.article-content img {
  max-width: 100% !important;
  height: auto !important;
  width: auto;
}

.article-content * {
  max-width: 100% !important;
  box-sizing: border-box;
}

.article-content table {
  table-layout: fixed;
  width: 100% !important;
}

.article-content pre,
.article-content code {
  white-space: pre-wrap;
  word-break: break-all;
}

.article-content a {
  color: var(--primary);
}

/* Star */
.article-star {
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
}

.article-star.starred {
  color: #f5a623;
}

/* Drawer overlay (mobile) */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--overlay);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* FAB */
.fab {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--shadow-hover);
  z-index: 50;
}

/* Modals */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--overlay);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 24px;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h2 {
  margin-bottom: 16px;
  font-size: 20px;
}

.modal-content input[type="url"],
.modal-content input[type="file"] {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 15px;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-cancel {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

/* Confirm modal */
.confirm-modal {
  text-align: center;
  max-width: 340px;
  animation: confirmSlideIn 0.2s ease-out;
}

@keyframes confirmSlideIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.confirm-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  margin: 0 auto 12px;
}

.confirm-message {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.4;
}

.confirm-modal .modal-actions {
  justify-content: center;
  gap: 12px;
}

.confirm-modal .btn-cancel,
.confirm-modal .btn-primary {
  min-width: 100px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.15s;
}

.confirm-modal .btn-cancel:hover {
  background: var(--border);
}

.confirm-modal .btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Shortcuts */
.shortcuts {
  display: grid;
  gap: 8px;
}

.shortcut {
  display: flex;
  gap: 8px;
  align-items: center;
}

kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 13px;
}

/* Loading */
/* New articles badge in header */
.new-badge {
  font-size: 14px;
  font-weight: 400;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  white-space: nowrap;
  animation: badge-pulse 0.3s ease;
}

.new-badge:hover {
  color: #fff;
  text-decoration: underline;
}

@keyframes badge-pulse {
  0% { opacity: 0; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1); }
}

.loading-more {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 14px;
}

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

/* Theme Toggle */
.theme-toggle {
  background: var(--bg);
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: background 0.2s;
}

.theme-toggle:hover {
  background: var(--border);
}

/* Dark theme specific overrides */
[data-theme="dark"] .sidebar-header {
  background: #3b5998;
}

[data-theme="dark"] .main-header {
  background: #3b5998;
}

[data-theme="dark"] .article-feed {
  background: #4a6aa5;
}

[data-theme="dark"] .fab {
  background: #3b5998;
}

[data-theme="dark"] .header-sort,
[data-theme="dark"] .header-mark-read {
  background: rgba(255,255,255,0.12);
}

[data-theme="dark"] .header-sort:hover,
[data-theme="dark"] .header-mark-read:hover {
  background: rgba(255,255,255,0.22);
}

[data-theme="dark"] .btn-primary {
  background: #4a6aa5;
  color: #f0f0f0;
}

[data-theme="dark"] .btn-primary:hover {
  background: #5a7ab5;
}

[data-theme="dark"] .confirm-icon {
  background: #4a6aa5;
}

[data-theme="dark"] kbd {
  background: #3e4147;
  border-color: #52555c;
  color: #dcddde;
}

[data-theme="dark"] .article-btn {
  background: var(--card-bg);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .article-btn:hover {
  background: var(--border);
}

[data-theme="dark"] .modal-content input[type="url"],
[data-theme="dark"] .modal-content input[type="text"],
[data-theme="dark"] .modal-content input[type="file"] {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

[data-theme="dark"] .nav-item.active {
  background: rgba(123, 175, 232, 0.12);
}

[data-theme="dark"] .confirm-modal .btn-primary:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Smooth theme transition */
body,
.sidebar,
.main,
.article,
.modal-content,
.nav-item,
.btn-icon,
.theme-toggle {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 250;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 2px 0 8px var(--shadow-hover);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-btn {
    display: block;
  }

  .main-header {
    padding: 12px 16px;
  }

  .articles-container {
    padding: 8px;
  }

  .article {
    margin-bottom: 8px;
  }

  .fab {
    display: block;
  }
}

@media (max-width: 480px) {
  .article-header {
    padding: 10px 12px;
  }

  .article-title {
    font-size: 15px;
  }

  .article-content {
    padding: 0 12px 12px;
  }
}
