* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f4f6f9;
  color: #16232e;
}
.admin-header {
  background: #0b5d8c;
  color: #fff;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.admin-header a { color: #fff; text-decoration: none; font-weight: 600; }
.admin-header .actions a {
  color: #fff; opacity: 0.85; margin-left: 18px; font-size: 0.9rem;
}
.admin-wrap { max-width: 960px; margin: 32px auto; padding: 0 20px; }
.card {
  background: #fff; border: 1px solid #e2e8ee; border-radius: 10px;
  padding: 28px; margin-bottom: 24px; box-shadow: 0 1px 3px rgba(15,35,55,0.06);
}
h1, h2 { margin-top: 0; }
label { display: block; font-weight: 600; margin: 16px 0 6px; font-size: 0.9rem; }
input[type=text], input[type=password], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #d7dee5; border-radius: 6px;
  font-size: 0.95rem; font-family: inherit;
}
textarea { min-height: 260px; font-family: 'Consolas', monospace; font-size: 0.85rem; }
.btn {
  display: inline-block; padding: 10px 20px; border-radius: 6px; border: none;
  background: #0b5d8c; color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; font-size: 0.9rem;
}
.btn:hover { background: #073f60; }
.btn-danger { background: #c0392b; }
.btn-danger:hover { background: #922017; }
.btn-outline { background: transparent; border: 1px solid #d7dee5; color: #16232e; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #eef1f4; font-size: 0.9rem; }
th { color: #55636f; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.row-actions a { margin-right: 12px; font-size: 0.85rem; cursor: pointer; }
.row-actions .delete { color: #c0392b; }

/* ---- Dashboard tab switcher (Articles / Video Posts) ---- */
.dashboard-tabs { display: flex; gap: 8px; margin-bottom: 20px; border-bottom: 1px solid #e2e8ee; }
.dashboard-tab {
  border: none; background: transparent; padding: 10px 4px; margin-right: 18px;
  font-size: 0.95rem; font-weight: 700; color: #64748b; cursor: pointer;
  border-bottom: 3px solid transparent;
}
.dashboard-tab.active { color: #0b5d8c; border-bottom-color: #0b5d8c; }
.dashboard-tab:hover { color: #073f60; }

/* ---- Post list: metrics, filters, status ---- */
.metrics-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px; margin: 20px 0;
}
.metric-card {
  background: #fafbfc; border: 1px solid #e2e8ee; border-radius: 8px; padding: 12px 14px;
}
.metric-card .metric-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #55636f; }
.metric-card .metric-value { font-size: 1.4rem; font-weight: 700; color: #0b5d8c; margin-top: 4px; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filter-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-pill {
  border: 1px solid #d7dee5; background: #fff; color: #334155; border-radius: 999px;
  padding: 6px 14px; font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
.filter-pill.active { background: #0b5d8c; border-color: #0b5d8c; color: #fff; }
#post-search-input { max-width: 280px; margin-left: auto; }

.status-pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
}
.status-pill.status-published { background: #e6f4ea; color: #1e7e34; }
.status-pill.status-draft { background: #f1f5f9; color: #64748b; }
.featured-star { color: #dd8f28; margin-left: 4px; }
.error { background: #fce8e6; color: #b3261e; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 0.9rem; }
.success { background: #e6f4ea; color: #1e7e34; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 0.9rem; }
.hint { color: #55636f; font-size: 0.82rem; margin-top: 4px; }
.hint code { background: #eef1f4; padding: 1px 5px; border-radius: 4px; }
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { max-width: 420px; width: 100%; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

#current-image-preview img { max-width: 220px; border-radius: 8px; display: block; margin: 8px 0; }

#loading-overlay {
  position: fixed; inset: 0; background: rgba(15,35,55,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 999;
}
.spinner-box {
  background: #fff; padding: 18px 28px; border-radius: 10px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

/* ---- Block content editor ---- */
.block-toolbar {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 10px;
  border: 1px solid #d7dee5; border-radius: 8px 8px 0 0; background: #fafbfc;
}
.block-add-btn {
  border: 1px solid #cbd5e1; background: #fff; color: #334155;
  padding: 6px 10px; border-radius: 5px; font-size: 0.78rem; font-weight: 700; cursor: pointer;
}
.block-add-btn:hover { background: #f1f5f9; }

#block-editor {
  border: 1px solid #d7dee5; border-top: none; border-radius: 0 0 8px 8px;
  background: #fbfbfd; padding: 14px; min-height: 120px;
}
#block-editor:empty::before,
.block-empty-state {
  display: block; text-align: center; padding: 30px 15px; color: #64748b; font-size: 0.9rem;
}

.content-block {
  position: relative; background: #fff; border: 1px solid #dfe5ec; border-radius: 8px;
  margin-bottom: 10px; transition: border-color .15s ease, opacity .15s ease, transform .15s ease;
}
.content-block:hover { border-color: #b7c2cf; }
.content-block.dragging { opacity: 0.4; }
.content-block.drop-before { box-shadow: 0 -3px 0 0 #0b5d8c; }
.content-block.drop-after { box-shadow: 0 3px 0 0 #0b5d8c; }

.content-block-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-bottom: 1px solid #edf1f5; background: #fafbfc; border-radius: 8px 8px 0 0;
}
.content-block-title { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; font-weight: 700; color: #263247; }
.content-block-title small { color: #94a3b8; font-weight: 600; }
.block-drag-handle {
  cursor: grab; color: #64748b; font-weight: 800; letter-spacing: -2px; user-select: none;
  padding: 2px 6px; border-radius: 4px;
}
.block-drag-handle:hover { background: #eef2f7; color: #1e293b; }
.block-drag-handle:active { cursor: grabbing; }

.content-block-actions { position: relative; display: flex; gap: 6px; }
.block-mini-btn {
  border: 1px solid #d6dee8; background: #fff; color: #334155;
  padding: 4px 9px; border-radius: 5px; font-size: 0.74rem; font-weight: 700; cursor: pointer;
}
.block-mini-btn:hover { background: #f8fafc; border-color: #aebdce; }

.block-more-menu {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 40;
  display: none; min-width: 140px; padding: 5px;
  border: 1px solid #dbe2ea; border-radius: 8px; background: #fff;
  box-shadow: 0 12px 28px rgba(15,23,42,.14);
}
.block-more-menu.open { display: flex; flex-direction: column; }
.block-more-menu button {
  width: 100%; padding: 7px 10px; border: 0; border-radius: 5px; background: transparent;
  color: #334155; text-align: left; font-size: 0.78rem; cursor: pointer;
}
.block-more-menu button:hover { background: #f1f5f9; }
.block-more-menu button.danger { color: #c0392b; }
.block-more-menu button.danger:hover { background: #fdecea; }

.content-block-body { padding: 12px; }
.content-block-body .field-row { margin-top: 0; }
.content-block-body input,
.content-block-body select,
.content-block-body textarea {
  margin: 0 0 8px;
}
.content-block-body textarea { min-height: 90px; font-family: inherit; font-size: 0.92rem; }
.block-divider-preview { text-align: center; color: #94a3b8; padding: 10px 0; font-size: 0.82rem; }
.block-image-preview { max-width: 220px; border-radius: 6px; display: block; margin-bottom: 8px; }

/* Floating "add block" popup (position + type picker) */
.add-block-menu {
  position: fixed; z-index: 60; width: 300px; padding: 14px;
  border: 1px solid #d7dee8; border-radius: 10px; background: #fff;
  box-shadow: 0 18px 45px rgba(15,23,42,.2);
}
.add-block-menu-head { display: flex; align-items: center; justify-content: space-between; }
.add-block-menu-head strong { font-size: 0.92rem; color: #243047; }
.add-block-menu-close { width: 26px; height: 26px; border: 0; border-radius: 5px; background: transparent; color: #64748b; font-size: 18px; cursor: pointer; }
.add-block-menu-close:hover { background: #f1f5f9; }
.add-block-menu-sub { margin: 4px 0 10px; color: #64748b; font-size: 0.78rem; }
.add-block-position-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
.add-block-position-row button {
  border: 1px solid #d8e0e9; border-radius: 6px; background: #f8fafc; color: #334155;
  padding: 7px 0; font-size: 0.76rem; font-weight: 700; cursor: pointer;
}
.add-block-position-row button.active { background: #0b5d8c; border-color: #0b5d8c; color: #fff; }
.add-block-type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.add-block-type-grid button {
  border: 1px solid #dce3eb; border-radius: 6px; background: #fff; color: #334155;
  padding: 8px; font-size: 0.78rem; font-weight: 600; cursor: pointer; text-align: left;
}
.add-block-type-grid button:hover { border-color: #9eb0c3; background: #f8fafc; }

/* ---- Preview overlay ---- */
#preview-overlay {
  position: fixed; inset: 0; background: rgba(15,35,55,0.55);
  z-index: 998; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.preview-panel {
  background: #fff; width: 100%; max-width: 900px; height: 90vh;
  border-radius: 10px; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: 0 20px 48px rgba(0,0,0,0.3);
}
.preview-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid #e2e8ee; font-size: 0.85rem; font-weight: 600;
}
#preview-frame { flex: 1; border: none; width: 100%; }

/* ---- Mobile ---- */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 720px) {
  .admin-header { padding: 14px 16px; flex-wrap: wrap; gap: 10px; }
  .admin-header .actions a { margin-left: 0; margin-right: 16px; }
  .admin-wrap { margin: 20px auto; padding: 0 14px; }
  .card { padding: 20px 18px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .login-card { max-width: 100%; margin: 0 16px; }
  table { min-width: 520px; }
  .preview-panel { max-width: 100%; height: 100%; border-radius: 0; }
  #preview-overlay { padding: 0; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  #post-search-input { max-width: none; margin-left: 0; }
  .add-block-menu { width: min(300px, calc(100vw - 24px)); }
}
