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

:root {
  --red: #e63946;
  --navy: #0d1b2a;
  --navy-light: #1b2d42;
  --green: #2a9d8f;
  --purple: #6366f1;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --bg2: #f1f5f9;
  --white: #ffffff;
  --text: #0f172a;
  --mid: #475569;
  --muted: #94a3b8;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
  --transition: 0.18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul { list-style: none; }
button { font-family: inherit; }

/* ── Admin Layout ── */
#adminApp { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: rgba(255,255,255,.85);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-decoration: none;
  color: #fff;
}
.sidebar-logo .logo-icon { font-size: 20px; }
.sidebar-logo .logo-text { font-size: 16px; font-weight: 800; letter-spacing: -.3px; }
.sidebar-logo .logo-dot { color: var(--red); }

.sidebar-section { padding: 16px 0 8px; }
.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  padding: 0 20px 8px;
}
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,.7);
  border-left: 3px solid transparent;
  transition: all var(--transition);
}
.sidebar-nav li a:hover { background: rgba(255,255,255,.06); color: #fff; border-left-color: rgba(255,255,255,.2); }
.sidebar-nav li a.active { background: rgba(255,255,255,.1); color: #fff; border-left-color: var(--red); }
.sidebar-nav li a .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-nav li a .nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

.sidebar-user {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: rgba(255,255,255,.4); }
.sidebar-logout { color: rgba(255,255,255,.4); font-size: 18px; transition: color var(--transition); cursor: pointer; }
.sidebar-logout:hover { color: var(--red); }

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

/* ── Topbar ── */
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  gap: 16px;
}
.admin-page-title { font-size: 18px; font-weight: 700; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--red); }
.btn-secondary { background: var(--bg2); color: var(--mid); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-success { background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; }
.btn-success:hover { background: #16a34a; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }

/* ── Page Body ── */
.admin-body-content { padding: 28px; flex: 1; }

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 700; }
.card-body { padding: 22px; }

/* ── Stat Cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-lg); }
.stat-icon { font-size: 28px; line-height: 1; }
.stat-info { flex: 1; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 500; }
.stat-change { font-size: 11px; margin-top: 6px; font-weight: 600; }
.stat-change.up { color: #16a34a; }
.stat-change.down { color: #dc2626; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
tbody td { padding: 12px 16px; font-size: 13.5px; vertical-align: middle; }
.td-title { font-weight: 600; max-width: 280px; }
.td-title a { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.td-title a:hover { color: var(--red); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-published { background: #dcfce7; color: #16a34a; }
.badge-draft { background: #f1f5f9; color: #64748b; }
.badge-scheduled { background: #fef3c7; color: #d97706; }
.badge-pending { background: #fef3c7; color: #d97706; }
.badge-approved { background: #dcfce7; color: #16a34a; }
.badge-spam { background: #fef2f2; color: #dc2626; }
.badge-admin { background: #ede9fe; color: #7c3aed; }
.badge-editor { background: #dbeafe; color: #1d4ed8; }
.badge-author { background: #fce7f3; color: #be185d; }

/* ── Category Color Dot ── */
.cat-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ── Filters Bar ── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-wrap: wrap;
}
.filter-tabs { display: flex; gap: 4px; }
.filter-tab {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: none;
  color: var(--muted);
  transition: all var(--transition);
}
.filter-tab.active, .filter-tab:hover { background: var(--white); color: var(--text); box-shadow: var(--shadow); }
.filter-tab.active { color: var(--navy); }
.search-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px;
  flex: 1;
  max-width: 280px;
}
.search-input-bar input {
  border: none;
  outline: none;
  font-size: 13px;
  background: none;
  flex: 1;
  color: var(--text);
}
.search-input-bar svg { color: var(--muted); flex-shrink: 0; }
.ml-auto { margin-left: auto; }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-label .required { color: var(--red); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  background: var(--white);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(13,27,42,.07);
}
.form-textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
.form-hint { font-size: 11.5px; color: var(--muted); }
.form-section { margin-bottom: 28px; }
.form-section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.char-count { font-size: 11px; color: var(--muted); text-align: right; }
.char-count.warn { color: var(--amber); }
.char-count.over { color: var(--red); }

/* ── Rich Text Editor Toolbar ── */
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.editor-toolbar button {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  color: var(--mid);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.editor-toolbar button:hover { background: var(--white); color: var(--text); box-shadow: var(--shadow); }
.editor-toolbar button.active { background: var(--navy); color: #fff; }
.editor-toolbar .separator { width: 1px; background: var(--border); margin: 4px 6px; }
.editor-area {
  border: 1.5px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  min-height: 420px;
  padding: 20px 24px;
  outline: none;
  font-size: 15px;
  line-height: 1.8;
  font-family: 'Inter', sans-serif;
  overflow-y: auto;
  background: var(--white);
}
.editor-area:focus { border-color: var(--navy); }
.editor-area h1, .editor-area h2 { font-size: 22px; font-weight: 700; margin: 16px 0 8px; }
.editor-area h3 { font-size: 18px; font-weight: 600; margin: 12px 0 6px; }
.editor-area p { margin-bottom: 12px; }
.editor-area blockquote { border-left: 3px solid var(--red); padding: 8px 16px; margin: 12px 0; color: var(--mid); font-style: italic; }
.editor-area ul, .editor-area ol { margin: 8px 0 12px 24px; }
.editor-area a { color: var(--red); text-decoration: underline; }
.editor-area img { max-width: 100%; border-radius: 4px; }
.editor-area code { font-family: 'JetBrains Mono', monospace; background: var(--bg2); padding: 2px 6px; border-radius: 3px; font-size: 13px; }
.editor-area pre { background: var(--navy); color: #a8ff78; padding: 16px; border-radius: var(--radius); overflow-x: auto; }
.editor-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 0; }
.editor-tab { padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; transition: all var(--transition); background: none; border-top: none; border-left: none; border-right: none; }
.editor-tab.active { color: var(--navy); border-bottom-color: var(--navy); }

/* ── Image Upload ── */
.image-upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg);
}
.image-upload-zone:hover, .image-upload-zone.dragover { border-color: var(--navy); background: #f0f4ff; }
.image-upload-zone .upload-icon { font-size: 32px; margin-bottom: 10px; }
.image-upload-zone p { font-size: 14px; color: var(--muted); }
.image-upload-zone strong { color: var(--text); }
.image-preview-wrap { position: relative; }
.image-preview-wrap img { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); }
.image-remove-btn { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 50%; width: 28px; height: 28px; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; }

/* ── Toggle Switches ── */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row-label { font-size: 14px; font-weight: 500; }
.toggle-row-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.toggle-switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--border); border-radius: 12px; cursor: pointer; transition: .3s; }
.toggle-slider::before { content:''; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .3s; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
input:checked + .toggle-slider { background: var(--green); }
input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Tags Input ── */
.tags-input-wrap { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 7px 10px; border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--white); min-height: 42px; transition: border-color var(--transition); }
.tags-input-wrap:focus-within { border-color: var(--navy); }
.tag-chip { display: flex; align-items: center; gap: 5px; background: var(--navy); color: #fff; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.tag-chip button { background: none; border: none; color: rgba(255,255,255,.7); cursor: pointer; font-size: 14px; line-height: 1; padding: 0; display: flex; }
.tag-chip button:hover { color: #fff; }
.tags-input-wrap input { border: none; outline: none; font-size: 13px; flex: 1; min-width: 80px; background: none; }

/* ── Media Grid ── */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.media-item { border-radius: var(--radius); overflow: hidden; border: 2px solid transparent; cursor: pointer; transition: all var(--transition); position: relative; background: var(--bg2); aspect-ratio: 1; }
.media-item img { width: 100%; height: 100%; object-fit: cover; }
.media-item:hover { border-color: var(--navy); transform: scale(1.02); }
.media-item.selected { border-color: var(--red); }
.media-item-info { position: absolute; inset: 0; background: rgba(0,0,0,.6); color: #fff; padding: 8px; display: flex; flex-direction: column; justify-content: flex-end; opacity: 0; transition: opacity var(--transition); }
.media-item:hover .media-item-info { opacity: 1; }
.media-item-name { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-item-size { font-size: 10px; opacity: .7; }
.media-item-delete { position: absolute; top: 6px; right: 6px; background: var(--red); color: #fff; border: none; border-radius: 50%; width: 24px; height: 24px; font-size: 12px; cursor: pointer; display: none; align-items: center; justify-content: center; }
.media-item:hover .media-item-delete { display: flex; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-box {
  background: var(--white); border-radius: 12px; width: 100%;
  max-width: 560px; box-shadow: var(--shadow-lg);
  transform: translateY(20px); transition: transform .25s;
  max-height: 90vh; overflow-y: auto;
}
.modal-overlay.open .modal-box { transform: none; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); transition: color var(--transition); }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); }

/* ── Toast Notifications ── */
#toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  padding: 13px 22px; border-radius: var(--radius); font-size: 14px; font-weight: 600;
  background: var(--navy); color: #fff; box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity .3s, transform .3s; transform: translateY(8px);
  pointer-events: none;
}
#toast.show { opacity: 1; transform: none; }
#toast.error { background: #dc2626; }
#toast.success { background: var(--green); }

/* ── Spinner ── */
.spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--navy); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 40px auto;
}
.spinner-sm { width: 18px; height: 18px; border-width: 2px; margin: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 64px 24px; }
.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.empty-state p { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-top: 1px solid var(--border); }
.page-info { font-size: 13px; color: var(--muted); }
.page-btns { display: flex; gap: 4px; }
.page-btn { padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-weight: 500; background: var(--white); cursor: pointer; transition: all var(--transition); }
.page-btn:hover, .page-btn.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Dashboard Recent List ── */
.recent-list { display: flex; flex-direction: column; }
.recent-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.recent-item:last-child { border-bottom: none; }
.recent-item-img { width: 52px; height: 40px; border-radius: 5px; object-fit: cover; background: var(--bg2); flex-shrink: 0; }
.recent-item-info { flex: 1; min-width: 0; }
.recent-item-title { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-item-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.recent-item-actions { display: flex; gap: 4px; }

/* ── SEO Meter ── */
.seo-meter { margin-top: 8px; }
.seo-bar { height: 6px; background: var(--bg2); border-radius: 3px; overflow: hidden; margin-bottom: 4px; }
.seo-bar-fill { height: 100%; border-radius: 3px; transition: width .3s; }
.seo-good { background: #22c55e; }
.seo-ok { background: var(--amber); }
.seo-bad { background: var(--red); }

/* ── Responsive Sidebar Toggle ── */
.sidebar-toggle { display: none; position: fixed; top: 14px; left: 14px; z-index: 200; background: var(--navy); color: #fff; border: none; border-radius: 8px; padding: 8px 10px; cursor: pointer; font-size: 18px; }
@media(max-width: 900px) {
  .sidebar-toggle { display: flex; align-items: center; }
  .admin-sidebar { transform: translateX(-100%); }
  .admin-sidebar.open { transform: none; }
  .admin-content { margin-left: 0; }
  .admin-topbar { padding-left: 56px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media(max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .admin-body-content { padding: 16px; }
}
