/* ============================================================
   GEEK-SPACE Admin Panel - Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --bg: #07070f;
  --bg-panel: #0e0e1a;
  --bg-card: #14141f;
  --bg-surface: #1c1c2e;
  --bg-hover: #22223a;
  --border: rgba(255,255,255,0.07);
  --border-light: rgba(255,255,255,0.12);
  --text: #e2e2ee;
  --text-2: #9292b2;
  --text-3: #5a5a78;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99,102,241,0.3);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --blue: #3b82f6;
  --radius: 10px;
  --radius-lg: 14px;
  --sidebar-w: 260px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---- Login Page ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(ellipse at 50% 0%, rgba(99,102,241,0.08) 0%, transparent 60%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 40px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-family: 'Syne', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
}

.login-logo h1 span { color: var(--accent); }

.login-logo p { font-size: 0.85rem; color: var(--text-2); margin-top: 6px; }

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

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 8px;
  letter-spacing: 0.03em;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder { color: var(--text-3); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: white;
  width: 100%;
  padding: 13px;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text);
  border: 1px solid var(--border-light);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { opacity: 0.9; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-surface); color: var(--text); }

.btn-sm { padding: 7px 14px; font-size: 0.8rem; }
.btn-icon { width: 36px; height: 36px; padding: 0; flex-shrink: 0; }

.login-error {
  padding: 12px 14px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius);
  color: #fca5a5;
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: none;
}

/* ---- Admin Layout ---- */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
}

.sidebar-logo span { color: var(--accent); }

.sidebar-badge {
  font-size: 0.65rem;
  background: rgba(99,102,241,0.15);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: auto;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 12px 8px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
  transition: 0.15s;
  text-decoration: none;
  position: relative;
}

.nav-link:hover { background: var(--bg-surface); color: var(--text); }

.nav-link.active {
  background: rgba(99,102,241,0.12);
  color: var(--accent);
  font-weight: 600;
}

.nav-link .icon { width: 18px; text-align: center; font-size: 0.9rem; }

.nav-link .badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  background: var(--accent);
  color: white;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

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

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--bg-surface);
}

.user-avatar {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-email { font-size: 0.78rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.7rem; color: var(--text-3); }

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  height: 60px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar-title {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 700;
}

.top-bar-actions { display: flex; align-items: center; gap: 10px; }

.content-area { padding: 28px; flex: 1; }

/* ---- Stats Cards ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

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

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
}

.stat-change {
  font-size: 0.78rem;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---- Table ---- */
.data-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.table-title {
  font-family: 'Syne', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
}

.table-search {
  position: relative;
}

.table-search input {
  padding: 8px 14px 8px 36px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.83rem;
  font-family: inherit;
  width: 220px;
}

.table-search input:focus { outline: none; border-color: var(--accent); }

.table-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  width: 14px;
}

.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 13px 16px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.article-title-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.article-thumb {
  width: 52px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg-surface);
  flex-shrink: 0;
}

.article-thumb-placeholder {
  width: 52px;
  height: 38px;
  border-radius: 6px;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.article-name { font-weight: 500; line-height: 1.3; }
.article-name small { display: block; color: var(--text-3); font-size: 0.75rem; font-weight: 400; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-published { background: rgba(16,185,129,0.12); color: var(--success); }
.status-draft { background: rgba(107,114,128,0.12); color: #9ca3af; }

.cat-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.actions-cell { display: flex; align-items: center; gap: 6px; }

/* ---- Article Editor ---- */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
}

.editor-main, .editor-side { display: flex; flex-direction: column; gap: 16px; }

.editor-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.editor-panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-family: 'Syne', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.editor-panel-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }

.editor-field { display: flex; flex-direction: column; gap: 6px; }
.editor-label { font-size: 0.78rem; font-weight: 600; color: var(--text-2); }

.editor-input {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  transition: 0.2s;
  resize: none;
}

.editor-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.editor-input::placeholder { color: var(--text-3); }

.editor-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235a5a78' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ---- Rich Text Toolbar ---- */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  background: var(--bg-panel);
}

.toolbar-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  background: transparent;
  color: var(--text-2);
  border: 1px solid transparent;
  transition: 0.15s;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
}

.toolbar-btn:hover { background: var(--bg-surface); color: var(--text); border-color: var(--border); }
.toolbar-btn.active { background: rgba(99,102,241,0.15); color: var(--accent); border-color: rgba(99,102,241,0.2); }

.toolbar-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }

.editor-textarea {
  width: 100%;
  min-height: 500px;
  padding: 18px;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: 'DM Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.875rem;
  line-height: 1.7;
  resize: vertical;
}

.editor-textarea:focus { outline: none; }

/* ---- AI Generate Panel ---- */
.ai-panel {
  background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(59,130,246,0.03));
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.ai-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Syne', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: #818cf8;
  margin-bottom: 14px;
}

.ai-btn {
  width: 100%;
  padding: 11px;
  background: linear-gradient(135deg, var(--accent), #4338ca);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.ai-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.ai-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.ai-loading {
  display: none;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: #818cf8;
  padding: 12px;
  background: rgba(99,102,241,0.05);
  border-radius: var(--radius);
  margin-top: 10px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(99,102,241,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

/* ---- Image Upload ---- */
.image-upload-zone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: 0.2s;
  position: relative;
}

.image-upload-zone:hover { border-color: var(--accent); background: rgba(99,102,241,0.04); }
.image-upload-zone.dragover { border-color: var(--accent); background: rgba(99,102,241,0.08); }

.image-upload-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.upload-icon { font-size: 2rem; margin-bottom: 8px; }
.upload-text { font-size: 0.82rem; color: var(--text-2); }
.upload-hint { font-size: 0.75rem; color: var(--text-3); margin-top: 4px; }

.image-preview {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  display: none;
}

.image-preview img {
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.image-preview-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: rgba(0,0,0,0.7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.75rem;
  color: white;
}

/* ---- Affiliate Links ---- */
.affiliate-list { display: flex; flex-direction: column; gap: 8px; }

.affiliate-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.affiliate-item input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.82rem;
  font-family: inherit;
}

.affiliate-item input:focus { outline: none; }
.affiliate-item input::placeholder { color: var(--text-3); }

/* ---- Notifications / Toast ---- */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-size: 0.85rem;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  animation: toastIn 0.3s ease;
  min-width: 280px;
  max-width: 380px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }

@keyframes toastIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: 0.2s;
}

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

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 18px;
  width: 100%;
  max-width: 560px;
  transform: scale(0.95);
  transition: 0.2s;
}

.modal-overlay.open .modal { transform: scale(1); }

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

.modal-title { font-family: 'Syne', sans-serif; font-size: 1rem; font-weight: 700; }
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-surface);
  border: none;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.15s;
}
.modal-close:hover { background: var(--danger); color: white; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 4px; margin-bottom: 24px; }

.tab-btn {
  padding: 10px 18px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-2);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: 0.15s;
  margin-bottom: -1px;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .editor-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
