/* =========================================
   RSS Reader — Design System
   ========================================= */

:root {
  --bg:        #07080f;
  --surface-0: #0a0c14;
  --surface-1: #0e1020;
  --surface-2: #141728;
  --surface-3: #1a1e30;

  --border:       rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);

  --a:      #7b68ee;
  --a2:     #a78bfa;
  --a-soft: rgba(123, 104, 238, 0.14);
  --a-glow: rgba(123, 104, 238, 0.28);
  --grad:   linear-gradient(135deg, #7b68ee 0%, #a78bfa 100%);

  --t1: #e2e6f2;
  --t2: #8892aa;
  --t3: #444c64;

  --red:      #f87171;
  --red-soft: rgba(248, 113, 113, 0.13);
  --green:    #4ade80;
  --green-soft: rgba(74, 222, 128, 0.12);

  --r:    14px;
  --r-sm: 9px;
  --r-xs: 5px;

  --dur: 0.18s;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--t1);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.09); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.16); }

/* ── Layout ── */
.layout { display: flex; height: 100dvh; }

/* =========================================
   Sidebar
   ========================================= */

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface-0);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 10px 24px;
  position: relative;
}

/* Accent line on sidebar right edge */
.sidebar::after {
  content: '';
  position: absolute;
  top: 0; right: -1px; bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent 10%, rgba(123,104,238,0.25) 50%, transparent 90%);
  pointer-events: none;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 22px;
}

.logo-icon {
  width: 30px;
  height: 30px;
  background: var(--grad);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px var(--a-glow);
  flex-shrink: 0;
}

.logo-icon svg { width: 15px; height: 15px; color: #fff; }

.logo-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--t1);
}

.nav-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  padding: 0 10px;
  margin-bottom: 6px;
}

nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--t2);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  width: 100%;
  text-align: left;
}

.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }

.nav-item:hover { background: var(--surface-2); color: var(--t1); }

.nav-item.active {
  background: var(--a-soft);
  color: var(--a2);
  font-weight: 600;
}

/* =========================================
   Main
   ========================================= */

.main { flex: 1; overflow-y: auto; background: var(--bg); }

.page { display: none; }
.page.active { display: block; }

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 36px 40px 0;
  gap: 16px;
}

.page-header-left h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--t1);
  line-height: 1.2;
}

.subtitle { color: var(--t2); margin-top: 4px; font-size: 13px; }

/* ── Stats ── */
.stats-row { display: flex; gap: 14px; padding: 24px 40px 0; }

.stat-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--dur) var(--ease);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--grad);
  opacity: 0.55;
}

.stat-card:hover { border-color: var(--border-strong); }

.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--a-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 16px; height: 16px; color: var(--a); }

.stat-body { display: flex; flex-direction: column; gap: 2px; }

.stat-num {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  background: var(--grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 11px;
  color: var(--t2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ── Toolbar / Search ── */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 18px 40px 0; }

.search-wrap { position: relative; max-width: 300px; width: 100%; }

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--t3);
  pointer-events: none;
  transition: color var(--dur) var(--ease);
}

.search-wrap:focus-within .search-icon { color: var(--a); }

.search-input {
  width: 100%;
  padding: 8px 14px 8px 34px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--t1);
  font-size: 13px;
  outline: none;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.search-input::placeholder { color: var(--t3); }

.search-input:focus {
  border-color: var(--a);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px var(--a-soft);
}

/* =========================================
   Feeds Table
   ========================================= */

.feeds-table {
  margin: 18px 40px 40px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.feeds-table-header {
  display: grid;
  grid-template-columns: 2fr 3fr 130px 56px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  background: var(--surface-0);
}

.feed-row {
  display: grid;
  grid-template-columns: 2fr 3fr 130px 56px;
  align-items: center;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  transition: background var(--dur) var(--ease);
}

.feed-row:last-child { border-bottom: none; }
.feed-row:hover { background: var(--surface-2); }

.feed-cell-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.feed-favicon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--a-soft);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.feed-favicon img { width: 16px; height: 16px; object-fit: contain; }
.feed-favicon svg { width: 13px; height: 13px; color: var(--a); }

.feed-name-text {
  font-weight: 500;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--t1);
}

.feed-cell-url {
  font-size: 12px;
  color: var(--t2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 20px;
}

.feed-cell-date { font-size: 12px; color: var(--t2); }

.feed-cell-actions { display: flex; justify-content: flex-end; }

/* =========================================
   Buttons
   ========================================= */

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  background: var(--grad);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
  white-space: nowrap;
  letter-spacing: -0.01em;
  box-shadow: 0 2px 10px var(--a-glow);
}

.btn-primary:hover {
  opacity: 0.88;
  box-shadow: 0 4px 18px var(--a-glow);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); opacity: 1; }

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary svg { width: 14px; height: 14px; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  background: transparent;
  color: var(--t2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  white-space: nowrap;
}

.btn-secondary:hover {
  background: var(--surface-2);
  color: var(--t1);
  border-color: var(--border-strong);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}

.btn-danger:hover {
  background: #ef4444;
  box-shadow: 0 4px 14px rgba(248,113,113,0.3);
  transform: translateY(-1px);
}

.btn-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--t2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--dur) var(--ease);
}

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

.btn-icon svg { width: 13px; height: 13px; }

/* =========================================
   Empty & Loading
   ========================================= */

.empty-feeds {
  padding: 64px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.empty-icon svg { width: 24px; height: 24px; color: var(--t3); }

.empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--t1);
}

.empty-sub { font-size: 13px; color: var(--t2); }

.loading { padding: 40px; text-align: center; color: var(--t2); font-size: 13px; }

/* Skeleton shimmer */
@keyframes shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}

.sk {
  background: linear-gradient(90deg, var(--surface-1) 0%, var(--surface-3) 45%, var(--surface-1) 90%);
  background-size: 1200px 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}

.skeleton-row {
  display: grid;
  grid-template-columns: 2fr 3fr 130px 56px;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.skeleton-row:last-child { border-bottom: none; }

.sk-name { display: flex; align-items: center; gap: 10px; }
.sk-avatar { width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0; }
.sk-line { height: 13px; border-radius: 4px; }

/* =========================================
   Modal
   ========================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.14s ease;
}

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { transform: translateY(14px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1);       opacity: 1; }
}

.modal {
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  padding: 28px;
  width: 480px;
  max-width: 92vw;
  animation: slideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 24px 64px rgba(0,0,0,0.65), 0 0 0 1px rgba(255,255,255,0.04);
}

.modal-sm { width: 380px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }

.modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--surface-2);
  color: var(--t2);
  cursor: pointer;
  border-radius: var(--r-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--dur) var(--ease);
}

.modal-close:hover { background: var(--surface-3); color: var(--t1); }
.modal-close svg { width: 15px; height: 15px; }

.modal-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin-bottom: 22px;
}

.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--t2);
  margin-bottom: 8px;
  letter-spacing: 0.01em;
}

.required { color: var(--a); margin-left: 2px; }
.optional { color: var(--t3); font-weight: 400; font-size: 12px; }

.form-group input {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--t1);
  font-size: 13.5px;
  outline: none;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.form-group input:focus {
  border-color: var(--a);
  box-shadow: 0 0 0 3px var(--a-soft);
}

.form-group input::placeholder { color: var(--t3); }

.form-error {
  color: var(--red);
  font-size: 12.5px;
  margin-bottom: 16px;
  min-height: 18px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.confirm-text {
  color: var(--t2);
  font-size: 13.5px;
  margin-bottom: 24px;
  line-height: 1.6;
}

/* =========================================
   Reports
   ========================================= */

.reports-layout {
  display: grid;
  grid-template-columns: 244px 1fr;
  gap: 16px;
  height: calc(100vh - 148px);
  padding: 20px 40px 32px;
}

.reports-list {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow-y: auto;
  padding: 8px;
}

.reports-list-label {
  padding: 6px 10px 10px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.report-item {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--t2);
  font-size: 13px;
  font-weight: 500;
}

.report-item:hover { background: var(--surface-2); color: var(--t1); }
.report-item.active { background: var(--a-soft); color: var(--a2); }
.report-item svg { width: 14px; height: 14px; flex-shrink: 0; }

.report-preview {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow-y: auto;
  padding: 40px 44px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--t3);
}

.empty-state p { font-size: 13.5px; color: var(--t2); }

/* =========================================
   Markdown
   ========================================= */

.md-content {
  line-height: 1.8;
  color: var(--t1);
  font-size: 14px;
  max-width: 720px;
}

.md-content h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.md-content h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 32px 0 12px;
  color: var(--a2);
  display: flex;
  align-items: center;
  gap: 9px;
}

.md-content h2::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 17px;
  background: var(--grad);
  border-radius: 2px;
  flex-shrink: 0;
}

.md-content h3 {
  font-size: 14.5px;
  font-weight: 600;
  margin: 20px 0 8px;
  color: var(--t2);
}

.md-content p { margin-bottom: 12px; }

.md-content ul, .md-content ol { padding-left: 22px; margin-bottom: 12px; }
.md-content li { margin-bottom: 6px; }

.md-content a {
  color: var(--a2);
  text-decoration: none;
  border-bottom: 1px solid rgba(167,139,250,0.3);
  transition: border-color var(--dur) var(--ease);
}

.md-content a:hover { border-color: var(--a2); }

.md-content strong { color: var(--t1); font-weight: 700; }

.md-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

.md-content code {
  background: var(--surface-2);
  padding: 2px 7px;
  border-radius: 4px;
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 12.5px;
  color: var(--a2);
  border: 1px solid var(--border);
}

/* =========================================
   Toast
   ========================================= */

.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 9px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  max-width: 320px;
}

@keyframes toastIn {
  from { transform: translateY(10px) translateX(6px); opacity: 0; }
  to   { transform: translateY(0) translateX(0); opacity: 1; }
}

.toast-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.toast.success .toast-dot { background: var(--green); }
.toast.success { border-color: rgba(74,222,128,0.22); }

.toast.error .toast-dot { background: var(--red); }
.toast.error { border-color: rgba(248,113,113,0.22); }

/* =========================================
   Spinner
   ========================================= */

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

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid rgba(255,255,255,0.22);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.5s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
