/* ===========================================================
   Admin Panel — Dark Theme
   =========================================================== */

/* ---- CSS Custom Properties ---- */
:root {
    --sidebar-width: 240px;
    --topbar-height: 56px;
    --sidebar-bg: #161616;
    --sidebar-border: #252525;
    --sidebar-link-color: #999;
    --sidebar-link-hover: #fff;
    --sidebar-active-bg: rgba(13, 110, 253, 0.13);
    --sidebar-active-border: #0d6efd;
    --topbar-bg: #1a1a1a;
    --topbar-border: #252525;
    --admin-accent: #0d6efd;
    --font-admin: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ---- Bootstrap dark mode variable overrides ---- */
[data-bs-theme="dark"] {
    --bs-body-bg: #111111;
    --bs-body-color: #ddd;
    --bs-secondary-bg: #1e1e1e;
    --bs-tertiary-bg: #1a1a1a;
    --bs-card-bg: #1c1c1c;
    --bs-border-color: #2a2a2a;
    --bs-border-color-translucent: rgba(255, 255, 255, 0.08);
    --bs-input-bg: #1e1e1e;
    color-scheme: dark;
}

/* ---- Base ---- */
body.admin-body {
    font-family: var(--font-admin);
    font-size: 0.875rem;
    background: #111111;
    color: #ddd;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-admin);
}

/* ---- Login Page ---- */
.admin-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.admin-login-page > * {
    width: 100%;
}

.admin-login-page .card {
    border: 1px solid #2a2a2a;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.admin-login-page h2 {
    font-size: 1.4rem;
    font-weight: 600;
}

/* ---- Admin Layout ---- */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.25s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Sidebar brand */
.sidebar-brand {
    padding: 1.1rem 1.25rem 1rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.975rem;
    letter-spacing: 0.02em;
}

.sidebar-brand-link:hover {
    color: #fff;
}

.sidebar-brand-link > i {
    color: var(--admin-accent);
    font-size: 1.05rem;
    flex-shrink: 0;
}

.sidebar-brand-logo {
    max-height: 36px;
    max-width: 160px;
    object-fit: contain;
}

/* Sidebar nav */
.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
}

.sidebar-link,
.sidebar-group-toggle {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    padding: 0.575rem 1.25rem;
    color: var(--sidebar-link-color);
    text-decoration: none;
    background: none;
    border: none;
    border-left: 3px solid transparent;
    font-family: var(--font-admin);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
    text-align: left;
    line-height: 1.4;
}

.sidebar-link:hover,
.sidebar-group-toggle:hover {
    color: var(--sidebar-link-hover);
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-link.active {
    color: #fff;
    background: var(--sidebar-active-bg);
    border-left-color: var(--sidebar-active-border);
}

.sidebar-link > i,
.sidebar-group-toggle > i:first-child {
    width: 1rem;
    text-align: center;
    flex-shrink: 0;
    font-size: 0.9rem;
}

/* Sidebar group (collapsible) */
.sidebar-chevron {
    transition: transform 0.2s ease;
    font-size: 0.65rem;
    margin-left: auto;
    flex-shrink: 0;
}

.sidebar-group.is-open .sidebar-chevron {
    transform: rotate(180deg);
}

.sidebar-group-toggle.active {
    color: #ccc;
}

.sidebar-submenu {
    display: none;
    background: rgba(0, 0, 0, 0.15);
    padding: 0.2rem 0;
}

.sidebar-submenu.show {
    display: block;
}

.sidebar-sublink {
    display: block;
    padding: 0.45rem 1.25rem 0.45rem 3rem;
    color: #777;
    text-decoration: none;
    font-size: 0.825rem;
    font-weight: 400;
    border-left: 3px solid transparent;
    transition: color 0.15s ease, background 0.15s ease;
    white-space: nowrap;
}

.sidebar-sublink:hover {
    color: #bbb;
    background: rgba(255, 255, 255, 0.04);
}

.sidebar-sublink.active {
    color: #fff;
    background: rgba(13, 110, 253, 0.1);
    border-left-color: var(--admin-accent);
}

/* Sidebar footer */
.sidebar-footer {
    flex-shrink: 0;
    padding: 0.5rem 0;
    border-top: 1px solid var(--sidebar-border);
}

.sidebar-link-external {
    opacity: 0.65;
}

.sidebar-link-external:hover {
    opacity: 1;
}

.sidebar-version {
    font-size: .65rem;
    color: var(--sidebar-muted, #444);
    text-align: center;
    padding: .3rem 0 .15rem;
    letter-spacing: .04em;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1039;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* ---- Main wrapper ---- */
.admin-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* ---- Top bar ---- */
.admin-topbar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 0.75rem;
    z-index: 900;
    flex-shrink: 0;
}

.topbar-toggle {
    display: none;
    background: none;
    border: none;
    color: #888;
    font-size: 1.05rem;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: 5px;
    transition: color 0.15s ease, background 0.15s ease;
    flex-shrink: 0;
}

.topbar-toggle:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.topbar-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #e0e0e0;
    letter-spacing: 0.01em;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.topbar-username {
    font-size: 0.8rem;
    color: #666;
}

.topbar-logout {
    color: #555;
    text-decoration: none;
    font-size: 0.975rem;
    padding: 0.35rem 0.5rem;
    border-radius: 5px;
    transition: color 0.15s ease, background 0.15s ease;
    line-height: 1;
}

.topbar-logout:hover {
    color: #dc3545;
    background: rgba(220, 53, 69, 0.12);
}

/* ---- Content area ---- */
.admin-content {
    flex: 1;
    padding: 1.75rem 2rem 2.5rem;
}

/* ---- Page headings ---- */
.admin-content h1 {
    font-size: 1.4rem;
    font-weight: 600;
    color: #eee;
}

/* ---- Cards ---- */
.card {
    border-color: #252525 !important;
}

.card-header {
    border-bottom-color: #252525 !important;
    background: rgba(255, 255, 255, 0.03) !important;
}

.card-footer {
    border-top-color: #252525 !important;
    background: rgba(255, 255, 255, 0.02) !important;
}

/* ---- Dashboard stat cards ---- */
.stat-card {
    border: 1px solid #252525;
    border-radius: 10px;
    padding: 1.5rem;
    background: #1c1c1c;
    transition: border-color 0.2s ease, transform 0.15s ease;
}

.stat-card:hover {
    border-color: #3a3a3a;
    transform: translateY(-1px);
}

.stat-card .stat-icon {
    font-size: 1.6rem;
    margin-bottom: 0.75rem;
    display: block;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.35rem;
    color: #fff;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0;
}

a .stat-card {
    cursor: pointer;
}

a .stat-card:hover {
    border-color: #444;
}

/* ---- List groups (dark theme) ---- */
.list-group-item {
    color: #e0e0e0;
    background-color: transparent;
    border-color: #252525;
}

.list-group-item-action:hover,
.list-group-item-action:focus {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.05) !important;
}

.list-group-item-action:active {
    background-color: rgba(255, 255, 255, 0.08) !important;
}

/* ---- Tables ---- */
.table {
    --bs-table-striped-bg: rgba(255, 255, 255, 0.025);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.04);
    border-color: #252525;
}

.table > :not(caption) > * > * {
    border-bottom-color: #252525;
}

/* ---- Forms ---- */
.form-control:focus,
.form-select:focus {
    border-color: rgba(13, 110, 253, 0.5);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

/* Code/script textareas */
textarea.font-monospace {
    font-size: 0.8rem;
    line-height: 1.6;
    tab-size: 4;
}

/* ---- Nav tabs (settings page) ---- */
.nav-tabs {
    border-color: #2a2a2a;
    gap: 0.25rem;
}

.nav-tabs .nav-link {
    color: #777;
    border-color: transparent;
    border-bottom-color: transparent;
    border-radius: 6px 6px 0 0;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: color 0.15s ease, background 0.15s ease;
}

.nav-tabs .nav-link:hover {
    color: #ccc;
    background: rgba(255, 255, 255, 0.04);
    border-color: transparent;
    border-bottom-color: transparent;
}

.nav-tabs .nav-link.active {
    color: #fff;
    background: #1c1c1c;
    border-color: #2a2a2a #2a2a2a #1c1c1c;
}

.tab-content > .tab-pane > .card {
    border-top-left-radius: 0;
}

/* ---- Alerts ---- */
.alert-dismissible .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* ---- Badges ---- */
.badge.bg-secondary {
    background-color: #3a3a3a !important;
    color: #bbb !important;
}

.badge.bg-light {
    background-color: #2a2a2a !important;
    color: #aaa !important;
}

/* ---- Buttons ---- */
.btn-outline-primary:hover,
.btn-outline-success:hover,
.btn-outline-secondary:hover,
.btn-outline-danger:hover {
    color: #fff !important;
}

/* ---- Content item cards (manage pages) ---- */
.item-card {
    background: #1c1c1c;
    border: 1px solid #252525;
    border-radius: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.item-card:hover {
    border-color: #3a3a3a;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.item-card .item-card-img {
    height: 170px;
    object-fit: cover;
    width: 100%;
    display: block;
}

.item-card .item-card-img-placeholder {
    height: 170px;
    background: #222;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #444;
    font-size: 0.8rem;
}

.item-card-body {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.item-card-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #eee;
    margin-bottom: 0.35rem;
    line-height: 1.3;
}

.item-card-meta {
    font-size: 0.775rem;
    color: #666;
    line-height: 1.5;
    flex: 1;
}

.item-card-meta i {
    width: 0.9rem;
    text-align: center;
    color: #555;
}

.item-card-badges {
    margin-top: 0.6rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.item-card-footer {
    padding: 0.6rem 1rem;
    border-top: 1px solid #252525;
    background: rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
    align-items: center;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }

    .admin-sidebar.is-open {
        transform: translateX(0);
        box-shadow: 6px 0 24px rgba(0, 0, 0, 0.6);
    }

    .admin-main {
        margin-left: 0;
    }

    .topbar-toggle {
        display: block;
    }

    .admin-content {
        padding: 1.25rem 1rem 2rem;
    }

    .admin-topbar {
        padding: 0 1rem;
    }

    .topbar-username {
        display: none;
    }
}

@media (min-width: 769px) {
    .topbar-toggle {
        display: none !important;
    }
}
