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

:root {
  --bg: #0a0a0b;
  --bg-elevated: #141416;
  --bg-card: #1a1a1d;
  --bg-hover: #222226;
  --border: #2a2a2e;
  --text: #e8e8ea;
  --text-dim: #888892;
  --text-muted: #5a5a62;
  --gold: #c9a96e;
  --gold-dim: #9a7e4e;
  --gold-bright: #e0c485;
  --red: #e0533d;
  --green: #4ec9a8;
  --blue: #5b9bd5;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --sidebar-w: 240px;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Helvetica Neue', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-bright); }

/* ===== Login Page ===== */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at center, #161620 0%, #0a0a0b 70%);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
  box-shadow: var(--shadow);
}

.login-logo {
  margin-bottom: 20px;
  opacity: 0.9;
}

.login-card h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--gold);
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 36px;
}

#login-form .input-group { margin-bottom: 16px; }

#login-form input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.2s;
}

#login-form input:focus {
  outline: none;
  border-color: var(--gold-dim);
}

#login-form input::placeholder { color: var(--text-muted); }

.login-error {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
  min-height: 20px;
}

.login-foot {
  text-align: center;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-muted);
}
.login-foot a {
  color: var(--gold);
  text-decoration: none;
}
.login-foot a:hover { text-decoration: underline; }

/* ===== Buttons ===== */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dim) 100%);
  color: #1a1a1d;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { opacity: 0.8; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-outline {
  padding: 8px 18px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-outline:hover {
  border-color: var(--gold-dim);
  color: var(--gold);
}

.btn-ghost {
  padding: 6px 14px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--bg-hover);
}

/* ===== Topbar ===== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--gold);
}

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

.user-info {
  color: var(--text-dim);
  font-size: 13px;
  margin-right: 8px;
}

/* ===== Config banner ===== */
.config-banner {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  z-index: 99;
  background: rgba(201, 169, 110, 0.12);
  border-bottom: 1px solid var(--gold-dim);
}
.config-banner-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
}
.config-banner .cb-icon { color: var(--gold); font-size: 15px; }
.config-banner .cb-text { color: var(--text-muted); }
.config-banner .cb-btn {
  margin-left: auto;
  color: var(--gold);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}
.config-banner .cb-btn:hover { text-decoration: underline; }

/* ===== Layout ===== */
.layout {
  display: flex;
  margin-top: 56px;
  min-height: calc(100vh - 56px);
}
.layout.with-banner {
  margin-top: 98px;
  min-height: calc(100vh - 98px);
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  position: fixed;
  top: 56px;
  bottom: 0;
  overflow-y: auto;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px;
}

/* ===== Sidebar ===== */
.sidebar-section { margin-bottom: 28px; }

.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-btn {
  text-align: left;
  padding: 8px 12px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.filter-btn.active {
  color: var(--gold);
  background: rgba(201, 169, 110, 0.08);
  border-color: rgba(201, 169, 110, 0.2);
}

/* ===== Stats ===== */
.stats-box {
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.stats-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stat-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.stat-num {
  font-size: 20px;
  font-weight: 700;
  color: var(--gold);
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
}

/* ===== Content Grid ===== */
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  cursor: pointer;
}

.content-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--gold-dim);
}

.card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: #000;
  overflow: hidden;
}

.card-media img,
.card-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-media .play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  background: rgba(0,0,0,0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-media .play-icon::after {
  content: '';
  width: 0;
  height: 0;
  border-left: 14px solid white;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  margin-left: 4px;
}

.platform-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  backdrop-filter: blur(4px);
}

.platform-badge.instagram { background: rgba(228, 64, 95, 0.85); color: white; }
.platform-badge.twitter { background: rgba(29, 161, 242, 0.85); color: white; }
.platform-badge.tiktok { background: rgba(0, 0, 0, 0.7); color: white; border: 1px solid rgba(255,255,255,0.2); }

.type-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0,0,0,0.6);
  color: var(--gold-bright);
  backdrop-filter: blur(4px);
}

.card-body {
  padding: 14px 16px;
}

.card-author {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.card-author img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.card-author span {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.card-caption {
  font-size: 12px;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
  line-height: 1.5;
}

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

.card-stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-stat svg { width: 14px; height: 14px; opacity: 0.7; }

/* ===== Loading ===== */
.loading-placeholder {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}

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

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  opacity: 0.3;
  margin-bottom: 16px;
}

.empty-state h3 {
  color: var(--text-dim);
  font-size: 16px;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 13px;
}

/* ===== Load More ===== */
.load-more-wrap {
  text-align: center;
  margin-top: 28px;
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

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

.modal-header h2 {
  font-size: 18px;
  color: var(--gold);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.modal-close:hover { background: var(--bg-hover); color: var(--text); }

.modal-body { padding: 24px; }

/* ===== Admin ===== */
.admin-section { margin-bottom: 28px; }
.admin-section:last-child { margin-bottom: 0; }

.admin-section h3 {
  font-size: 15px;
  margin-bottom: 8px;
  color: var(--text);
}

.admin-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.cfg-label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin: 14px 0 6px;
  font-weight: 500;
}

.cfg-label:first-of-type { margin-top: 0; }

.input-row input {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
}

.input-row input:focus {
  outline: none;
  border-color: var(--gold-dim);
}

.admin-section textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  resize: vertical;
  margin-bottom: 12px;
}

.admin-section textarea:focus {
  outline: none;
  border-color: var(--gold-dim);
}

.admin-section code {
  background: var(--bg-hover);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--gold-bright);
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-row .btn-primary { width: auto; padding: 8px 18px; }

.scrape-result {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg-elevated);
  border-radius: 6px;
  font-size: 13px;
  display: none;
}

.scrape-result.show { display: block; }
.scrape-result.success { color: var(--green); }
.scrape-result.error { color: var(--red); }
.scrape-result.loading { color: var(--gold); }

.logs-list {
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border-radius: 6px;
  padding: 8px;
}

.log-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.log-item:last-child { border-bottom: none; }

.log-platform {
  font-weight: 600;
  text-transform: uppercase;
  width: 80px;
}

.log-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.log-status.success { background: var(--green); }
.log-status.error { background: var(--red); }

.log-msg {
  flex: 1;
  color: var(--text-dim);
}

.log-time {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}

/* ===== Lightbox ===== */
.lightbox {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.92);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: none;
  border: none;
  color: var(--text);
  font-size: 28px;
  cursor: pointer;
  z-index: 1;
}

#lightbox-body img,
#lightbox-body video {
  max-width: 90vw;
  max-height: 80vh;
  border-radius: 8px;
}

.lightbox-info {
  margin-top: 16px;
  color: var(--text);
}

.lightbox-info .lb-author {
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 8px;
}

.lightbox-info .lb-caption {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 12px;
  line-height: 1.6;
}

.lightbox-info .lb-stats {
  display: flex;
  gap: 20px;
  color: var(--text-muted);
  font-size: 13px;
}

.lightbox-info .lb-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 13px;
  color: var(--gold);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    position: relative;
    top: 0;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  
  .main-content {
    margin-left: 0;
    padding: 16px;
  }
  
  .content-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }
  
  .card-caption { font-size: 11px; }
  .card-stats { gap: 10px; font-size: 11px; }
}

/* ===== Content toolbar (add 5 more) ===== */
.content-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.ct-left { display: flex; align-items: baseline; gap: 8px; }
.ct-title { font-size: 17px; font-weight: 700; color: var(--text); }
.ct-count { font-size: 12.5px; color: var(--text-muted); }

.ct-right { display: flex; align-items: center; gap: 12px; }

.addmore-msg {
  font-size: 12.5px;
  line-height: 1.4;
  max-width: 320px;
  text-align: right;
  display: none;
}
.addmore-msg.show { display: inline-block; }
.addmore-msg.loading { color: var(--gold); }
.addmore-msg.success { color: #5fd28a; }
.addmore-msg.error { color: #e88; }

@media (max-width: 620px) {
  .content-toolbar { flex-direction: column; align-items: stretch; }
  .ct-right { justify-content: space-between; }
  .addmore-msg { max-width: none; text-align: left; }
}
