/* FastAdmin integration overrides */

body {
    min-height: 100vh;
}

.site-header .header-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 10px 0 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink-2);
    font-size: 13px;
    background: var(--surface);
    max-width: 180px;
}

.site-header .header-user img {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
}

.site-header .header-user span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-header .header-user:hover {
    border-color: var(--brand-500);
    color: var(--brand-700);
}

/* mobile navigation drawer */
@media (max-width: 1024px) {
    .main-nav.is-open {
        display: flex;
        position: absolute;
        top: var(--header-h);
        left: 0;
        right: 0;
        z-index: 70;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        padding: 12px 18px 18px;
        margin: 0;
        background: var(--bg-elevated);
        border-bottom: 1px solid var(--line);
        box-shadow: var(--shadow-md);
    }

    .main-nav.is-open a {
        padding: 12px 14px;
        border-radius: 8px;
    }

    .main-nav.is-open a.is-active::after {
        display: none;
    }
}

@media (max-width: 720px) {
    .header-user span {
        display: none;
    }

    .site-header .header-user {
        padding: 0 4px;
        border: 0;
        background: transparent;
    }

    .search-trigger span:not(.kbd) {
        display: none;
    }

    .search-trigger {
        width: 36px;
        justify-content: center;
        padding: 0;
    }

    .search-trigger .kbd {
        display: none;
    }
}

/* FastAdmin forms inside the new shell */
.auth-form .help-block,
.auth-card .help-block {
    margin: 6px 0 0;
    color: #B42318;
    font-size: 12px;
    line-height: 1.5;
}

.auth-form .form-group {
    margin: 0;
}

.auth-form .has-error .input,
.auth-form .has-error .form-control {
    border-color: #B42318;
}

.auth-form .input-group {
    display: flex;
    gap: 8px;
}

.auth-form .input-group .form-control {
    flex: 1;
    min-width: 0;
}

.auth-form .input-group-btn {
    flex-shrink: 0;
}

.auth-form .input-group-btn .btn {
    height: 44px;
    white-space: nowrap;
}

.auth-form .captcha-img,
.auth-form .input-group img {
    height: 44px;
    width: auto;
    cursor: pointer;
    border-radius: 8px;
}

.auth-form .form-control {
    width: 100%;
}

.auth-form .btn-block {
    width: 100%;
}

.auth-form .checkbox,
.auth-form .radio {
    font-size: 13px;
    color: var(--ink-2);
}

.auth-form .checkbox input,
.auth-form .radio input {
    margin-right: 6px;
}

/* toast */
.tp-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 3000;
    transform: translate(-50%, 12px);
    opacity: 0;
    padding: 10px 18px;
    border-radius: 10px;
    background: rgba(20, 32, 24, .92);
    color: #fff;
    font-size: 13px;
    pointer-events: none;
    transition: opacity .2s var(--ease), transform .2s var(--ease);
}

.tp-toast.is-show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* download pagination */
.dl-pagination {
    display: flex;
    justify-content: center;
    margin-top: 24px;
}

.dl-pagination .pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.dl-pagination .pagination li a,
.dl-pagination .pagination li span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink-3);
    font-size: 13px;
    background: var(--surface);
}

.dl-pagination .pagination li.active span,
.dl-pagination .pagination li.active a {
    border-color: var(--brand-600);
    background: var(--brand-600);
    color: #fff;
}

.dl-pagination .pagination li a:hover {
    border-color: var(--brand-500);
    color: var(--brand-700);
}

/* article content generated by the admin editor */
.article-body img {
    max-width: 100%;
    height: auto;
}

.article-body .callout {
    margin: 18px 0;
}

.article-body .table-wrap {
    overflow-x: auto;
}

/* account */
.account-main .panel {
    padding: 0;
}

.account-empty {
    padding: 36px;
    text-align: center;
    color: var(--ink-3);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
}

.account-overview {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.account-stat {
    padding: 18px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.account-stat b {
    display: block;
    font-size: 24px;
    color: var(--ink);
}

.account-stat span {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--ink-3);
}

.account-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

/* dark mode fixes for FastAdmin layer content */
[data-theme="dark"] .layui-layer {
    background: var(--surface);
    color: var(--ink);
}

[data-theme="dark"] .layui-layer-title {
    background: var(--surface-2);
    color: var(--ink);
    border-bottom-color: var(--line);
}

@media (max-width: 720px) {
    .account-overview {
        grid-template-columns: 1fr;
    }
}

/* downloads page integration */
.cat-list a {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 8px;
    color: var(--ink-2);
    font-size: 13px;
    text-align: left;
    background: transparent;
    cursor: pointer;
}
.cat-list a:hover { background: var(--surface-2); color: var(--ink); }
.cat-list a.is-active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.cat-list a svg { width: 15px; height: 15px; flex-shrink: 0; }
.cat-list a .count {
    margin-left: auto;
    padding: 1px 7px;
    border-radius: 99px;
    background: var(--surface-2);
    color: var(--ink-4);
    font-size: 11px;
}
.cat-list a.is-active .count { background: #fff; color: var(--brand-700); }

.filter-chips .scope-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 99px;
    background: var(--surface);
    color: var(--ink-3);
    font-size: 12.5px;
    cursor: pointer;
    user-select: none;
}
.filter-chips .scope-chip:hover { border-color: var(--line-strong); color: var(--ink); }
.filter-chips .scope-chip.is-active { border-color: var(--brand-600); background: var(--brand-600); color: #fff; }
.filter-chips .scope-chip input { position: absolute; opacity: 0; pointer-events: none; }
.filter-chips button.scope-chip { font-family: inherit; }
.filter-chips .scope-chip.is-active input { accent-color: #fff; }

.dl-filter-extra {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px 18px;
    border-top: 1px dashed var(--line);
}
.dl-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface);
}
.dl-search svg { width: 15px; height: 15px; color: var(--ink-4); }
.dl-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; }

.dl-link { font-family: inherit; }
.dl-item-foot {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
    color: var(--ink-4);
    font-size: 11.5px;
}
.dl-permission {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0 0;
    color: var(--warn);
    font-size: 11.5px;
}
.dl-permission svg { width: 13px; height: 13px; }
.dl-muted { margin: 6px 0; color: var(--ink-4); font-size: 12.5px; }
.tag--warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }

.dl-empty { display: grid; justify-items: center; gap: 10px; padding: 54px 20px; text-align: center; }
.dl-empty h2 { margin: 0; font-size: 17px; }
.dl-empty p { margin: 0; color: var(--ink-3); font-size: 13px; }

@media (max-width: 720px) {
    .dl-filter-extra { flex-wrap: wrap; }
    .dl-search { flex-basis: 100%; }
    .dl-hero-stats { gap: 18px; }
}

/* account navigation links */
.account-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--ink-2);
    font-size: 13px;
    text-align: left;
}
.account-nav .nav-item:hover { background: var(--surface-2); color: var(--ink); }
.account-nav .nav-item.is-active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.account-nav .nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }

.account-user .avatar-lg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--brand-50);
    color: var(--brand-700);
}
.account-user .avatar-lg img { width: 100%; height: 100%; object-fit: cover; }

.auth-terms {
    margin: 2px 0 4px;
    font-size: 12.5px;
    color: var(--ink-3);
}
.auth-terms input { margin-right: 6px; }

/* FastAdmin auth reset modal */
.auth-reset-form { padding: 14px 10px 0; }
.auth-reset-form .form-group { margin-bottom: 12px; }
.auth-reset-form .control-label { font-size: 12.5px; font-weight: 500; }
.auth-reset-form .form-control { border: 1px solid var(--line); border-radius: 8px; height: 38px; }
.auth-reset-form .btn { border-radius: 8px; }

/* Bootstrap container clearfix pseudo-elements become grid items; disable in the new shell */
.container::before,
.container::after {
    content: none !important;
    display: none !important;
}

/* auth header */
.auth-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}
.auth-header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}
.auth-header .header-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-3);
    font-size: 13px;
}
.auth-header .header-back:hover { color: var(--brand-700); }
.auth-header .header-back svg { width: 15px; height: 15px; }

/* docs sidebar group links */
.nav-group > summary .nav-group-link {
    flex: 1;
    min-width: 0;
    color: inherit;
    font: inherit;
}
.nav-group > summary .nav-group-link:hover { color: var(--brand-700); }
.nav-group.is-active > summary,
.nav-group > summary .nav-group-link.is-active {
    color: var(--brand-700);
    font-weight: 600;
}

.auth-form .input-group {
    display: flex !important;
    align-items: stretch;
    width: 100%;
}
.auth-form .input-group .form-control {
    flex: 1 1 auto;
    height: 44px;
    border-radius: 10px 0 0 10px;
}
.auth-form .input-group-btn {
    display: block;
    width: 108px;
    flex: 0 0 108px;
}
.auth-form .input-group-btn img {
    display: block;
    width: 108px;
    height: 44px;
    object-fit: cover;
    border-radius: 0 10px 10px 0;
}
.auth-form .input-group-btn .btn {
    height: 44px;
    width: 100%;
    padding: 0 8px;
    font-size: 12px;
    border-radius: 0 10px 10px 0;
}

/* software detail */
.dl-hero--detail { padding-bottom: 34px; }
.dl-hero--detail h1 { max-width: 780px; }
.dl-detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 24px;
    padding-block: 28px 60px;
    align-items: start;
}
.dl-detail-card {
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
}
.dl-detail-head { display: flex; align-items: flex-start; gap: 14px; }
.dl-detail-head h2 { margin: 0 0 4px; font-size: 18px; }
.dl-detail-head p { margin: 0; color: var(--ink-3); font-size: 13px; }
.dl-detail-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 20px 0;
}
.dl-detail-actions .btn svg { width: 15px; height: 15px; }
.dl-detail-url {
    display: grid;
    gap: 6px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
    margin-bottom: 18px;
}
.dl-detail-url code { word-break: break-all; font-size: 12px; color: var(--ink-3); }
.dl-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
    padding: 18px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}
.dl-detail-grid .dl-label,
.dl-detail-specs .dl-label { display: block; margin-bottom: 10px; }
.dl-hash-line { margin: 8px 0; font-size: 12px; word-break: break-all; color: var(--ink-3); }
.dl-hash-line b { display: inline-block; min-width: 48px; color: var(--ink-2); }
.dl-detail-specs { padding: 18px 0; border-bottom: 1px solid var(--line); }
.dl-detail-content { padding-top: 20px; }
.dl-detail-layout .dl-aside { position: static; }

@media (max-width: 900px) {
    .dl-detail-layout { grid-template-columns: 1fr; }
    .dl-detail-grid { grid-template-columns: 1fr; }
}

/* profile / change password */
.account-form .profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 20px;
}
.account-form .field--full { grid-column: 1 / -1; }
.account-form .avatar-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}
.account-form .avatar-row .avatar-lg {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--surface-2);
}
.account-form .avatar-row .avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
.account-form .field-hint { margin: 6px 0 0; color: var(--ink-4); font-size: 11.5px; }
.account-form .field label { display: block; margin-bottom: 6px; font-size: 12.5px; color: var(--ink-2); }
.account-form .field .input { width: 100%; }
.account-form .account-actions { margin-top: 22px; }

@media (max-width: 720px) {
    .account-form .profile-grid { grid-template-columns: 1fr; }
    .account-form .field--full { grid-column: auto; }
}

/* remove FastAdmin fixed-navbar offset in the standalone template shell */
body {
    margin: 0 !important;
    padding-top: 0 !important;
}

/* raw editor content fallbacks */
.article-body pre {
    margin: 16px 0;
    padding: 16px;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #0F1713;
    color: #D7E3DB;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.7;
}
.article-body pre code { padding: 0; background: transparent; color: inherit; }
.article-body code {
    padding: 2px 5px;
    border-radius: 5px;
    background: var(--surface-2);
    color: var(--brand-700);
    font-family: var(--font-mono);
    font-size: .88em;
}
.article-body table {
    width: 100%;
    margin: 16px 0;
    border-collapse: collapse;
    font-size: 13px;
}
.article-body th, .article-body td {
    padding: 9px 11px;
    border: 1px solid var(--line);
    text-align: left;
}
.article-body th { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.article-body blockquote {
    margin: 16px 0;
    padding: 12px 16px;
    border-left: 3px solid var(--brand-500);
    background: var(--brand-50);
    color: var(--ink-2);
}

@media (max-width: 1024px) {
    .doc-sidebar {
        display: block !important;
        position: static;
        width: auto;
        max-height: none;
        margin-bottom: 18px;
        overflow: visible;
    }
    .doc-layout {
        display: block;
    }
}

/* docs homepage write entry */
.hero-editor {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
}
.hero-editor .hero-editor-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 36px;
    padding: 0 15px;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 9px;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}
.hero-editor .hero-editor-btn:hover {
    background: rgba(255, 255, 255, .2);
    border-color: rgba(255, 255, 255, .55);
}
.hero-editor .hero-editor-btn svg {
    width: 15px;
    height: 15px;
}
.hero-editor > span {
    color: rgba(255, 255, 255, .68);
    font-size: 12px;
}

/* download table extras */
.dl-file b a { color: inherit; text-decoration: none; }
.dl-file b a:hover { color: var(--brand-700); }
.dl-file-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.dl-file-tags .tag { height: 18px; padding: 0 6px; font-size: 10px; }
.dl-sort { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-4); white-space: nowrap; }
.dl-sort select { height: 38px; padding: 0 28px 0 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink-2); font-family: inherit; font-size: 12.5px; }
.dl-os { min-width: 0; }
.dl-os-text b { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
@media (min-width: 721px) {
    .dl-table th:nth-child(5),
    .dl-table td:nth-child(5) { width: 240px; }
}
.dl-md5 code { font-size: 10.5px; }

/* AJAX filter state */
#software-results { position: relative; transition: opacity .16s var(--ease); }
#software-results.is-loading { opacity: .45; pointer-events: none; }
#software-results.is-loading::after {
    content: "";
    position: absolute;
    top: 88px;
    left: 50%;
    width: 24px;
    height: 24px;
    margin-left: -12px;
    border: 2px solid var(--line);
    border-top-color: var(--brand-600);
    border-radius: 50%;
    animation: software-spin .7s linear infinite;
}
.dl-filter.is-loading { opacity: .65; pointer-events: none; }
@keyframes software-spin { to { transform: rotate(360deg); } }

/* inline resource detail */
.dl-main-row { cursor: pointer; }
.dl-main-row.is-open { background: color-mix(in srgb, var(--brand-50) 55%, transparent); }
.dl-title-btn {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.dl-title-btn:hover { color: var(--brand-700); }
.dl-expand-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ink-4);
    font-family: inherit;
    font-size: 11.5px;
    cursor: pointer;
}
.dl-expand-btn:hover { color: var(--brand-700); }
.dl-main-row.is-open .dl-expand-btn svg { transform: rotate(180deg); }
.dl-detail-row[hidden] { display: none; }
.dl-detail-row > td { padding: 0 !important; background: var(--surface-2); }
.dl-inline-detail {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 20px 28px;
    padding: 20px 24px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}
.dl-detail-summary { margin: 0 0 14px; color: var(--ink-2); font-size: 13px; line-height: 1.75; }
.dl-detail-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 16px; margin: 0; }
.dl-detail-meta div { min-width: 0; }
.dl-detail-meta dt, .dl-detail-file dt { margin: 0; color: var(--ink-4); font-size: 10.5px; letter-spacing: .04em; }
.dl-detail-meta dd, .dl-detail-file dd { margin: 2px 0 0; color: var(--ink); font-size: 12.5px; word-break: break-all; }
.dl-detail-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.dl-detail-file { min-width: 0; }
.dl-detail-label { display: block; margin-bottom: 8px; color: var(--brand-700); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.dl-detail-file dl { display: grid; gap: 7px; margin: 0 0 12px; }
.dl-detail-hashes { display: grid; gap: 6px; }
.dl-detail-hashes .hash-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.dl-detail-hashes .hash-row > span { flex: 0 0 44px; color: var(--ink-4); font-size: 10.5px; }
.dl-detail-hashes code { min-width: 0; overflow-wrap: anywhere; color: var(--ink-2); font-family: var(--font-mono); font-size: 10.5px; }
.dl-detail-hashes button { flex-shrink: 0; display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink-4); cursor: pointer; }
.dl-detail-hashes button:hover { color: var(--brand-700); border-color: var(--brand-500); }
.dl-detail-hashes button svg { width: 12px; height: 12px; }
.dl-detail-download { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-top: 14px; border-top: 1px dashed var(--line); }
.dl-detail-download .btn { height: 34px; }
@media (max-width: 720px) {
    .dl-inline-detail { grid-template-columns: 1fr; padding: 16px 18px; gap: 16px; }
    .dl-detail-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dl-detail-row > td { display: block !important; }
}
#software-filter-form [hidden] { display: none !important; }
