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

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: #151c2e;
  --bg-card-hover: #1a2340;
  --bg-input: #0d1220;
  --border: #1e293b;
  --border-active: #3b82f6;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.15);
  --green: #10b981;
  --green-glow: rgba(16, 185, 129, 0.15);
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.15);
  --yellow: #f59e0b;
  --purple: #8b5cf6;
  --purple-glow: rgba(139, 92, 246, 0.15);
  --cyan: #06b6d4;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.4);
  --transition: all 0.2s ease;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Monaco, monospace;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== ADMIN LAYOUT ===== */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.sidebar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: white;
  font-family: var(--font-mono);
}

.sidebar-brand .brand-text {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

.sidebar-brand .brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.sidebar-nav a:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.sidebar-nav a.active {
  background: var(--accent-glow);
  color: var(--accent);
}

.sidebar-nav a .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
  opacity: 0.8;
}

.sidebar-nav .nav-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

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

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 13px;
  transition: var(--transition);
}

.sidebar-footer a:hover {
  color: var(--red);
  background: var(--red-glow);
}

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 32px 40px;
  max-width: 100%;
}

/* ===== PAGE HEADER ===== */
.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.page-header p {
  color: var(--text-muted);
  font-size: 14px;
}

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

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--border-active);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 16px;
}

.stat-card .stat-icon.blue { background: var(--accent-glow); color: var(--accent); }
.stat-card .stat-icon.green { background: var(--green-glow); color: var(--green); }
.stat-card .stat-icon.purple { background: var(--purple-glow); color: var(--purple); }
.stat-card .stat-icon.red { background: var(--red-glow); color: var(--red); }

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.card-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.card-body {
  padding: 24px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: var(--border);
}

.btn-danger:hover {
  background: var(--red-glow);
  border-color: var(--red);
}

.btn-success {
  background: var(--green);
  color: white;
}

.btn-success:hover {
  background: #059669;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 15px;
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  transition: var(--transition);
  outline: none;
}

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

textarea.form-control {
  min-height: 120px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* ===== TABLE ===== */
.table-wrap {
  overflow-x: auto;
}

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

th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: rgba(255,255,255,0.02);
}

/* ===== BADGE ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-green {
  background: var(--green-glow);
  color: var(--green);
}

.badge-yellow {
  background: rgba(245, 158, 11, 0.15);
  color: var(--yellow);
}

.badge-blue {
  background: var(--accent-glow);
  color: var(--accent);
}

.badge-red {
  background: var(--red-glow);
  color: var(--red);
}

/* ===== FILE MANAGER ===== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--bg-input);
  margin-bottom: 24px;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.upload-zone .upload-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.upload-zone p {
  color: var(--text-muted);
  font-size: 14px;
}

.upload-zone .upload-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  opacity: 0.7;
}

.upload-progress {
  margin-top: 16px;
  display: none;
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  font-family: var(--font-mono);
}

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

/* ===== HOMEPAGE EDITOR ===== */
.editor-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  min-height: 600px;
}

.editor-pane {
  display: flex;
  flex-direction: column;
}

.editor-pane .editor-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.html-editor {
  flex: 1;
  width: 100%;
  min-height: 500px;
  padding: 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: var(--transition);
  tab-size: 2;
}

.html-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.preview-frame {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #050712;
  min-height: 500px;
}

/* ===== 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;
  animation: fadeIn 0.15s ease;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.15s ease;
}

.modal-header {
  padding: 20px 24px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-body {
  padding: 16px 24px;
}

.modal-footer {
  padding: 0 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

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

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* ===== LOGIN ===== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 30%, rgba(59, 130, 246, 0.08), transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(139, 92, 246, 0.08), transparent 50%),
    var(--bg-primary);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
}

.login-card .login-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
}

.login-card .brand-mark {
  text-align: center;
  margin-bottom: 24px;
}

.login-card .brand-mark span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: var(--radius-lg);
  font-weight: 700;
  font-size: 18px;
  color: white;
  font-family: var(--font-mono);
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 20px;
}

.alert-error {
  background: var(--red-glow);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.alert-success {
  background: var(--green-glow);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* ===== PUBLIC PAGES ===== */
.public-layout {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 28px;
  min-height: 100vh;
}

.public-layout.blog-layout {
  max-width: 720px;
}

/* ===== BLOG STYLES ===== */
.blog-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.blog-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: var(--transition);
}

.blog-item:hover {
  padding-left: 8px;
}

.blog-item .blog-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  transition: var(--transition);
}

.blog-item:hover .blog-title {
  color: var(--accent);
}

.blog-item .blog-date {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  margin-left: 24px;
}

.blog-item .blog-excerpt {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Blog post content */
.post-header {
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 12px;
}

.post-meta {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.post-content {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.post-content h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 40px 0 16px;
}

.post-content h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 32px 0 12px;
}

.post-content p {
  margin-bottom: 16px;
}

.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(59, 130, 246, 0.3);
  text-underline-offset: 3px;
  transition: var(--transition);
}

.post-content a:hover {
  text-decoration-color: var(--accent);
}

.post-content code {
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.post-content pre {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow-x: auto;
  margin: 24px 0;
}

.post-content pre code {
  background: transparent;
  border: none;
  padding: 0;
}

.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 12px 20px;
  background: var(--accent-glow);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 24px 0;
  color: var(--text-secondary);
  font-style: italic;
}

.post-content img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 24px 0;
}

.post-content ul, .post-content ol {
  margin: 16px 0;
  padding-left: 24px;
}

.post-content li {
  margin: 8px 0;
}

/* ===== FILE PREVIEW ===== */
.file-preview-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.file-preview-card {
  max-width: 480px;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.file-preview-card .file-icon {
  font-size: 48px;
  margin-bottom: 20px;
}

.file-preview-card .file-name {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  word-break: break-all;
}

.file-preview-card .file-size {
  font-size: 14px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: 24px;
}

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

.toast {
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }

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

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

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

.empty-state p {
  font-size: 14px;
}

/* ===== BACK LINK ===== */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 24px;
  transition: var(--transition);
}

.back-link:hover {
  color: var(--accent);
}

/* ===== 404 PAGE ===== */
.page-404 {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.page-404 h1 {
  font-size: 72px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-muted);
  line-height: 1;
  margin-bottom: 8px;
}

.page-404 p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .main-content {
    margin-left: 0;
    padding: 20px 16px;
  }
  .editor-container {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .page-header-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* ===== EASYMDE OVERRIDES ===== */
.EasyMDEContainer .CodeMirror {
  background: var(--bg-input) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  font-family: var(--font-mono) !important;
  font-size: 13px !important;
}

.EasyMDEContainer .editor-toolbar {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-bottom: none !important;
  border-radius: var(--radius) var(--radius) 0 0 !important;
}

.EasyMDEContainer .editor-toolbar button {
  color: var(--text-secondary) !important;
}

.EasyMDEContainer .editor-toolbar button:hover,
.EasyMDEContainer .editor-toolbar button.active {
  background: var(--accent-glow) !important;
  color: var(--accent) !important;
  border-color: transparent !important;
}

.EasyMDEContainer .editor-preview {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
}

.EasyMDEContainer .editor-statusbar {
  color: var(--text-muted) !important;
}

.EasyMDEContainer .CodeMirror-cursor {
  border-left-color: var(--accent) !important;
}

.editor-toolbar.fullscreen,
.CodeMirror-fullscreen,
.editor-preview-side {
  z-index: 999 !important;
}

/* ===== COPY BUTTON ===== */
.copy-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: var(--transition);
  font-family: var(--font-sans);
}

.copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== TRUNCATE ===== */
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  display: inline-block;
}

/* ===== PUBLIC NAV ===== */
.public-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 48px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.public-nav .nav-brand {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  text-decoration: none;
}

.public-nav .nav-links {
  display: flex;
  gap: 24px;
  list-style: none;
}

.public-nav .nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.public-nav .nav-links a:hover {
  color: var(--text-primary);
}
