/* Personal News — base stylesheet */

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-sidebar: #13151f;
  --border: #2a2d3e;
  --text: #e2e4ed;
  --text-muted: #7b7f9e;
  --text-heading: #ffffff;
  --accent: #5b8dee;
  --accent-hover: #7aa3f5;
  --danger: #e05252;
  --success: #4caf82;
  --warning: #e0a752;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;
  --sidebar-width: 200px;
  --radius: 8px;
}

html.light {
  --bg: #f5f6fa;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --border: #dde1ee;
  --text: #2c2f3f;
  --text-muted: #7b7f9e;
  --text-heading: #111827;
  --accent: #3b6fd4;
  --accent-hover: #2d5ab8;
  --danger: #c0392b;
  --success: #27774f;
  --warning: #b8760a;
}

/* Theme toggle button */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
  margin-top: 0.75rem;
  width: 100%;
  text-align: left;
  transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }

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

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  padding: 1.5rem 0;
}

.sidebar-header {
  padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: -0.02em;
}

.nav-links {
  list-style: none;
  padding: 1rem 0;
  flex: 1;
}

.nav-links li a {
  display: block;
  padding: 0.55rem 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s, background 0.15s;
  border-radius: 0;
}

.nav-links li a:hover,
.nav-links li a.active {
  color: var(--text);
  background: rgba(91, 141, 238, 0.1);
  border-left: 3px solid var(--accent);
  padding-left: calc(1.25rem - 3px);
}

.sidebar-footer {
  padding: 1rem 1.25rem 0;
  border-top: 1px solid var(--border);
}

/* ── Main content ──────────────────────────────────────────────────────────── */
.content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1100px;
}

.table-scroll { overflow-x: auto; }

/* ── Page header ───────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-heading);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.count {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 1rem;
}

/* ── Feed card list (Feedly-style) ─────────────────────────────────────────── */
.feed-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.feed-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.6rem;
  transition: border-color 0.12s;
}

.feed-card:hover { border-color: var(--accent); }
.feed-card.is-read .feed-title a { color: var(--text-muted); }

.feed-card-body {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.feed-card-text { flex: 1; min-width: 0; }

.feed-card-thumb {
  flex-shrink: 0;
  width: 100px;
  height: 70px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--border);
}

.feed-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.feed-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.feed-source { font-weight: 600; color: var(--accent); }

.feed-category {
  background: rgba(91, 141, 238, 0.12);
  color: var(--accent);
  padding: 0.1em 0.45em;
  border-radius: 4px;
  font-size: 0.72rem;
}

.feed-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
  line-height: 1.4;
}

.feed-title a {
  color: var(--text-heading);
  text-decoration: none;
}

.feed-title a:hover { color: var(--accent); }

.feed-summary {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.feed-card-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

/* keep old .source / .category classes working on other pages */
.source { font-weight: 600; color: var(--accent); }
.category {
  background: rgba(91, 141, 238, 0.15);
  color: var(--accent);
  padding: 0.1em 0.5em;
  border-radius: 4px;
  font-size: 0.75rem;
}

/* ── Article detail ────────────────────────────────────────────────────────── */
.article-detail { max-width: 720px; }

.breadcrumb {
  margin-bottom: 1rem;
  font-size: 0.875rem;
}

.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }

.article-detail h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-heading);
  margin: 0.75rem 0 1rem;
  line-height: 1.3;
}

.article-summary-box {
  background: rgba(91, 141, 238, 0.07);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--text);
}

.article-body {
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text);
}

.article-body.placeholder {
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}

.article-actions-bar {
  display: flex;
  gap: 0.75rem;
  margin: 2rem 0 1rem;
  flex-wrap: wrap;
}

.article-debug {
  margin-top: 2rem;
  font-size: 0.8rem;
}

.article-debug summary { cursor: pointer; color: var(--text-muted); }
.article-debug dl { margin-top: 0.75rem; display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; }
.article-debug dt { color: var(--text-muted); font-weight: 600; }
.article-debug dd { color: var(--text); word-break: break-all; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-ghost, .btn-danger, .btn-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover, .btn-secondary.active {
  background: rgba(91, 141, 238, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.05); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover { background: rgba(224, 82, 82, 0.1); }

.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0;
  cursor: pointer;
  font-size: 0.875rem;
}
.btn-link:hover { color: var(--text); }

.btn-small { padding: 0.2rem 0.6rem; font-size: 0.78rem; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

input[type="text"],
input[type="url"],
input[type="password"],
input[type="number"],
input[type="file"],
select,
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.45rem 0.75rem;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-row {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.form-actions { margin-top: 1.25rem; display: flex; gap: 0.75rem; }

.required { color: var(--danger); }
.hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.4rem; }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.data-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

.disabled-row { opacity: 0.45; }
.actions-cell { white-space: nowrap; }
.keywords-cell { color: var(--text-muted); font-size: 0.8rem; }
.muted { color: var(--text-muted); }
.error-text { color: var(--danger); }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.875rem;
}
.alert-error { background: rgba(224, 82, 82, 0.1); border: 1px solid var(--danger); color: var(--danger); }
.alert-success { background: rgba(76, 175, 130, 0.1); border: 1px solid var(--success); color: var(--success); }

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state a { color: var(--accent); }
.empty { color: var(--text-muted); font-size: 0.875rem; padding: 1rem 0; }

/* ── Pagination ────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── Expandable add forms ──────────────────────────────────────────────────── */
.add-form {
  margin-top: 1.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.add-form summary {
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--accent);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.add-form[open] summary { margin-bottom: 1rem; }
.inline-form { margin-top: 0.75rem; }
.inline-form .form-group { margin-bottom: 0.75rem; }

/* ── Login page ────────────────────────────────────────────────────────────── */
body.login-page {
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--bg);
  flex-direction: column;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
}

.login-card h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 1.5rem;
  text-align: center;
}

.login-card label {
  display: block;
  margin-bottom: 0.3rem;
}

.login-card input[type="password"] {
  margin-bottom: 1rem;
}

.login-card button[type="submit"] {
  width: 100%;
  padding: 0.6rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.login-card button[type="submit"]:hover { background: var(--accent-hover); }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .sidebar { display: none; }
  .content { margin-left: 0; padding: 1rem; }
}

/* ── Status note ───────────────────────────────────────────────────────────── */
.status-note { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.5rem; }
