/* ================================================================
   SPDIGEST — Editor Interface Styles
   Control Panel: Channel management, Archive, Weekly Top-10
   ================================================================ */

/* ── Layout ─────────────────────────────────────────────────── */
.editor-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 60px 1fr;
  min-height: 100vh;
}

/* ── Top Bar ─────────────────────────────────────────────────── */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
}

.topbar-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-dot 2s infinite;
}
.status-dot.idle { background: var(--text-muted); box-shadow: none; animation: none; }
.status-dot.running { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

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

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  border: 1px solid transparent;
}

.nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  border-color: var(--border-accent);
}

.nav-item .nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #000;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
}

.sidebar-bottom {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

/* ── Main Content Area ────────────────────────────────────────── */
.main-content {
  padding: 28px 32px;
  overflow-y: auto;
  background: var(--bg-base);
}

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

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

.page-title { display: flex; flex-direction: column; gap: 4px; }
.page-title h1 { margin: 0; font-size: 1.6rem; }
.page-title p  { margin: 0; font-size: 0.875rem; color: var(--text-secondary); }

/* ── Dashboard Stats ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

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

.stat-card:hover { border-color: var(--accent-glow2); transform: translateY(-2px); }
.stat-card:hover::before { opacity: 1; }

.stat-icon {
  font-size: 1.5rem;
  margin-bottom: 12px;
  display: block;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Channel Cards ────────────────────────────────────────────── */
.channels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.channel-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: var(--transition);
}

.channel-card:hover {
  border-color: var(--glass-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.channel-card.paused { opacity: 0.6; }

.channel-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.channel-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #000;
  flex-shrink: 0;
}

.channel-info { flex: 1; min-width: 0; }
.channel-name { font-weight: 600; font-size: 0.95rem; }
.channel-handle { font-size: 0.8rem; color: var(--text-muted); }

.channel-stats {
  display: flex;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.channel-stat { display: flex; align-items: center; gap: 4px; }
.channel-actions { display: flex; gap: 8px; margin-top: auto; }

/* ── Archive ──────────────────────────────────────────────────── */
.archive-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}

/* Calendar */
.calendar-widget {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: sticky;
  top: 16px;
}

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

.cal-title { font-family: var(--font-display); font-size: 1rem; font-weight: 600; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.cal-day-name {
  text-align: center;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 0;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.cal-day:hover { background: var(--bg-elevated); }

.cal-day.has-posts {
  background: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}

.cal-day.selected {
  background: var(--accent);
  color: #000;
  font-weight: 700;
}

.cal-day.today { box-shadow: inset 0 0 0 1px var(--cyan); }
.cal-day.empty { color: var(--text-muted); cursor: default; }

/* Archive Post Cards */
.archive-posts { display: flex; flex-direction: column; gap: 14px; }

.archive-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 16px;
  align-items: start;
  transition: var(--transition);
  cursor: pointer;
}

.archive-card:hover {
  border-color: var(--accent-glow2);
  background: var(--bg-elevated);
}

.archive-thumb {
  width: 100px;
  height: 70px;
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.archive-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius); }

.archive-meta { display: flex; flex-direction: column; gap: 6px; }
.archive-headline { font-weight: 600; font-size: 0.95rem; line-height: 1.3; }
.archive-source {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.8rem; color: var(--text-muted);
}
.archive-score {
  display: flex; align-items: center; gap: 12px;
  font-size: 0.8rem; color: var(--text-secondary);
}
.score-pill {
  background: var(--accent-glow);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 700;
  font-size: 0.8rem;
}

.dup-flag {
  background: var(--red-glow);
  color: var(--red);
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
}

.archive-actions { display: flex; flex-direction: column; gap: 6px; }

/* ── Weekly Top-10 ────────────────────────────────────────────── */
.weekly-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.weekly-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 44px 90px 1fr auto;
  gap: 16px;
  align-items: center;
  transition: var(--transition);
  cursor: grab;
}

.weekly-item:hover { border-color: var(--glass-border); background: var(--bg-elevated); }
.weekly-item.dragging { opacity: 0.5; cursor: grabbing; }
.weekly-item.broadcast {
  border-color: var(--green);
  background: linear-gradient(135deg, var(--bg-surface), rgba(16,185,129,0.04));
}

.weekly-rank {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-muted);
  text-align: center;
}
.weekly-rank.top3 { color: var(--accent); }

.weekly-thumb {
  width: 90px; height: 58px;
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--bg-elevated);
}
.weekly-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius); }

.weekly-info { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.weekly-headline { font-weight: 600; font-size: 0.9rem; line-height: 1.3; }
.weekly-channel { font-size: 0.78rem; color: var(--text-muted); }
.weekly-score {
  font-size: 0.8rem;
  color: var(--accent);
  font-weight: 600;
}

.weekly-actions { display: flex; gap: 6px; }

/* ── Finalize Banner ─────────────────────────────────────────── */
.finalize-banner {
  background: linear-gradient(135deg, rgba(245,158,11,0.1), rgba(245,158,11,0.03));
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.finalize-info h3 { font-size: 1.1rem; margin-bottom: 4px; }
.finalize-info p  { font-size: 0.875rem; color: var(--text-secondary); }

/* ── Post Editor Modal ────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 1.1rem; font-weight: 600; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--bg-elevated); color: var(--text-primary); }

.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Image Picker */
.image-picker {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.image-option {
  width: 100px;
  height: 70px;
  border-radius: var(--radius);
  object-fit: cover;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
  flex-shrink: 0;
  background: var(--bg-elevated);
}

.image-option.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow2);
}

/* ── Filters Bar ─────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-select {
  width: auto;
  min-width: 160px;
}

/* ── Empty State ─────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 12px;
  color: var(--text-muted);
}

.empty-icon { font-size: 3rem; }
.empty-state p { font-size: 0.9rem; }

/* ── Scraper Log Panel ────────────────────────────────────────── */
.scrape-log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.log-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  font-size: 0.8rem;
}

.log-status { font-weight: 600; }
.log-status.done  { color: var(--green); }
.log-status.error { color: var(--red); }
.log-status.running { color: var(--accent); }
