/* Admin utilities and components (SimpleSL-aligned) */

/* Layout helpers */
.cluster { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.gap-2 { gap: .5rem; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.inline { display: inline-block; }
.card { padding: 1.5rem; background: var(--bg-card, #f9fafb09); border-radius: .5rem; border: 2px solid var(--border-color, #e5e7eb); }
.m-0 { margin: 0; }
.mt-1 { margin-top: .25rem; }
.ml-2 { margin-left: .5rem; }
.mb-3 { margin-bottom: .75rem; }
.mb-4 { margin-bottom: 1rem; }
.mt-3 { margin-top: .75rem; }
.text-sm { font-size: .9rem; }
.text-muted, .muted { color: #6b7280; }
.text-success { color: #16a34a; }
.text-danger { color: #dc2626; }

/* Panel toolbar */
.admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: flex-start;
    background: #f9fafb;
    padding: .5rem .75rem;
    border: 1px solid #e5e7eb;
    border-radius: .5rem;
}

.admin-toolbar__group {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
}

.admin-toolbar__group--end {
    margin-left: auto;
}

.admin-toolbar label {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-size: .9rem;
    color: #374151;
    margin: 0;
}

.admin-toolbar select {
    min-width: 8rem;
    padding: .35rem .6rem;
    border: 1px solid #d1d5db;
    border-radius: .375rem;
    background: #fff;
    font: inherit;
}

.admin-toolbar select:focus {
    outline: 2px solid #0ea5e9;
    outline-offset: 1px;
}

.admin-kind-list {
    display: flex;
    align-items: center;
}

.admin-kind-list ul {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.admin-kind-list button {
    font: inherit;
    padding-inline: .65rem;
}

.admin-toolbar .btn {
    white-space: nowrap;
}

.admin-inline-form {
    display: inline-block;
    margin-left: .5rem;
}

.form-filter {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}

/* Metrics grid */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; }
.metric { background: #f8fafc; border: 1px solid #e5e7eb; border-radius: .375rem; padding: .5rem .75rem; }
.metric__value { font-weight: 600; }
.metric__label { color: #6b7280; font-size: .85rem; }

/* Issues */
.issue-group { border: 1px solid #e5e7eb; border-radius: .375rem; padding: .5rem .75rem; margin-bottom: .75rem; background: #fff; }
.issue-title { margin: 0 0 .5rem; font-size: 1rem; }
.issue-items { display: grid; gap: .5rem; }
.issue-row { display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: center; }
.issue-key code { display: inline-block; padding: .1rem .25rem; background: #f3f4f6; border-radius: .25rem; }
.issue-actions { display: inline-flex; gap: .25rem; align-items: center; }

/* Progress / Integrity */
.integrity-meter { display: grid; gap: .35rem; }
.progress-bar { width: 100%; height: .5rem; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: var(--progress, 0%); background: linear-gradient(90deg, #22c55e, #16a34a); transition: width .3s ease; }

/* Probe results */
.probe-result { background: #0b1021; color: #e5e7eb; border-radius: .375rem; padding: .5rem; border: 1px solid #1f2937; }
.probe-summary { margin-bottom: .25rem; }
.probe-result details { margin-top: .25rem; }
.probe-result pre { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: .85rem; }

/* Health badges on actions */
[data-admin-action="ok"]::before { content: '✓'; display: inline-block; margin-right: .25rem; color: #16a34a; }
[data-admin-action="missing"]::before { content: '×'; display: inline-block; margin-right: .25rem; color: #dc2626; }

/* HTMX error target highlight */
.hx-error { outline: 2px solid #dc2626; outline-offset: 2px; }

/* Anchor navigation (monitoring) */
.anchor-nav-wrap { margin: .25rem 0 1rem; }
.anchor-nav {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
}
.anchor-nav li { display: inline-flex; }
.anchor-nav a.small-anchor { text-decoration: none; border: 1px solid var(--border, #e5e7eb); border-radius: .5rem; }
.anchor-nav a.small-anchor:hover { text-decoration: none; }

/* Fragment summary boxes */
.fragments-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; margin: .5rem 0; }
.fragments-summary .stat-box { background: var(--bg-elevated, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: .5rem; padding: .5rem .75rem; }
.fragments-summary .stat-value { font-weight: 600; font-size: 1.1rem; }
.fragments-summary .stat-label { color: #6b7280; font-size: .85rem; }

/* Probes grid and cards */
.probes-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .75rem; align-items: start; }
.probe-card { background: var(--bg-elevated, #fff); border: 1px solid var(--border, #e5e7eb); border-radius: .5rem; padding: .75rem; }
/* Admin-scoped styles (loaded only on admin.* routes). */

/* Breadcrumbs: subtle divider and spacing */
.admin-scope nav.breadcrumb {
    margin: .25rem 0 .75rem;
    font-size: 0.95rem;
}

.admin-scope nav.breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    list-style: none;
    padding: 0;
    margin: 0;
}

.admin-scope nav.breadcrumb li {
    display: inline-flex;
    align-items: center;
}

.admin-scope nav.breadcrumb li+li::before {
    content: '›';
    opacity: .6;
    margin: 0 .375rem;
}

/* Aside tree: improved indicator and hover */
.admin-scope .mnl .ctx-nav details {
    border-radius: 4px;
}

.admin-scope .mnl .ctx-nav summary {
    padding: .25rem .25rem;
    border-radius: 4px;
}

.admin-scope .mnl .ctx-nav summary:hover {
    background: rgba(255, 255, 255, 0.04);
}

/* Triangle indicator (overrides base) */
.admin-scope .mnl .ctx-nav summary::before {
    content: '▸';
    color: var(--accent, #00e6ff);
    transform-origin: center;
}

.admin-scope .mnl .ctx-nav details[open] summary::before {
    transform: rotate(90deg);
}

/* Active page marker: left border and dot */
.admin-scope .mnl .ctx-nav a[aria-current="page"] {
    position: relative;
    /* Remove solid left rail; use a subtle pill highlight instead (border removed) */
    /* border-left: 2px solid var(--accent, #00e6ff); */
    padding-left: .375rem;
}

.admin-scope .mnl .ctx-nav a[aria-current="page"]::after {
    content: '';
    position: absolute;
    left: -6px;
    top: 50%;
    width: 6px;
    height: 6px;
    margin-top: -3px;
    border-radius: 50%;
    background: var(--accent, #00e6ff);
}

/* Section items */
.admin-scope .mnl .ctx-nav ul.ctx-list.small li a {
    opacity: .9;
}

.admin-scope .mnl .ctx-nav ul.ctx-list.small li a:hover {
    opacity: 1;
}

/* Highlight aside anchor when its target is active (:target based) */
/* Requires section wrappers/sections to have matching id attributes */
.admin-scope .ct section:target {
    outline: 2px solid var(--accent, #00e6ff);
    outline-offset: 2px;
}

.admin-scope .mnl .ctx-nav ul.ctx-list.small li a[href^="#"]:is(:hover, :focus) {
    text-decoration: underline;
}
/* Aside tree base styles live in public/css/aside-tree.css. Keep only admin-specific tweaks here. */
/* Brand accent color tweaks for admin UI elements */
:root {
    --accent: #00e6ff;
    --accent-contrast: #000;
}

/* Admin aside: compact-first, CSS-driven collapse/expand with hover/focus fallback
   - Default width is comfortable for reading (var(--admin-aside-width)).
   - .collapsed reduces to icons-only width; hovering or focus-within temporarily expands.
   - Minimal JS may toggle .collapsed for persistent preference; however UX works without JS.
*/
:root {
    --admin-aside-width: 200px;
    --admin-aside-compact-width: 48px;
    --admin-aside-bg: var(--bg-elevated);
    --admin-aside-color: var(--fg-body);
    --admin-aside-border: rgba(255,255,255,0.03);
    --admin-radius: 4px;

    /* Legacy DigiRelik tokens (mapped from dgrk_style / dgrk_theme) */
    --clr-accent: var(--clr-accent, #00ffff); /* cyan neon */
    --clr-accent-soft: var(--clr-accent-soft, #33ffff);
    --clr-accent-glow: var(--clr-accent-glow, #00ffffaa);
    --clr-bg-deep: var(--clr-bg-deep, #0d0d0d);
    --clr-bg-surface: var(--clr-bg-surface, #161b1d);
    --clr-border: var(--clr-border, #223035);
    --clr-text: var(--clr-text, #d5dde2);

    /* Spacing scale (bridge) */
    --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px; --sp-5:20px; --sp-6:24px;

    /* Radius bridge */
    --radius-xs:2px; --radius-sm:4px; --radius-md:8px;
}

.admin-scope aside.mnl {
    background: var(--clr-bg-surface);
    color: var(--admin-aside-color);
    width: var(--admin-aside-width);
    min-width: var(--admin-aside-width);
    max-width: var(--admin-aside-width);
    padding: .25rem;
    border-right: 1px solid var(--clr-border);
    height: calc(100vh - 2rem);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: width 120ms ease;
    font-size: .9rem; /* slightly denser */
    border-radius: var(--radius-sm);
    box-shadow: none;
}

/* Desktop sticky refinement (coexists with mobile slide-in) */
@media (min-width: 901px) {
    .admin-scope aside.mnl {
        position: sticky;
        top: calc(var(--sticky-nav, 56px) + .5rem);
        align-self: start;
        overflow: auto; /* allow internal scroll */
        max-height: calc(100vh - var(--sticky-nav, 56px) - 1rem);
    }
}

/* compact mode: icons-only */
.admin-scope aside.mnl.collapsed {
    width: var(--admin-aside-compact-width);
    min-width: var(--admin-aside-compact-width);
    max-width: var(--admin-aside-compact-width);
}

/* hover or focus-within expands the collapsed aside temporarily (CSS-only expansion)
   Supports keyboard users via focus-within on nav links. */
.admin-scope aside.mnl.collapsed:hover,
.admin-scope aside.mnl.collapsed:focus-within {
    width: var(--admin-aside-width);
}

.admin-scope aside.mnl .admin-nav-wrap {
    overflow-y: auto;
    padding: .25rem 0;
    flex: 1 1 auto;
}

/* Links: icon + label layout; labels hidden in collapsed state */
.admin-scope .admin-nav-link {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .3rem .45rem;
    border-radius: var(--radius-sm);
    color: inherit;
    text-decoration: none;
    transition: background .12s ease, color .12s ease, padding .12s ease;
}

.admin-scope .admin-nav-link .nav-icon { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; }

.admin-scope aside.mnl.collapsed .admin-nav-link { justify-content: center; padding: .32rem 0; }
.admin-scope aside.mnl.collapsed .admin-nav-link .nav-label { display: none; }

/* make the nav denser by reducing gaps inside lists and limiting max height */
.admin-scope .admin-nav-wrap { padding: .1rem 0; }
.admin-scope .admin-nav { gap: .08rem; }

/* Accordion: style details/summary to act as section headers; use minimal JS to enforce single-open */
.admin-scope .ctx-nav details {
    margin: 0.1rem 0;
    border-radius: 6px;
    overflow: visible;
}

.admin-scope .ctx-nav summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .25rem .4rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    color: rgba(199,208,224,0.8);
}

.admin-scope .ctx-nav summary::-webkit-details-marker { display: none; }

.admin-scope .ctx-nav summary::before { content: '▸'; transform-origin: center; transition: transform .12s ease; color: var(--clr-accent); font-size: .9em; }
.admin-scope .ctx-nav details[open] summary::before { transform: rotate(90deg); }

.admin-scope .ctx-nav details .ctx-list { padding-left: .6rem; }

/* limit aside internal height and show scroll inside */
.admin-scope aside.mnl .admin-nav-wrap { max-height: calc(100vh - 5.2rem); overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* even more compact labels when dense: smaller font and tighter padding */
.admin-scope aside.mnl.dense { font-size: .88rem; }
.admin-scope aside.mnl.dense .admin-nav-link { padding: .26rem .4rem; }


/* show a simple accessible tooltip when collapsed and icon is hovered/focused */
.admin-scope aside.mnl.collapsed .admin-nav-link[title] { position: relative; }
.admin-scope aside.mnl.collapsed .admin-nav-link[title]:hover::after,
.admin-scope aside.mnl.collapsed .admin-nav-link[title]:focus::after {
    content: attr(title);
    position: fixed; /* fixed so it escapes overflow hidden */
    left: calc(var(--admin-aside-compact-width) + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(20,22,24,0.96);
    color: var(--clr-text);
    padding: 5px 7px;
    border-radius: var(--radius-xs);
    font-size: .82rem;
    white-space: nowrap;
    box-shadow: 0 4px 10px rgba(0,0,0,0.18);
    z-index: 1200;
}

/* active and hover states */
.admin-scope .admin-nav-link:hover,
.admin-scope .admin-nav-link:focus { background: rgba(255,255,255,0.02); color: var(--clr-text); }
.admin-scope .admin-nav-link[aria-current="page"],
.admin-scope .admin-nav-link.active { background: rgba(0,230,255,0.06); color: var(--clr-text); font-weight: 600; /* border-left removed */ padding-left: .45rem; border-radius: var(--radius-sm); }

/* Accent mapping for compatibility with legacy classes */
.admin-scope .nav-badge { background:#132d33; color:var(--clr-accent); border-radius:10px; padding:2px 6px; border:1px solid #1d3a41; font-size:.7rem; }

/* small section header inside aside */
.admin-scope .admin-nav-section { padding: .5rem .6rem; font-size: .72rem; color: rgba(199,208,224,0.6); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }

/* responsive: mobile slides in */
@media (max-width: 900px) {
    .admin-scope aside.mnl { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform 180ms ease; z-index: 1200; }
    .admin-scope aside.mnl.open { transform: translateX(0); }
}

/* ==========================
   Changelog & Roadmap admin
   ========================== */

/* Panel focus when revealed via HTMX */
.admin-scope [data-section-panel][tabindex="-1"]:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Toolbar subtle framing and spacing */
.admin-scope .toolbar {
    gap: .5rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    border-bottom: 1px solid rgba(0,0,0,0.08);
    padding-top: .5rem;
    padding-bottom: .5rem;
}

/* Table container responsiveness */
.admin-scope .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Simple tag badge */
.admin-scope .tag {
    display: inline-block;
    padding: .1rem .4rem;
    margin: 0 .25rem .25rem 0;
    border: 1px solid rgba(127,127,127,.3);
    border-radius: .375rem;
    font-size: .75rem;
    line-height: 1.2;
    background: rgba(255,255,255,.06);
}

/* Pagination: normalize Laravel Tailwind view in admin without Tailwind */
.admin-scope nav[role="navigation"][aria-label*="Pagination"],
.admin-scope nav[role="navigation"][aria-label*="Pagination simple"] {
    margin-top: .75rem;
}

/* Summary text ("Showing 1 to 10 of 13 results") */
.admin-scope nav[role="navigation"] .text-sm {
    font-size: .875rem;
    line-height: 1.25rem;
}
.admin-scope nav[role="navigation"] .text-gray-700,
.admin-scope nav[role="navigation"] .dark\:text-gray-400 {
    color: rgba(255,255,255,.75);
}

/* Pager container behaves like a button group */
.admin-scope nav[role="navigation"] .inline-flex {
    display: inline-flex;
    gap: 0;
}

/* Pager items (anchors and spans) */
.admin-scope nav[role="navigation"] .inline-flex > a,
.admin-scope nav[role="navigation"] .inline-flex > span > a,
.admin-scope nav[role="navigation"] .inline-flex > span > span,
.admin-scope nav[role="navigation"] .inline-flex > span[class*="relative"],
.admin-scope nav[role="navigation"] .inline-flex > span[class*="relative"] > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 .5rem;
    border: 1px solid rgba(127,127,127,.35);
    background: #fff;
    color: #333;
    text-decoration: none;
    font-size: .875rem;
    line-height: 1;
}

/* Light rounding at the ends of the group */
.admin-scope nav[role="navigation"] .inline-flex > :first-child a,
.admin-scope nav[role="navigation"] .inline-flex > :first-child span[class*="inline-flex"],
.admin-scope nav[role="navigation"] .inline-flex > :first-child { border-top-left-radius: .375rem; border-bottom-left-radius: .375rem; }
.admin-scope nav[role="navigation"] .inline-flex > :last-child a,
.admin-scope nav[role="navigation"] .inline-flex > :last-child span[class*="inline-flex"],
.admin-scope nav[role="navigation"] .inline-flex > :last-child { border-top-right-radius: .375rem; border-bottom-right-radius: .375rem; }

/* Active page */
.admin-scope nav[role="navigation"] [aria-current="page"] .inline-flex,
.admin-scope nav[role="navigation"] [aria-current="page"] > span {
    background: var(--accent);
    color: var(--accent-contrast);
    border-color: var(--accent);
}

/* Disabled */
.admin-scope nav[role="navigation"] [aria-disabled="true"] .inline-flex,
.admin-scope nav[role="navigation"] [aria-disabled="true"] > span {
    opacity: .5;
    cursor: not-allowed;
}

/* Hover/focus on links */
.admin-scope nav[role="navigation"] a:hover { background: #f6f6f6; }
.admin-scope nav[role="navigation"] a:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Compact header stats badges alignment */
.admin-scope #changelog-stats .badge,
.admin-scope #roadmap-stats .badge {
    vertical-align: middle;
}

/* Header cards spacing */
.admin-scope .card.card--elevated.mb-3 > .toolbar { margin-top: .5rem; }
