/*
 * FrontNews admin panel - Bootstrap 5 + this theme.
 */

:root {
    --admin-sidebar-width: 252px;
    --admin-bg: #f4f5f7;
    --admin-sidebar-bg: #14161b;
    --admin-sidebar-text: #aeb3bd;
    --admin-accent: #d4000e;
    --admin-accent-dark: #a8000b;
    --admin-radius: .75rem;
    --admin-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);

    --bs-primary: #d4000e;
    --bs-primary-rgb: 212, 0, 14;
    --bs-link-color: #b3000c;
    --bs-link-color-rgb: 179, 0, 12;
    --bs-link-hover-color: #8a0009;
    --bs-link-hover-color-rgb: 138, 0, 9;
    --bs-body-font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --bs-body-font-size: .9375rem;
    --bs-border-radius: .55rem;
    --bs-focus-ring-color: rgba(212, 0, 14, .2);
}

body.admin {
    background: var(--admin-bg);
    color: #1d2330;
}

.btn-primary {
    --bs-btn-bg: var(--admin-accent);
    --bs-btn-border-color: var(--admin-accent);
    --bs-btn-hover-bg: var(--admin-accent-dark);
    --bs-btn-hover-border-color: var(--admin-accent-dark);
    --bs-btn-active-bg: #8a0009;
    --bs-btn-active-border-color: #8a0009;
    --bs-btn-disabled-bg: var(--admin-accent);
    --bs-btn-disabled-border-color: var(--admin-accent);
    --bs-btn-focus-shadow-rgb: 212, 0, 14;
}

.btn-outline-primary {
    --bs-btn-color: var(--admin-accent);
    --bs-btn-border-color: var(--admin-accent);
    --bs-btn-hover-bg: var(--admin-accent);
    --bs-btn-hover-border-color: var(--admin-accent);
    --bs-btn-active-bg: var(--admin-accent-dark);
    --bs-btn-active-border-color: var(--admin-accent-dark);
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(212, 0, 14, .45);
    box-shadow: 0 0 0 .2rem rgba(212, 0, 14, .12);
}

.form-check-input:checked {
    background-color: var(--admin-accent);
    border-color: var(--admin-accent);
}

.form-check-input:focus {
    border-color: rgba(212, 0, 14, .45);
    box-shadow: 0 0 0 .2rem rgba(212, 0, 14, .12);
}

.form-label {
    font-weight: 600;
    font-size: .85rem;
    color: #3b4250;
}

.page-link {
    color: #3b4250;
}

.active > .page-link, .page-link.active {
    background-color: var(--admin-accent);
    border-color: var(--admin-accent);
}

/* ---------------- sidebar ---------------- */
.admin-sidebar {
    --bs-offcanvas-width: 272px;
    --bs-offcanvas-bg: var(--admin-sidebar-bg);
    --bs-offcanvas-color: var(--admin-sidebar-text);
    background: var(--admin-sidebar-bg);
    color: var(--admin-sidebar-text);
}

@media (min-width: 992px) {
    /* Bootstrap makes .offcanvas-lg transparent (with !important) on large screens */
    .admin-sidebar.offcanvas-lg,
    .admin-sidebar.offcanvas-lg .offcanvas-body {
        background-color: var(--admin-sidebar-bg) !important;
    }

    .admin-sidebar.offcanvas-lg .offcanvas-body {
        overflow-y: auto !important;
        flex-grow: 1;
    }

    .admin-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: var(--admin-sidebar-width);
        z-index: 1030;
        display: flex;
        flex-direction: column;
    }

    .admin-main {
        margin-left: var(--admin-sidebar-width);
    }
}

.admin-sidebar .offcanvas-body {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
    overflow-y: auto;
}

.admin-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.admin-brand a {
    display: flex;
    align-items: center;
    gap: .7rem;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: .02em;
}

.admin-brand__logo {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: .6rem;
    background: #fff;
}

.admin-brand__logo img {
    width: 28px;
    height: auto;
}

.admin-brand small {
    display: block;
    font-weight: 500;
    font-size: .72rem;
    color: #7d8391;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.admin-nav {
    padding: .75rem .75rem 1rem;
    flex: 1 1 auto;
}

.admin-nav__title {
    margin: 1.1rem .75rem .4rem;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #666c78;
}

.admin-nav a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem .75rem;
    margin-bottom: 2px;
    border-radius: .55rem;
    color: var(--admin-sidebar-text);
    text-decoration: none;
    font-size: .92rem;
    transition: background-color .15s ease, color .15s ease;
}

.admin-nav a span {
    display: inline-block;
}

.admin-nav a span::first-letter {
    text-transform: uppercase;
}

.admin-nav a .bi {
    font-size: 1.05rem;
    width: 1.2rem;
    text-align: center;
    opacity: .85;
}

.admin-nav a:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

.admin-nav a.active {
    background: var(--admin-accent);
    color: #fff;
    box-shadow: 0 6px 16px rgba(212, 0, 14, .28);
}

.admin-nav a.active .bi {
    opacity: 1;
}

.admin-user {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, .06);
}

.admin-user__name {
    color: #fff;
    font-weight: 600;
    font-size: .88rem;
    line-height: 1.2;
}

.admin-user__role {
    font-size: .75rem;
    color: #7d8391;
}

.avatar {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff4b55, #b3000c);
    color: #fff;
    font-weight: 700;
    font-size: .85rem;
    text-transform: uppercase;
}

.avatar--sm {
    width: 30px;
    height: 30px;
    font-size: .75rem;
}

/* ---------------- top bar ---------------- */
.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    gap: .75rem;
    min-height: 64px;
    padding: .6rem 1.5rem;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid #e7e9ee;
}

.admin-topbar__title {
    font-weight: 700;
    font-size: 1.05rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-topbar__title::first-letter {
    text-transform: uppercase;
}

.lang-switch .btn {
    font-weight: 600;
    font-size: .8rem;
    padding: .3rem .7rem;
}

.lang-switch .btn.active {
    background: #1d2330;
    border-color: #1d2330;
    color: #fff;
}

.admin-content {
    padding: 1.5rem;
    max-width: 1440px;
}

@media (max-width: 575.98px) {
    .admin-content {
        padding: 1rem .75rem;
    }

    .admin-topbar {
        padding: .5rem .75rem;
    }
}

/* ---------------- page elements ---------------- */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.page-head h1 {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 700;
}

.page-head h1::first-letter {
    text-transform: uppercase;
}

.page-head .text-muted {
    font-size: .88rem;
}

.card {
    --bs-card-border-color: #e7e9ee;
    --bs-card-border-radius: var(--admin-radius);
    --bs-card-inner-border-radius: calc(var(--admin-radius) - 1px);
    --bs-card-cap-bg: #fff;
    box-shadow: var(--admin-shadow);
}

.card-header {
    font-weight: 700;
    font-size: .9rem;
    padding: .85rem 1.1rem;
}

.card-header::first-letter {
    text-transform: uppercase;
}

.card-body {
    padding: 1.1rem;
}

.table {
    --bs-table-hover-bg: #f8f9fb;
    margin-bottom: 0;
    vertical-align: middle;
}

.table > thead th {
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #6b7280;
    background: #fafbfc;
    border-bottom-width: 1px;
    white-space: nowrap;
}

.table td {
    border-color: #eef0f3;
}

.table-thumb {
    width: 72px;
    height: 50px;
    object-fit: cover;
    border-radius: .45rem;
    background: #eef0f3;
}

.row-title {
    font-weight: 600;
    color: #1d2330;
    text-decoration: none;
    line-height: 1.35;
}

.row-title:hover {
    color: var(--admin-accent);
}

.row-meta {
    font-size: .8rem;
    color: #6b7280;
}

.actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .25rem;
    white-space: nowrap;
}

.actions form {
    display: inline;
    margin: 0;
}

.btn-icon {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: .5rem;
    background: transparent;
    color: #5b6270;
    transition: background-color .15s ease, color .15s ease;
}

.btn-icon:hover {
    background: #eef0f3;
    color: #1d2330;
}

.btn-icon.is-on {
    color: #16a34a;
}

.btn-icon.is-star-on {
    color: #f59e0b;
}

.btn-icon.is-danger:hover {
    background: #fde8e8;
    color: #c81e1e;
}

.badge-soft-success { background: #dcfce7; color: #166534; }
.badge-soft-secondary { background: #eef0f3; color: #4b5563; }
.badge-soft-warning { background: #fef3c7; color: #92400e; }
.badge-soft-primary { background: #fde2e3; color: #9b000a; }
.badge-soft-info { background: #e0f2fe; color: #075985; }

.badge {
    font-weight: 600;
}

.empty-state {
    padding: 3rem 1rem;
    text-align: center;
    color: #6b7280;
}

.empty-state .bi {
    font-size: 2.2rem;
    display: block;
    margin-bottom: .5rem;
    color: #c2c7d0;
}

/* stat tiles (dashboard) */
.stat {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat__icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: .75rem;
    font-size: 1.35rem;
    background: #fde2e3;
    color: var(--admin-accent);
}

.stat__value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat__label {
    font-size: .82rem;
    color: #6b7280;
}

/* sticky save bar of long forms */
.save-bar {
    position: sticky;
    bottom: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .8rem 1rem;
    margin-top: 1.25rem;
    background: rgba(255, 255, 255, .95);
    backdrop-filter: blur(8px);
    border: 1px solid #e7e9ee;
    border-radius: var(--admin-radius);
    box-shadow: 0 -6px 18px rgba(16, 24, 40, .06);
}

.form-title-input {
    font-size: 1.25rem;
    font-weight: 600;
    padding: .7rem .9rem;
}

/* image picker */
.image-drop {
    position: relative;
    display: block;
    border: 2px dashed #d6d9e0;
    border-radius: var(--admin-radius);
    background: #fafbfc;
    text-align: center;
    padding: 1.2rem;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.image-drop:hover,
.image-drop.is-dragover {
    border-color: var(--admin-accent);
    background: #fff5f5;
}

.image-drop input[type=file] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.image-drop img {
    max-width: 100%;
    max-height: 220px;
    border-radius: .5rem;
    object-fit: cover;
}

.image-drop .bi {
    font-size: 1.8rem;
    color: #9aa1ad;
}

/* tag input */
.tag-input {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    min-height: 42px;
    padding: .35rem .45rem;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    background: #fff;
    cursor: text;
    position: relative;
}

.tag-input:focus-within {
    border-color: rgba(212, 0, 14, .45);
    box-shadow: 0 0 0 .2rem rgba(212, 0, 14, .12);
}

.tag-input__tag {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .35rem .2rem .6rem;
    border-radius: 999px;
    background: #f1f2f5;
    font-size: .85rem;
}

.tag-input__tag button {
    border: 0;
    background: none;
    padding: 0 .15rem;
    line-height: 1;
    color: #6b7280;
}

.tag-input__tag button:hover {
    color: var(--admin-accent);
}

.tag-input input {
    flex: 1 1 120px;
    min-width: 120px;
    border: 0;
    outline: 0;
    padding: .2rem .25rem;
    font-size: .9rem;
}

.tag-input__suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    z-index: 20;
    max-height: 240px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e7e9ee;
    border-radius: .55rem;
    box-shadow: 0 10px 24px rgba(16, 24, 40, .12);
}

.tag-input__suggestions button {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: none;
    padding: .45rem .75rem;
    font-size: .88rem;
}

.tag-input__suggestions button:hover,
.tag-input__suggestions button.is-active {
    background: #fff1f1;
}

/* menu tree */
.tree,
.tree ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tree ul {
    margin-left: 1.6rem;
    border-left: 2px solid #eef0f3;
    padding-left: .6rem;
    min-height: 6px;
}

.tree-item__row {
    display: flex;
    align-items: center;
    gap: .6rem;
    margin: .3rem 0;
    padding: .45rem .5rem .45rem .35rem;
    background: #fff;
    border: 1px solid #e7e9ee;
    border-radius: .6rem;
    transition: box-shadow .15s ease, border-color .15s ease;
}

.tree-item__row:hover {
    border-color: #d6d9e0;
    box-shadow: var(--admin-shadow);
}

.tree-handle {
    cursor: grab;
    color: #9aa1ad;
    padding: .2rem .35rem;
}

.tree-item__name {
    font-weight: 600;
    color: #1d2330;
    text-decoration: none;
}

.tree-item__slug {
    font-size: .78rem;
    color: #8a909c;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

.sortable-ghost > .tree-item__row,
.sortable-ghost.photo-card {
    opacity: .45;
    border-style: dashed;
}

/* album */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 1rem;
}

.photo-card {
    background: #fff;
    border: 1px solid #e7e9ee;
    border-radius: var(--admin-radius);
    overflow: hidden;
    box-shadow: var(--admin-shadow);
}

.photo-card__image {
    position: relative;
    aspect-ratio: 3 / 2;
    background: #eef0f3;
    cursor: grab;
}

.photo-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-card__delete {
    position: absolute;
    top: .5rem;
    right: .5rem;
    background: rgba(255, 255, 255, .92);
}

.photo-card__body {
    padding: .6rem;
}

.upload-zone {
    display: block;
    border: 2px dashed #d6d9e0;
    border-radius: var(--admin-radius);
    background: #fff;
    text-align: center;
    padding: 2rem 1rem;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.upload-zone:hover,
.upload-zone.is-dragover {
    border-color: var(--admin-accent);
    background: #fff5f5;
}

.upload-zone .bi {
    font-size: 2rem;
    color: #9aa1ad;
}

/* texts editor */
.text-row textarea {
    min-height: 38px;
    resize: vertical;
}

.save-state {
    font-size: .78rem;
    min-width: 1.2rem;
}

/* toasts: top right, under the top bar; green = done, red = failed */
.admin-toasts {
    position: fixed;
    top: 4.5rem;
    right: 1rem;
    z-index: 1090;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: calc(100vw - 2rem);
}

.admin-toast {
    width: 380px;
    max-width: 100%;
    border-radius: .75rem;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .22);
    font-size: .95rem;
}

.admin-toast .bi {
    font-size: 1.15rem;
}

.admin-toast.showing,
.admin-toast.show {
    animation: admin-toast-in .28s cubic-bezier(.2, .8, .2, 1);
}

@keyframes admin-toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: none; }
}

/* the clicked button while its action runs */
.is-busy {
    pointer-events: none;
    opacity: .8;
}

.btn .busy-spinner {
    margin-right: .45rem;
    vertical-align: -.15em;
}

.btn.is-busy > .bi,
.btn-icon.is-busy > .bi {
    display: none;
}

.btn-icon .busy-spinner {
    width: 1rem;
    height: 1rem;
    border-width: .15em;
}

/* thin bar at the very top while a page or an action is loading */
.admin-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    height: 3px;
    background: var(--admin-accent);
    transform: scaleX(0);
    transform-origin: left center;
    opacity: 0;
    pointer-events: none;
}

.admin-progress.is-active {
    opacity: 1;
    animation: admin-progress 8s cubic-bezier(.1, .7, .2, 1) forwards;
}

.admin-progress.is-done {
    animation: none;
    transform: scaleX(1);
    opacity: 0;
    transition: transform .2s ease, opacity .3s ease .15s;
}

@keyframes admin-progress {
    0% { transform: scaleX(0); }
    8% { transform: scaleX(.4); }
    100% { transform: scaleX(.94); }
}

/* ---------------- login ---------------- */
body.admin-login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(212, 0, 14, .35), transparent 60%),
        radial-gradient(900px 500px at 110% 110%, rgba(212, 0, 14, .22), transparent 60%),
        #111318;
}

.login-card {
    width: 100%;
    max-width: 410px;
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 30px 60px rgba(0, 0, 0, .35);
    padding: 2.25rem 2rem 2rem;
    animation: login-in .6s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes login-in {
    from { opacity: 0; transform: translateY(16px) scale(.98); }
    to { opacity: 1; transform: none; }
}

.login-card__logo {
    display: block;
    height: 64px;
    margin: 0 auto 1rem;
}

.login-card h1 {
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: .25rem;
}

.login-card p.lead {
    font-size: .9rem;
    color: #6b7280;
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-card .form-control {
    padding: .7rem .9rem;
}

.login-card .btn-primary {
    padding: .7rem;
    font-weight: 600;
}

.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 2.75rem;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: .35rem;
    transform: translateY(-50%);
}

.login-footer {
    margin-top: 1.25rem;
    text-align: center;
    font-size: .8rem;
    color: rgba(255, 255, 255, .45);
}

.login-footer a {
    color: rgba(255, 255, 255, .7);
}

.min-w-0 {
    min-width: 0;
}

.nav-pills {
    --bs-nav-pills-link-active-bg: var(--admin-accent);
    --bs-nav-link-color: #3b4250;
    --bs-nav-link-hover-color: var(--admin-accent);
}

/* empty drop areas under menu items (they accept dragged sub-pages) */
.tree ul:not(:has(li)) {
    border-left-color: transparent;
    min-height: 4px;
}

.news-title-cell {
    min-width: 200px;
}

@media (min-width: 768px) {
    .news-title-cell {
        min-width: 280px;
    }
}

@media (max-width: 575.98px) {
    .table-thumb {
        width: 56px;
        height: 40px;
    }

    .page-head h1 {
        font-size: 1.25rem;
    }
}
