/* ==========================================================================
   CMS admin — layout & components (on top of Bootstrap 5.3)
   ========================================================================== */
:root {
  --sidebar-w: 248px;
  --sidebar-bg: #0f172a;
  --sidebar-fg: #cbd5e1;
  --sidebar-active: #2563eb;
  --admin-bg: #f4f6fb;
}

body.admin-body { background: var(--admin-bg); }
.admin-shell { display: flex; min-height: 100vh; }

/* ---- sidebar ---- */
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
@media (min-width: 992px) {
  .admin-sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; visibility: visible !important; transform: none !important; background-color: var(--sidebar-bg) !important; }
  .admin-sidebar .offcanvas-body, .admin-sidebar { display: flex !important; flex-direction: column; }
}
@media (max-width: 991.98px) {
  .admin-sidebar.offcanvas-lg { --bs-offcanvas-width: var(--sidebar-w); --bs-offcanvas-bg: var(--sidebar-bg); }
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff; font-size: 1.05rem; }
.brand-mark-lg { width: 56px; height: 56px; border-radius: 16px; font-size: 1.6rem; }
.sidebar-nav { padding: .75rem .6rem; display: flex; flex-direction: column; gap: 2px; flex-grow: 1; }
.sidebar-link { display: flex; align-items: center; gap: .7rem; padding: .55rem .8rem; border-radius: 8px; color: var(--sidebar-fg); text-decoration: none; font-size: .92rem; }
.sidebar-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: .85; }
.sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-link.active { background: var(--sidebar-active); color: #fff; }
.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.08); }

/* ---- main ---- */
.admin-main { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; padding: .65rem 1.5rem; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid #e5e7eb; }
.admin-content { padding: 1.5rem; max-width: 1600px; width: 100%; }
@media (max-width: 575.98px) { .admin-content { padding: 1rem; } .admin-topbar { padding: .6rem 1rem; } }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.card { border-color: #e5e7eb; border-radius: 12px; }
.card-header { background: #fff; border-bottom-color: #eef0f4; padding: .85rem 1rem; border-top-left-radius: 12px !important; border-top-right-radius: 12px !important; }
.table > :not(caption) > * > * { padding: .7rem .9rem; }
.min-w-0 { min-width: 0; }

/* ---- status badges ---- */
.badge.status-published { background: #dcfce7; color: #166534; }
.badge.status-draft { background: #fef3c7; color: #92400e; }

/* ---- dashboard ---- */
.stat-card { transition: transform .15s, box-shadow .15s; color: inherit; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(15,23,42,.08); }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem; margin-bottom: .6rem; }
.stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; color: #0f172a; }
.stat-label { font-size: .82rem; color: #64748b; }
.workflow { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .75rem; }
@media (max-width: 991.98px) { .workflow { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.workflow-step { display: flex; flex-direction: column; gap: .15rem; padding: .85rem 1rem; border: 1px dashed #cbd5e1; border-radius: 10px; text-decoration: none; color: #0f172a; font-weight: 600; font-size: .92rem; }
.workflow-step span { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; background: #2563eb; color: #fff; align-items: center; justify-content: center; font-size: .8rem; margin-bottom: .3rem; }
.workflow-step small { color: #64748b; font-weight: 400; }
.workflow-step:hover { border-color: #2563eb; background: #eff6ff; }

/* ---- stepper (page wizard) ---- */
.stepper { display: flex; flex-wrap: wrap; gap: .5rem; }
.stepper .step { flex: 1 1 140px; display: flex; flex-direction: column; padding: .6rem .8rem; border-radius: 10px; background: #fff; border: 1px solid #e5e7eb; font-size: .86rem; font-weight: 600; color: #64748b; }
.stepper .step span { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; background: #e2e8f0; align-items: center; justify-content: center; font-size: .75rem; margin-bottom: .25rem; }
.stepper .step small { font-weight: 400; }
.stepper .step.done { color: #166534; }
.stepper .step.done span { background: #22c55e; color: #fff; }
.stepper .step.active { border-color: #2563eb; color: #1e3a8a; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.stepper .step.active span { background: #2563eb; color: #fff; }

.template-card { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.template-card:hover { border-color: #93c5fd; }
.template-card.selected { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.18); }
.template-icon { width: 44px; height: 44px; border-radius: 12px; background: #eff6ff; color: #2563eb; display: inline-flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }

/* ---- page builder ---- */
.url-prefix { max-width: 55%; font-family: var(--bs-font-monospace); font-size: .8rem; }
.field-group { border: 1px solid #eef0f4; border-radius: 10px; padding: 1rem 1rem .25rem; background: #fcfcfd; }
.field-group + .field-group { margin-top: 1rem; }
.field-group-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #64748b; margin-bottom: .9rem; }
.repeater-row .card-header { cursor: grab; }
.repeater-row .card-body .cms-field { margin-bottom: .75rem !important; }
.serp-preview { border: 1px solid #e5e7eb; border-radius: 10px; padding: 1rem 1.1rem; background: #fff; font-family: arial, sans-serif; }
.serp-url { color: #188038; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.serp-title { color: #1a0dab; font-size: 1.15rem; line-height: 1.3; margin: .15rem 0; }
.serp-desc { color: #4d5156; font-size: .87rem; line-height: 1.45; }
.publish-box .card-header { background: #f8fafc; }
.tox-tinymce { border-radius: 8px !important; }

/* ---- field type picker ---- */
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
.type-option { display: flex; align-items: center; gap: .5rem; text-align: left; font-size: .86rem; padding: .55rem .7rem; }
.type-option i { font-size: 1.05rem; }
.field-assign .list-group-item { background: #fff; }
.drag-handle { cursor: grab; }

/* ---- media ---- */
.dropzone-box { border: 2px dashed #cbd5e1; border-radius: 12px; padding: 1.75rem; text-align: center; background: #fafbff; transition: border-color .15s, background .15s; }
.dropzone-box.dragging { border-color: #2563eb; background: #eff6ff; }
.media-library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.media-card { overflow: hidden; }
.media-thumb { display: flex; align-items: center; justify-content: center; flex-direction: column; aspect-ratio: 4 / 3; width: 100%; background: #f1f5f9; border: 0; padding: 0; overflow: hidden; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-thumb i { font-size: 2.4rem; color: #94a3b8; }
.media-thumb .ext { font-size: .75rem; font-weight: 700; color: #64748b; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .75rem; }
.media-pick-item { position: relative; border: 2px solid transparent; border-radius: 10px; background: #f1f5f9; padding: 0; overflow: hidden; aspect-ratio: 1; display: flex; flex-direction: column; }
.media-pick-item img { width: 100%; height: 100%; object-fit: cover; }
.media-pick-item .file-icon { flex-grow: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #64748b; font-size: 2rem; }
.media-pick-item .file-icon small { font-size: .7rem; font-weight: 700; }
.media-pick-name { position: absolute; left: 0; right: 0; bottom: 0; font-size: .7rem; background: rgba(15,23,42,.65); color: #fff; padding: .15rem .35rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-pick-item.selected { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.3); }
.media-pick-item.selected::after { content: "\F26E"; font-family: bootstrap-icons; position: absolute; top: 6px; right: 6px; background: #2563eb; color: #fff; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .9rem; }
.gallery-item img { display: block; }

/* ---- menus ---- */
.menu-tree { list-style: none; padding-left: 0; margin: 0; min-height: 8px; }
.menu-tree .menu-tree { padding-left: 1.75rem; }
.menu-node { margin-bottom: .4rem; }
.menu-node-body { display: flex; align-items: center; gap: .5rem; padding: .55rem .75rem; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; }
.menu-node-edit { padding: .9rem; border: 1px solid #e5e7eb; border-top: 0; border-radius: 0 0 8px 8px; background: #f8fafc; margin-top: -4px; margin-bottom: .4rem; }
.sortable-ghost > .menu-node-body { background: #eff6ff; border-style: dashed; }

/* ---- misc ---- */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: #64748b; }
.empty-state i { font-size: 2.4rem; display: block; margin-bottom: .5rem; color: #94a3b8; }
.site-logo { width: 48px; height: 48px; border-radius: 10px; background: #f1f5f9; display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; font-size: 1.3rem; color: #64748b; }
.site-logo img { max-width: 100%; max-height: 100%; object-fit: contain; padding: 4px; }
.cat-icon { width: 32px; height: 32px; border-radius: 8px; background: #eff6ff; color: #2563eb; display: inline-flex; align-items: center; justify-content: center; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #e0e7ff; color: #3730a3; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.template-help code { font-size: .78em; }
.CodeMirror { font-size: 13px; line-height: 1.5; border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; }
.counter { margin-top: .15rem; }

/* ---- login ---- */
.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: radial-gradient(circle at 20% 20%, #dbeafe 0, transparent 40%), radial-gradient(circle at 80% 80%, #ede9fe 0, transparent 40%), #f8fafc; }
.login-card { width: 100%; max-width: 420px; border-radius: 16px; }
