/* ═══════════════════════════════════════════════════════
   BLOG MANAGEMENT SYSTEM  –  Admin Dashboard Extension
   Premium dark-accented design matching the admin panel.
   ═══════════════════════════════════════════════════════ */

:root {
  --bm-primary:      #6366f1;
  --bm-primary-soft: rgba(99, 102, 241, 0.1);
  --bm-success:      #10b981;
  --bm-warning:      #f59e0b;
  --bm-danger:       #ef4444;
  --bm-pending:      #f97316;
  --bm-info:         #06b6d4;
  --bm-surface:      #fff;
  --bm-border:       #e5e7eb;
  --bm-text:         #111827;
  --bm-muted:        #6b7280;
  --bm-radius:       10px;
  --bm-shadow:       0 4px 16px rgba(0,0,0,0.06);
  --bm-transition:   all .2s ease;
}

/* ── Blog view wrapper ───────────────────────────────── */
#blogs-view {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

/* ── Two-panel layout ───────────────────────────────── */
.bm-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

/* ── Panel cards ────────────────────────────────────── */
.bm-panel {
  background: var(--bm-surface);
  border-radius: var(--bm-radius);
  box-shadow: var(--bm-shadow);
  border: 1px solid var(--bm-border);
  padding: 24px;
}

.bm-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--bm-border);
  flex-wrap: wrap;
  gap: 10px;
}

.bm-panel-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--bm-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.bm-panel-title i { color: var(--bm-primary); }

/* ── Tab bar (Create / List / Media) ───────────────── */
.bm-tabs {
  display: flex;
  gap: 4px;
  background: #f3f4f6;
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.bm-tab-btn {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--bm-muted);
  background: transparent;
  cursor: pointer;
  transition: var(--bm-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.bm-tab-btn:hover { background: rgba(99,102,241,0.08); color: var(--bm-primary); }
.bm-tab-btn.active {
  background: var(--bm-surface);
  color: var(--bm-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

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

/* ── Form sections ──────────────────────────────────── */
.bm-form-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

@media (max-width: 960px) {
  .bm-form-grid { grid-template-columns: 1fr; }
}

.bm-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bm-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--bm-text);
}

.bm-label .req { color: var(--bm-danger); margin-left: 2px; }

.bm-input,
.bm-select,
.bm-textarea {
  padding: 10px 14px;
  border: 1.5px solid var(--bm-border);
  border-radius: 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  color: var(--bm-text);
  background: #fff;
  transition: var(--bm-transition);
  width: 100%;
  box-sizing: border-box;
}

.bm-input:focus,
.bm-select:focus,
.bm-textarea:focus {
  outline: none;
  border-color: var(--bm-primary);
  box-shadow: 0 0 0 3px var(--bm-primary-soft);
}

.bm-textarea { resize: vertical; min-height: 80px; }
.bm-select   { cursor: pointer; }

/* Category row with quick-add */
.bm-category-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.bm-category-row .bm-select { flex: 1; }

.bm-btn-icon-sm {
  padding: 10px 14px;
  border: 1.5px solid var(--bm-border);
  border-radius: 8px;
  background: #f9fafb;
  color: var(--bm-primary);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  transition: var(--bm-transition);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}

.bm-btn-icon-sm:hover {
  background: var(--bm-primary-soft);
  border-color: var(--bm-primary);
}

/* ── Tags ───────────────────────────────────────────── */
.bm-tags-box {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  border: 1.5px solid var(--bm-border);
  border-radius: 8px;
  min-height: 44px;
  align-items: center;
  background: #fff;
  cursor: text;
  transition: var(--bm-transition);
}

.bm-tags-box:focus-within {
  border-color: var(--bm-primary);
  box-shadow: 0 0 0 3px var(--bm-primary-soft);
}

.bm-tag-input {
  border: none;
  outline: none;
  flex-grow: 1;
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem;
  min-width: 120px;
  background: transparent;
}

.bm-tag-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bm-primary-soft);
  color: var(--bm-primary);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.bm-tag-pill .rm { cursor: pointer; opacity: 0.7; }
.bm-tag-pill .rm:hover { opacity: 1; }

/* ── Cover image dropzone ────────────────────────────── */
.bm-dropzone {
  border: 2px dashed var(--bm-border);
  border-radius: 10px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--bm-transition);
  background: #fafafa;
}

.bm-dropzone:hover,
.bm-dropzone.drag-over {
  border-color: var(--bm-primary);
  background: var(--bm-primary-soft);
}

.bm-dropzone i { font-size: 2rem; color: #94a3b8; display: block; margin-bottom: 8px; }
.bm-dropzone span { font-weight: 600; color: var(--bm-muted); font-size: 0.9rem; }
.bm-dropzone small { display: block; color: #94a3b8; margin-top: 4px; font-size: 0.8rem; }

/* ── Image previews ─────────────────────────────────── */
.bm-image-previews {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.bm-img-item {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--bm-border);
}

.bm-img-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bm-img-remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  background: var(--bm-danger);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 0.65rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--bm-transition);
}

.bm-img-item:hover .bm-img-remove { opacity: 1; }

/* ── Attachment list ────────────────────────────────── */
.bm-attach-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.bm-attach-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #f9fafb;
  border: 1px solid var(--bm-border);
  border-radius: 8px;
  font-size: 0.85rem;
}

.bm-attach-icon { font-size: 1.1rem; color: var(--bm-primary); }
.bm-attach-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-attach-size { color: var(--bm-muted); font-size: 0.78rem; }
.bm-attach-remove { background: none; border: none; color: var(--bm-danger); cursor: pointer; font-size: 0.85rem; }

/* ── Quill editor wrapper ───────────────────────────── */
.bm-editor-wrap {
  border: 1.5px solid var(--bm-border);
  border-radius: 8px;
  overflow: hidden;
  transition: var(--bm-transition);
}

.bm-editor-wrap:focus-within {
  border-color: var(--bm-primary);
  box-shadow: 0 0 0 3px var(--bm-primary-soft);
}

#bm-quill-editor { height: 380px; font-size: 1rem; background: #fff; cursor: text; }
#bm-quill-editor .ql-container,
#bm-quill-editor .ql-editor { background: #fff; cursor: text; pointer-events: auto; }

/* ── Right sidebar panel ────────────────────────────── */
.bm-sidebar { display: flex; flex-direction: column; gap: 16px; }

.bm-sidebar-card {
  background: #f9fafb;
  border: 1px solid var(--bm-border);
  border-radius: 10px;
  padding: 16px;
}

.bm-sidebar-card h4 {
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bm-muted);
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Status badges ──────────────────────────────────── */
.bm-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bm-status-badge.draft          { background: #f3f4f6; color: #6b7280; }
.bm-status-badge.pending_review { background: #fef3c7; color: #92400e; }
.bm-status-badge.published      { background: #d1fae5; color: #065f46; }

/* ── Blog list table ────────────────────────────────── */
.bm-list-table { width: 100%; border-collapse: collapse; }

.bm-list-table th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bm-muted);
  padding: 10px 12px;
  border-bottom: 1.5px solid var(--bm-border);
  white-space: nowrap;
}

.bm-list-table td {
  padding: 12px 12px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.88rem;
  color: var(--bm-text);
  vertical-align: middle;
}

.bm-list-table tr:hover td { background: #fafafa; }

.bm-list-table .blog-title-cell {
  font-weight: 600;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bm-list-table .created-by-cell {
  font-size: 0.82rem;
  color: var(--bm-muted);
}

/* ── Action buttons ─────────────────────────────────── */
.bm-action-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.bm-btn-xs {
  padding: 5px 10px;
  border: 1.5px solid transparent;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: var(--bm-transition);
  background: none;
  font-family: 'Outfit', sans-serif;
}

.bm-btn-xs.view   { color: var(--bm-info);    border-color: #a5f3fc; background: #ecfeff; }
.bm-btn-xs.edit   { color: var(--bm-primary); border-color: #c7d2fe; background: #eef2ff; }
.bm-btn-xs.delete { color: var(--bm-danger);  border-color: #fecaca; background: #fef2f2; }

.bm-btn-xs:hover { filter: brightness(0.93); transform: translateY(-1px); }

/* ── Filter bar ─────────────────────────────────────── */
.bm-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid var(--bm-border);
}

.bm-filters label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--bm-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bm-filter-input {
  padding: 7px 12px;
  border: 1.5px solid var(--bm-border);
  border-radius: 6px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  color: var(--bm-text);
  background: #fff;
  transition: var(--bm-transition);
}

.bm-filter-input:focus {
  outline: none;
  border-color: var(--bm-primary);
}

/* ── Primary action buttons ─────────────────────────── */
.bm-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: var(--bm-transition);
}

.bm-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.bm-btn-primary   { background: var(--bm-primary); color: #fff; }
.bm-btn-success   { background: var(--bm-success); color: #fff; }
.bm-btn-warning   { background: var(--bm-warning); color: #fff; }
.bm-btn-danger    { background: var(--bm-danger);  color: #fff; }
.bm-btn-ghost     { background: #f3f4f6; color: #374151; border: 1px solid var(--bm-border); }
.bm-btn-outline   { background: transparent; color: var(--bm-primary); border: 1.5px solid var(--bm-primary); }

.bm-btn:hover { filter: brightness(0.93); transform: translateY(-1px); }

/* ── Word count / stats ─────────────────────────────── */
.bm-editor-stats {
  font-size: 0.8rem;
  color: var(--bm-muted);
  text-align: right;
  padding: 4px 4px 0;
}

/* ── Media library grid ─────────────────────────────── */
.bm-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  max-height: 440px;
  overflow-y: auto;
  padding: 4px;
}

.bm-media-thumb {
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: var(--bm-transition);
  aspect-ratio: 1;
  position: relative;
}

.bm-media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bm-media-thumb:hover    { border-color: var(--bm-primary); transform: scale(1.03); }
.bm-media-thumb.selected { border-color: var(--bm-primary); box-shadow: 0 0 0 3px var(--bm-primary-soft); }

.bm-media-overlay {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 0.68rem;
  padding: 3px 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Modal (view/edit) ──────────────────────────────── */
.bm-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9990;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 30px 16px 60px;
}

.bm-modal-backdrop.open { display: flex; }

.bm-modal {
  background: #fff;
  border-radius: 14px;
  max-width: 900px;
  width: 100%;
  margin: auto;
  box-shadow: 0 30px 60px rgba(0,0,0,0.25);
  position: relative;
  animation: bmSlideIn 0.25s ease-out;
}

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

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

.bm-modal-head h3 { font-size: 1.1rem; font-weight: 700; margin: 0; }

.bm-modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--bm-muted);
  line-height: 1;
  padding: 0;
  transition: var(--bm-transition);
}

.bm-modal-close:hover { color: var(--bm-danger); transform: rotate(90deg); }
.bm-modal-body { padding: 24px; }

/* Preview render area */
.bm-preview-area .ql-editor {
  padding: 0;
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--bm-text);
}

.bm-preview-meta .bm-cat-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--bm-primary-soft);
  color: var(--bm-primary);
  margin-bottom: 10px;
}

.bm-preview-title {
  font-size: 2rem;
  font-weight: 800;
  margin: 0 0 10px;
  line-height: 1.2;
}

.bm-preview-author {
  font-size: 0.9rem;
  color: var(--bm-muted);
  margin-bottom: 24px;
}

.bm-preview-cover {
  width: 100%;
  border-radius: 10px;
  margin-bottom: 24px;
  max-height: 400px;
  object-fit: cover;
}

.bm-preview-tags {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--bm-border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bm-preview-tag {
  padding: 2px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--bm-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

/* Attachments download section */
.bm-attachments-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--bm-border);
}

.bm-attachment-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #f3f4f6;
  border-radius: 8px;
  color: var(--bm-text);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--bm-border);
  transition: var(--bm-transition);
  margin: 4px;
}

.bm-attachment-download:hover {
  background: var(--bm-primary-soft);
  color: var(--bm-primary);
  border-color: var(--bm-primary);
}

/* ── Expert badge ────────────────────────────────────── */
.bm-expert-badge {
  background: #fef3c7;
  color: #92400e;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 700;
}

/* ── Toast ──────────────────────────────────────────── */
#bm-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.bm-toast {
  padding: 12px 20px;
  border-radius: 10px;
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: bmToastIn .25s ease-out;
  pointer-events: all;
}

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

.bm-toast.success { background: var(--bm-success); }
.bm-toast.error   { background: var(--bm-danger);  }
.bm-toast.info    { background: var(--bm-primary);  }
.bm-toast.warning { background: var(--bm-warning);  }

/* ── SEO collapsible section ────────────────────────── */
.bm-seo-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  font-family: 'Outfit', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--bm-muted);
  cursor: pointer;
  padding: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bm-seo-toggle:hover { color: var(--bm-primary); }
.bm-seo-body { margin-top: 12px; display: none; }
.bm-seo-body.open { display: flex; flex-direction: column; gap: 10px; }

/* ── Empty state ────────────────────────────────────── */
.bm-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--bm-muted);
}

.bm-empty i { font-size: 3rem; margin-bottom: 14px; display: block; opacity: 0.4; }
.bm-empty p { font-size: 1rem; font-weight: 600; }

/* ── Loading spinner ─────────────────────────────────── */
.bm-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--bm-primary);
  border-radius: 50%;
  animation: bmSpin 0.7s linear infinite;
  margin: 24px auto;
}

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

/* ── Pagination ─────────────────────────────────────── */
.bm-pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.bm-page-btn {
  padding: 6px 13px;
  border: 1.5px solid var(--bm-border);
  border-radius: 6px;
  background: #fff;
  color: var(--bm-text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--bm-transition);
  font-family: 'Outfit', sans-serif;
}

.bm-page-btn:hover,
.bm-page-btn.active {
  background: var(--bm-primary);
  color: #fff;
  border-color: var(--bm-primary);
}

/* Scrollbar in media grid */
.bm-media-grid::-webkit-scrollbar { width: 6px; }
.bm-media-grid::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
