/* Busicus Admin — lightweight layout on top of Bootstrap 5.
   Brand blue is a single token (provisional; owner may change the brand colour).
   Kept separate from the public template assets to avoid CSS/JS conflicts. */
:root {
    --brand-blue: #2B54F5;      /* PROVISIONAL — lock from final logo */
    --brand-blue-600: #2246cf;
    --admin-bg: #f4f5f8;
    --admin-sidebar-bg: #10203a;
    --admin-sidebar-fg: #c7d2e4;
    --admin-sidebar-active: #ffffff;
    --admin-border: #e4e7ee;
}
* { box-sizing: border-box; }
body { background: var(--admin-bg); }

.btn-primary { --bs-btn-bg: var(--brand-blue); --bs-btn-border-color: var(--brand-blue); --bs-btn-hover-bg: var(--brand-blue-600); --bs-btn-hover-border-color: var(--brand-blue-600); --bs-btn-active-bg: var(--brand-blue-600); }
a { color: var(--brand-blue); }
:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 2px; }

/* Shell */
.admin-shell { display: flex; min-height: 100vh; }
.admin-sidebar { width: 250px; flex: 0 0 250px; background: var(--admin-sidebar-bg); color: var(--admin-sidebar-fg); position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.admin-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

/* Brand */
.admin-brand { padding: 18px 18px 10px; }
.admin-brand a { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; }
.admin-brand-mark { display: inline-flex; flex: 0 0 34px; align-items: center; justify-content: center; width: 34px; height: 34px; overflow: hidden; border-radius: 8px; background: var(--brand-blue); }
.admin-brand-mark img { display: block; width: 19px; height: 29px; object-fit: contain; }
.admin-brand-text { font-weight: 700; font-size: 18px; line-height: 1; }
.admin-brand-text small { display: block; font-weight: 500; font-size: 11px; opacity: .6; letter-spacing: .12em; text-transform: uppercase; margin-top: 3px; }

/* Nav */
.admin-nav { padding: 6px 10px 30px; }
.admin-nav .nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; opacity: .5; padding: 16px 12px 6px; }
.admin-nav .nav-link { color: var(--admin-sidebar-fg); border-radius: 8px; padding: 9px 12px; display: flex; align-items: center; gap: 11px; font-size: 14.5px; }
.admin-nav .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.admin-nav .nav-link.active { background: var(--brand-blue); color: #fff; }
.admin-nav .nav-link svg { flex: 0 0 18px; }

/* Topbar */
.admin-topbar { display: flex; align-items: center; gap: 12px; background: #fff; border-bottom: 1px solid var(--admin-border); padding: 10px 20px; position: sticky; top: 0; z-index: 5; }
.admin-topbar-spacer { flex: 1 1 auto; }
.admin-menu-toggle { display: none; background: none; border: 0; color: #333; }
.admin-avatar { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: rgba(43,84,245,.12); color: var(--brand-blue); font-weight: 700; }
.admin-content { padding: 24px 20px; flex: 1 1 auto; }
.admin-footer { padding: 14px 20px; color: #6b7280; font-size: 13px; border-top: 1px solid var(--admin-border); }

/* Auth pages */
.admin-auth-body { background: var(--admin-sidebar-bg); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.admin-auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 34px 30px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.admin-auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 22px; }
.admin-auth-brand .admin-brand-text { color: #10203a; }
.admin-auth-brand .admin-brand-text small { color: #6b7280; }
.admin-auth-copy { text-align: center; color: #9aa3b2; font-size: 12.5px; margin: 20px 0 0; }

/* Insights editor: a focused, semantic writing environment. */
.btn-soft-primary { color: var(--brand-blue); background: rgba(43,84,245,.10); border-color: rgba(43,84,245,.18); }
.btn-soft-success { color: #087b48; background: #e7f7ee; border-color: #b9ead0; }
.btn-soft-warning { color: #8a5a00; background: #fff5d8; border-color: #f5df9e; }
.btn-soft-danger { color: #a62d39; background: #fff0f1; border-color: #f4c7cb; }
.insight-rich-editor { border: 1px solid var(--admin-border); border-radius: 10px; overflow: hidden; background: #fff; }
.insight-editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 8px; border-bottom: 1px solid var(--admin-border); background: #fbfcff; }
.insight-editor-toolbar .btn { min-width: 32px; min-height: 31px; padding: 3px 7px; border-color: #dce1eb; color: #23314a; }
.insight-editor-toolbar .btn[aria-pressed="true"] { color: #fff; background: var(--brand-blue); border-color: var(--brand-blue); }
.insight-editor-toolbar .btn:focus-visible, .insight-editor-toolbar select:focus-visible { position: relative; z-index: 1; }
.insight-editor-select { width: 132px; min-height: 31px; font-size: 12px; }
.insight-editor-media { width: min(220px, 100%); min-height: 31px; font-size: 12px; }
.insight-editor-divider { width: 1px; height: 24px; margin: 0 2px; background: #dce1eb; }
.insight-editor-spacer { flex: 1 1 8px; }
.insight-editor-stage { background: #fff; }
.insight-editor-canvas, .insight-editor-source, .insight-editor-preview { min-height: 470px; padding: clamp(18px, 3vw, 30px); }
.insight-editor-canvas { outline: 0; color: #1c2738; font-size: 16px; line-height: 1.8; }
.insight-editor-canvas:focus { box-shadow: inset 0 0 0 2px rgba(43,84,245,.22); }
.insight-editor-source { width: 100%; border: 0; border-radius: 0; resize: vertical; font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.insight-editor-preview { color: #1c2738; font-size: 16px; line-height: 1.8; background: #fff; }
.insight-editor-canvas > :first-child, .insight-editor-preview > :first-child { margin-top: 0; }
.insight-editor-canvas p, .insight-editor-preview p { margin: 0 0 1.15em; }
.insight-editor-canvas h2, .insight-editor-preview h2 { margin: 2em 0 .55em; font-size: 1.55em; line-height: 1.25; }
.insight-editor-canvas h3, .insight-editor-preview h3 { margin: 1.65em 0 .5em; font-size: 1.25em; line-height: 1.35; }
.insight-editor-canvas h4, .insight-editor-preview h4 { margin: 1.5em 0 .5em; font-size: 1.05em; }
.insight-editor-canvas a, .insight-editor-preview a { color: var(--brand-blue); text-decoration: underline; text-underline-offset: 3px; }
.insight-editor-canvas ul, .insight-editor-canvas ol, .insight-editor-preview ul, .insight-editor-preview ol { margin: 0 0 1.25em; padding-left: 1.5em; }
.insight-editor-canvas blockquote, .insight-editor-preview blockquote { margin: 1.4em 0; padding: .3em 0 .3em 1em; border-left: 3px solid var(--brand-blue); color: #41526e; font-weight: 600; }
.insight-editor-canvas pre, .insight-editor-preview pre { overflow: auto; padding: 16px; border-radius: 8px; background: #10203a; color: #e9efff; font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.insight-editor-canvas code:not(pre code), .insight-editor-preview code:not(pre code) { padding: .12em .35em; border-radius: 4px; background: #eef1f7; color: #b1384a; font: .9em ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.insight-editor-canvas hr, .insight-editor-preview hr { margin: 2em 0; border: 0; border-top: 1px solid #dce1eb; }
.insight-editor-canvas figure, .insight-editor-preview figure { margin: 1.7em 0; }
.insight-editor-canvas img, .insight-editor-preview img { display: block; max-width: 100%; height: auto; border-radius: 8px; }
.insight-editor-canvas figcaption, .insight-editor-preview figcaption { margin-top: 8px; color: #68758b; font-size: 13px; line-height: 1.5; }
.insight-editor-canvas table, .insight-editor-preview table { display: block; width: max-content; max-width: 100%; overflow-x: auto; margin: 1.5em 0; border-collapse: collapse; }
.insight-editor-canvas th, .insight-editor-canvas td, .insight-editor-preview th, .insight-editor-preview td { min-width: 130px; padding: 9px 12px; border: 1px solid #dce1eb; text-align: left; vertical-align: top; }
.insight-editor-canvas th, .insight-editor-preview th { background: #f4f6fb; font-weight: 700; }
.insight-serp-preview { display: grid; gap: 4px; padding: 15px; border: 1px solid #dce1eb; border-radius: 9px; background: #fbfcff; }
.insight-serp-preview strong { color: #1a0dab; font-family: Arial, sans-serif; font-size: 18px; font-weight: 500; line-height: 1.3; }
.insight-serp-preview p { margin: 0; color: #4d596c; font-size: 13px; line-height: 1.55; }
.insight-empty-media { display: grid; min-height: 120px; place-items: center; border: 1px dashed #cbd3e0; border-radius: 8px; color: #78849a; font-size: 13px; text-align: center; }

/* Shared image picker: visual selection without breaking the normal form flow. */
.busicus-media-picker { min-width: 0; }
.busicus-media-picker__body { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid #dce1eb; border-radius: 10px; background: #fbfcff; }
.busicus-media-picker__preview { display: grid; flex: 0 0 78px; width: 78px; height: 62px; place-items: center; overflow: hidden; border: 1px dashed #c8d0df; border-radius: 7px; background: #f0f3f9; color: #78849a; font-size: 24px; }
.busicus-media-picker__preview img { width: 100%; height: 100%; object-fit: cover; }
.busicus-media-picker__meta { display: grid; min-width: 0; gap: 2px; font-size: 13px; }
.busicus-media-picker__meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #23314a; }
.busicus-media-picker__meta span { color: #66758b; }
.busicus-media-picker__selected { min-height: 39px; padding: 9px 11px; border-radius: 7px; background: #f3f6fb; color: #42506a; font-size: 13px; }
.busicus-media-picker__upload { padding: 10px 12px; border: 1px solid #dce1eb; border-radius: 8px; background: #fbfcff; }
.busicus-media-picker__upload summary { cursor: pointer; color: var(--brand-blue); font-weight: 600; }
.busicus-media-picker__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: min(52vh, 510px); padding: 2px; overflow: auto; }
.busicus-media-picker__card { display: grid; min-width: 0; gap: 5px; padding: 7px; overflow: hidden; border: 1px solid #dce1eb; border-radius: 8px; background: #fff; color: #23314a; text-align: left; transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.busicus-media-picker__card:hover { border-color: var(--brand-blue); box-shadow: 0 4px 12px rgba(32,57,105,.10); transform: translateY(-1px); }
.busicus-media-picker__card.is-selected { border-color: var(--brand-blue); box-shadow: 0 0 0 2px rgba(43,84,245,.18); }
.busicus-media-picker__card img { width: 100%; height: 102px; object-fit: cover; border-radius: 5px; background: #f0f3f9; }
.busicus-media-picker__card-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.busicus-media-picker__card small { color: #68758b; font-size: 11px; }

/* Media library: a clear upload workflow with an inspectable image preview. */
.admin-media-page-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 4px 0 22px; }
.admin-media-eyebrow, .admin-media-step { margin: 0 0 7px; color: var(--brand-blue); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.admin-media-page-header h1 { margin: 0; color: #14213b; font-size: clamp(27px, 2.5vw, 35px); font-weight: 750; letter-spacing: -.035em; }
.admin-media-page-header p:last-child, .admin-media-library-heading p:last-child { margin: 7px 0 0; color: #63718a; font-size: 14px; }
.admin-media-total { flex: none; padding: 8px 12px; border: 1px solid #dce4f4; border-radius: 999px; background: #fff; color: #45536b; font-size: 12px; font-weight: 700; }
.admin-media-alert { margin-bottom: 18px; border-radius: 10px; }
.admin-media-upload { overflow: hidden; margin-bottom: 36px; border: 1px solid #dce3ef; border-radius: 18px; background: #fff; box-shadow: 0 12px 34px rgba(16, 32, 58, .045); }
.admin-media-upload-head { display: flex; align-items: center; gap: 15px; padding: 23px 28px; border-bottom: 1px solid #e7ebf3; background: linear-gradient(110deg, #f8faff, #fff 72%); }
.admin-media-upload-icon { display: grid; flex: 0 0 42px; height: 42px; place-items: center; border: 1px solid #d9e3ff; border-radius: 12px; background: #edf2ff; color: var(--brand-blue); }
.admin-media-upload-icon svg { width: 21px; height: 21px; }
.admin-media-upload-head h2, .admin-media-library-heading h2 { margin: 0; color: #14213b; font-size: clamp(20px, 2vw, 25px); font-weight: 750; letter-spacing: -.025em; }
.admin-media-upload-head p:last-child { margin: 5px 0 0; color: #63718a; font-size: 13.5px; }
.admin-media-upload form { padding: 26px 28px 0; }
.admin-media-upload-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(300px, .95fr); gap: 22px; align-items: stretch; }
.admin-media-file-column { min-width: 0; }
.admin-media-dropzone { position: relative; display: flex; min-height: 266px; flex-direction: column; align-items: center; justify-content: center; gap: 9px; padding: 25px; border: 2px dashed #bccbee; border-radius: 14px; background: #f8faff; color: #1c2c48; text-align: center; cursor: pointer; transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease; }
.admin-media-dropzone:hover, .admin-media-dropzone.is-dragover { border-color: var(--brand-blue); background: #f1f5ff; box-shadow: inset 0 0 0 1px rgba(43,84,245,.1); }
.admin-media-dropzone:focus-within { outline: 3px solid rgba(43,84,245,.4); outline-offset: 3px; }
.admin-media-dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.admin-media-dropzone-icon { display: grid; width: 49px; height: 49px; place-items: center; margin-bottom: 5px; border-radius: 14px; background: #e8eeff; color: var(--brand-blue); }
.admin-media-dropzone-icon svg { width: 24px; height: 24px; }
.admin-media-dropzone strong { font-size: 15px; font-weight: 750; }
.admin-media-dropzone > span:not(.admin-media-dropzone-icon):not(.admin-media-browse) { color: #63718a; font-size: 13px; }
.admin-media-browse { margin-top: 8px; padding: 8px 14px; border: 1px solid #c8d5fb; border-radius: 8px; background: #fff; color: var(--brand-blue); font-size: 12px; font-weight: 750; }
.admin-media-file-help, .admin-media-file-status { margin: 10px 0 0; color: #63718a; font-size: 12px; line-height: 1.5; }
.admin-media-file-status { min-height: 18px; margin-top: 5px; font-weight: 600; }
.admin-media-file-status.is-error { color: #b32638; }
.admin-media-file-status.is-success { color: #15714b; }
.admin-media-preview { min-width: 0; overflow: hidden; border: 1px solid #e2e8f1; border-radius: 14px; background: #fff; }
.admin-media-preview-stage { display: flex; height: 266px; align-items: center; justify-content: center; overflow: hidden; background-color: #f5f7fa; background-image: linear-gradient(45deg, #ebeff4 25%, transparent 25%), linear-gradient(-45deg, #ebeff4 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #ebeff4 75%), linear-gradient(-45deg, transparent 75%, #ebeff4 75%); background-size: 22px 22px; background-position: 0 0, 0 11px, 11px -11px, -11px 0; }
.admin-media-preview-stage img { width: 100%; height: 100%; object-fit: contain; }
.admin-media-preview-placeholder { display: grid; justify-items: center; gap: 10px; padding: 18px; color: #8996aa; font-size: 12px; text-align: center; }
.admin-media-preview-placeholder svg { width: 29px; height: 29px; stroke-width: 1.5; }
.admin-media-preview-details { display: grid; gap: 3px; padding: 11px 14px; border-top: 1px solid #e7ebf3; }
.admin-media-preview-details > span { color: #8090aa; font-size: 10px; font-weight: 800; letter-spacing: .11em; }
.admin-media-preview-details strong { overflow: hidden; color: #26334b; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.admin-media-preview-details small { color: #738199; font-size: 11px; }
.admin-media-upload [hidden] { display: none !important; }
.admin-media-meta-heading { margin: 27px 0 18px; padding-top: 22px; border-top: 1px solid #e7ebf3; }
.admin-media-meta-heading h3 { margin: 0; color: #1c2c48; font-size: 17px; font-weight: 750; }
.admin-media-meta-heading p { margin: 4px 0 0; color: #718096; font-size: 12.5px; }
.admin-media-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 20px; }
.admin-media-field-wide { grid-column: 1 / -1; }
.admin-media-field .form-label { margin-bottom: 7px; color: #30405b; font-size: 12.5px; font-weight: 700; }
.admin-media-field .form-control { min-height: 42px; border-color: #d5deed; border-radius: 8px; font-size: 13.5px; }
.admin-media-field .form-control:focus { border-color: var(--brand-blue); box-shadow: 0 0 0 3px rgba(43,84,245,.12); }
.admin-media-field .form-control::placeholder { color: #9aa6b7; }
.admin-media-field .form-text { margin: 6px 0 0; color: #77849a; font-size: 11.5px; }
.admin-media-required { margin-left: 5px; color: #ac3143; font-size: 10.5px; font-weight: 700; }
.admin-media-optional { margin-left: 5px; color: #8592a6; font-size: 10.5px; font-weight: 500; }
.admin-media-upload-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 24px -28px 0; padding: 16px 28px; border-top: 1px solid #e7ebf3; background: #fbfcff; }
.admin-media-upload-footer p { display: flex; align-items: center; gap: 8px; max-width: 380px; margin: 0; color: #75839a; font-size: 11.5px; line-height: 1.45; }
.admin-media-upload-footer p svg { flex: 0 0 15px; width: 15px; height: 15px; }
.admin-media-submit { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 40px; padding: 8px 17px; border-radius: 8px; font-size: 12.5px; font-weight: 750; white-space: nowrap; }
.admin-media-submit svg { width: 15px; height: 15px; }
.admin-media-library-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 12px; }
.admin-media-search { position: relative; flex: 0 1 280px; min-width: 210px; }
.admin-media-search svg { position: absolute; top: 10px; left: 11px; width: 17px; height: 17px; color: #8290a8; pointer-events: none; }
.admin-media-search input { min-height: 38px; padding-left: 37px; border-color: #d9e1ee; border-radius: 9px; font-size: 13px; }
.admin-media-results { margin: 0 0 12px; color: #75839a; font-size: 12px; }
.admin-media-item-card { border-color: #dce4f0; border-radius: 12px; box-shadow: 0 5px 16px rgba(16,32,58,.025); }
.admin-media-item-thumb { flex: 0 0 88px; width: 88px; height: 88px; padding: 5px; border: 1px solid #e6ebf3; border-radius: 9px; background: #f7f9fc; object-fit: contain; }
.admin-media-item-info { min-width: 0; }
.admin-media-item-filename { max-width: 180px; overflow: hidden; margin: 3px 0; color: #33435e; text-overflow: ellipsis; white-space: nowrap; }
.admin-media-no-results, .admin-media-empty { display: grid; justify-items: center; gap: 7px; padding: 42px 20px; border: 1px dashed #cfd9e9; border-radius: 12px; background: #fbfcff; color: #78869b; text-align: center; }
.admin-media-no-results svg, .admin-media-empty svg { width: 28px; height: 28px; margin-bottom: 5px; color: #9aabc6; }
.admin-media-no-results strong, .admin-media-empty h3 { margin: 0; color: #263650; font-size: 15px; font-weight: 700; }
.admin-media-no-results span, .admin-media-empty p { margin: 0; font-size: 12.5px; }
.admin-media-no-results[hidden] { display: none; }

@media (max-width: 1050px) {
    .admin-media-upload-grid { grid-template-columns: 1fr; }
    .admin-media-preview-stage { height: 220px; }
}
@media (max-width: 640px) {
    .admin-media-page-header, .admin-media-library-heading { align-items: start; flex-direction: column; }
    .admin-media-upload-head { align-items: start; padding: 20px; }
    .admin-media-upload form { padding: 20px 20px 0; }
    .admin-media-dropzone { min-height: 230px; }
    .admin-media-fields { grid-template-columns: 1fr; }
    .admin-media-upload-footer { align-items: stretch; flex-direction: column; margin: 22px -20px 0; padding: 16px 20px; }
    .admin-media-search { width: 100%; flex-basis: auto; }
}
@media (prefers-reduced-motion: reduce) {
    .admin-media-dropzone { transition: none; }
}

@media (max-width: 820px) {
    .admin-sidebar { position: fixed; left: 0; top: 0; z-index: 1050; transform: translateX(-100%); transition: transform .2s ease; }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-menu-toggle { display: inline-flex; }
    .insight-editor-spacer { flex-basis: 100%; height: 0; }
    .insight-editor-canvas, .insight-editor-source, .insight-editor-preview { min-height: 360px; padding: 18px; }
    .busicus-media-picker__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
