/*
  CSS Custom Properties ΓÇö Layout
*/
:root {
    --sidebar-width: 220px;
    --sidebar-collapsed-width: 60px;
    --header-height: 56px;
    --sidebar-bg: #23282d;
    --sidebar-border: #292f35;
    --sidebar-text: #aaa;
    --sidebar-hover-bg: #202429;
    --sidebar-active-bg: rgba(255, 159, 10, 0.10);
    --sidebar-active-border: #ff9f0a;
    --sidebar-active-color: #ff9f0a;
    --header-bg: #1c2025;
    --header-border: #292f35;
}

/*
  Admin Layout ΓÇö CSS Grid
*/
.admin-layout {
    display: grid;
    grid-template-areas: "header header" "sidebar main";
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--header-height) minmax(0, 1fr);
    height: 100vh;
    overflow: hidden;
}

/*
  Admin Header
*/
.admin-header {
    grid-area: header;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    z-index: 20;
    flex-shrink: 0;
}

.admin-header-start {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-header-end {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto; /* Push to the right */
    justify-content: flex-end;
}

.admin-header-user {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: #888;
    white-space: nowrap;
    padding-left: 14px;
    border-left: 1px solid var(--header-border);
    margin-left: 4px;
}

.admin-header-user img.gravatar {
    border-radius: 50%;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.admin-header-user .welcome {
    color: #aaa;
}

.admin-brand {
    font-family: 'Courier Prime', 'Courier New', monospace;
    font-size: 18px;
    font-weight: 700;
    color: #f0f0f0;
    text-decoration: none;
    letter-spacing: -0.5px;
}

/* Dark mode specific brand color */
body.moon .admin-brand {
    color: #ffffff;
}

.admin-brand-dot {
    color: #ff9f0a; /* Always orange */
}

/* Dark mode specific brand color */
body.moon .admin-brand {
    color: #ffffff;
}

.admin-brand-dot {
    color: #ff9f0a; /* Always orange */
}

.admin-brand:hover {
    color: #ffffff;
    text-decoration: none;
}

.admin-quote {
    color: #777;
    font-style: oblique;
    font-size: 11px;
    margin-right: 4px;
}

/* Settings dropdown container ΓÇö similar to language dropdown */
.settings-dropdown {
    display: inline-block;
    position: relative;
}

.settings-dropdown .btn-gear {
    position: relative;
    z-index: 1001;
}

.settings-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    margin: 0;
    padding: 8px 0;
    list-style: none;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1100;
}

.settings-dropdown-menu::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 12px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #fff;
}

.settings-dropdown-menu::after {
    content: '';
    position: absolute;
    top: -7px;
    right: 11px;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 7px solid #dee2e6;
    z-index: -1;
}

.settings-dropdown.show .settings-dropdown-menu {
    display: block;
}

.settings-dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: #333;
    text-decoration: none;
    font-size: 12px;
    transition: background 0.15s, color 0.15s;
}

.settings-dropdown-menu .dropdown-item:hover {
    background: #f8f9fa;
    color: #000;
}

.settings-dropdown-menu .dropdown-item i {
    width: 14px;
    font-size: 12px;
    color: #6c757d;
    flex-shrink: 0;
}

/* Mobile hamburger toggle ΓÇö three-dash icon */
.sidebar-mobile-toggle {
    display: none;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 4px;
    padding: 6px 8px;
    cursor: pointer;
    color: #aaa;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.sidebar-mobile-toggle:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.sidebar-mobile-toggle .navbar-toggler-icon {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    position: relative;
}

.sidebar-mobile-toggle .navbar-toggler-icon::before,
.sidebar-mobile-toggle .navbar-toggler-icon::after {
    content: '';
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    position: absolute;
    left: 0;
}

.sidebar-mobile-toggle .navbar-toggler-icon::before { top: -6px; }
.sidebar-mobile-toggle .navbar-toggler-icon::after  { top: 6px; }

/*
  Admin-right nav in header (Profile, Settings)
*/
.admin-header-nav-wrapper {
    margin-left: auto;
    display: flex;
    align-items: center;
}

/* User wants logout align right and other two left in header? */
/* Wait, user said "i assked the logout align right and the other two left" */
/* The previous fix in admin.layout.css for .admin-header-end used justify-content: flex-end */
/* But in the template, we have: Quote, Settings, Moon, Language, Nav(Profile/Logout) */
/* The Nav is usually a dropdown. */

/* Sidebar footer nav - horizontal layout */
.admin-sidebar-footer-nav {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    justify-content: flex-start; /* Profile and Settings left-aligned */
    width: 100% !important;
    padding: 0 4px; /* Add padding */
    gap: 4px;
    flex-wrap: nowrap;
    margin: 0;
}

.admin-sidebar-footer-nav .nav-one {
    width: auto !important;
    flex: 0 0 auto;
    margin: 0;
}

/* Force Logout to be right-aligned */
.admin-sidebar-footer-nav .nav-page-logout {
    margin-left: auto !important;
}

/* Collapsed state: Stack vertically */
body.sidebar-collapsed .admin-sidebar-footer {
    flex-direction: column;
    padding: 0;
}

body.sidebar-collapsed .admin-sidebar-footer-nav {
    flex-direction: column !important;
    padding: 0;
    gap: 0;
    width: 100% !important;
}

body.sidebar-collapsed .admin-sidebar-footer-nav .nav-one {
    width: 100% !important; /* Full width items when stacked */
    justify-content: center;
    display: flex;
}

body.sidebar-collapsed .admin-sidebar-footer-nav .nav-page-logout {
    margin-left: 0 !important; /* Reset margin in collapsed mode */
}

/* Ensure items look good in collapsed mode */
body.sidebar-collapsed .admin-sidebar-footer-nav .nav-one > a {
    justify-content: center;
    width: 100%;
    border-radius: 0;
    padding: 12px 0; /* Add vertical padding for hit area */
}

/* Fix gravatar centering in collapsed mode */
body.sidebar-collapsed .admin-sidebar-footer-nav .nav-one > a .gravatar-sidebar {
    display: inline;
}

.admin-sidebar-footer-nav .nav-one > a,
.admin-sidebar-footer-nav .nav-one > a:hover {
    padding: 0;
    justify-content: center;
    align-items: center;
    width: 32px; /* Fixed width for icon-only feel */
    height: 32px;
    border-radius: 6px;
    display: flex;
    text-decoration: none !important;
    overflow: visible;
}

.admin-sidebar-footer-nav .nav-one.is-open > a,
.admin-sidebar-footer-nav .nav-one.is-open > a:hover {
    background: var(--admin-surface-3);
}

/* Hide text in footer nav items (Profile, Settings, Logout) - RESTORED */
.admin-sidebar-footer-nav .nav-one > a .nav-text {
    display: none !important;
}

/* Ensure icons/gravatar are visible and centered */
.admin-sidebar-footer-nav .nav-one > a .fas,
.admin-sidebar-footer-nav .nav-one > a .gravatar-sidebar {
    margin: 0 !important;
    font-size: 14px;
    display: block;
}

/* Remove special pushing for logout to treat it like a normal item in the flex row */
.admin-sidebar-footer-nav .nav-one.nav-page-logout {
    margin-left: 0; 
}

/* User asked to replace profile button icon with gravatar */
/* If profile item has both, hide the icon span if img exists? */
/* TPLMenu logic handles this: if img tag, it prints it. Else span class. */
/* So duplicate icon implies something else adds an icon. */
/* Maybe CSS adds :before? */
/* I don't see :before adding icon on .nav-one > a. */

/* Ensure gravatar in footer menu is circular */
.admin-sidebar-footer-nav .gravatar-sidebar {
    border-radius: 50%;
    width: 24px;
    height: 24px;
}

.admin-sidebar-footer-nav .nav-page-notifications > a {
    position: relative;
}

.admin-notification-trigger-badge {
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    margin-left: 0;
    white-space: nowrap;
}

.admin-header-nav {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 2px;
    padding: 0;
    margin: 0;
    list-style: none;
}

.admin-header-nav .nav-one > a {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    color: #aaa;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}

.admin-header-nav .nav-one > a:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
}

.admin-header-nav .nav-one.active > a {
    color: var(--sidebar-active-color);
}

.admin-header-nav .nav-one > a .nav-text {
    display: none;
}

.admin-header-nav .nav-one > a .fas {
    display: inline-block !important;
    font-size: 16px;
    margin: 0;
}

/* Dropdown falls down from header */
.admin-header-nav .nav-one {
    position: relative;
}

.admin-header-nav .nav-one .dropdown-menu {
    display: none;
    position: absolute !important;
    top: calc(100% - 12px) !important;
    right: -6px;
    left: auto !important;
    min-width: 180px;
    margin: 0;
    padding: 3px 0;
    list-style: none;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1100;
}

.admin-header-nav .nav-one.show .dropdown-menu {
    display: block;
}

.admin-header-nav .nav-one .dropdown-menu::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 10px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #fff;
}

.admin-header-nav .nav-one .dropdown-menu::after {
    content: '';
    position: absolute;
    top: -7px;
    right: 9px;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 7px solid #dee2e6;
    z-index: -1;
}

.admin-header-nav .nav-one .dropdown-menu .nav-two > a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    color: #333;
    text-decoration: none;
    font-size: 12px;
    transition: background 0.15s, color 0.15s;
}

.admin-header-nav .nav-one .dropdown-menu .nav-two > a:hover,
.admin-header-nav .nav-one .dropdown-menu .nav-two.sactive > a {
    background: #f8f9fa;
    color: #000;
}

.admin-header-nav .nav-one .dropdown-menu .nav-two > a .fas {
    width: 16px;
    font-size: 12px;
    color: #6c757d;
    flex-shrink: 0;
}

.admin-header-nav .nav-one .dropdown-menu .nav-two > a .nav-text {
    flex: 1;
}

.admin-header-nav .nav-one .dropdown-menu .nav-two.sactive > a::after {
    content: '\2713';
    margin-left: auto;
    color: #198754;
    font-size: 12px;
    line-height: 1;
}

/* Hide Bootstrap dropdown caret on all admin navs */
.admin-header-nav .dropdown-toggle::after,
nav.navbar.navbar-dark .dropdown-toggle::after {
    display: none;
}

/*
  Admin Sidebar Backdrop (mobile overlay)
*/
.admin-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1035;
}

/*
  Admin Sidebar
*/
nav.navbar.navbar-dark.admin-sidebar {
    grid-area: sidebar;
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    border-radius: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
    z-index: 15;
}

.admin-sidebar-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: #3a4255 transparent;
}

.admin-sidebar-body::-webkit-scrollbar { width: 4px; }
.admin-sidebar-body::-webkit-scrollbar-track { background: transparent; }
.admin-sidebar-body::-webkit-scrollbar-thumb { background: #3a4255; border-radius: 2px; }

.admin-sidebar-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--sidebar-border);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Align start to put toggle on left */
    position: relative;
}

/* Footer nav dropdown opens upward */
body div ul.admin-sidebar-footer-nav li.nav-one ul.dropdown-menu {
    position: absolute !important;
    bottom: calc(100% + 4px) !important;
    top: auto !important;
    left: 0 !important;
    min-width: 180px;
    padding: 5px 0;
    border-radius: 10px;
    background: var(--admin-footer-dropdown-bg);
    backdrop-filter: var(--admin-chrome-backdrop);
    -webkit-backdrop-filter: var(--admin-chrome-backdrop);
    border: 1px solid var(--admin-border-soft);
    box-shadow: var(--admin-float-shadow);
    display: none;
    z-index: 1200;
}
.admin-sidebar-footer-nav .nav-one.show .dropdown-menu {
    display: block !important;
}
body div ul.admin-sidebar-footer-nav li.nav-page-settings ul.dropdown-menu {
    background: var(--admin-footer-dropdown-bg) !important;
}
body div ul.admin-sidebar-footer-nav li.nav-page-profile ul.dropdown-menu {
    background: var(--admin-footer-dropdown-bg) !important;
}
.admin-sidebar-footer-nav .dropdown-menu .nav-two > a {
    padding: 8px 16px 8px 36px;
    font-size: 12px;
    color: var(--admin-text-soft);
    border-left: 3px solid transparent;
}
.admin-sidebar-footer-nav .dropdown-menu .nav-two > a:hover,
.admin-sidebar-footer-nav .dropdown-menu .nav-two.sactive > a {
    background: var(--admin-surface-3);
    color: var(--admin-text-main);
    border-left-color: var(--admin-accent-strong);
}
.admin-sidebar-footer-nav .dropdown-menu .nav-two .fas {
    width: 18px;
    margin-right: 8px;
    font-size: 12px;
    opacity: 0.7;
}

.admin-notification-balloon {
    position: absolute;
    left: 12px;
    bottom: calc(100% + 10px);
    width: min(360px, calc(100vw - 32px));
    z-index: 1250;
    display: none;
}

.admin-notification-balloon.is-open {
    display: block;
}

body.sidebar-collapsed .admin-notification-balloon {
    left: 8px;
}

@media (max-width: 1199px) {
    .admin-notification-balloon {
        left: 12px;
        right: 12px;
        width: auto;
        max-width: 360px;
    }
}

.admin-sidebar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
    width: 100%;
}

.admin-sidebar-user em {
    display: flex;
    align-items: center;
    gap: 7px;
    font-style: normal;
    color: #888;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-sidebar-user em img {
    flex-shrink: 0;
    border-radius: 50%;
}

.admin-sidebar-user em .welcome {
    overflow: hidden;
    text-overflow: ellipsis;
}

/*
  Sidebar navigation items
*/
nav.navbar.navbar-dark.admin-sidebar .navbar-nav {
    width: 100%;
    display: block;
    margin: 0;
    padding: 0;
    list-style: none;
}

nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one {
    width: 100%;
    position: relative;
}

nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one > a {
    display: flex;
    align-items: center;
    padding: 7px 14px;
    border-left: 3px solid transparent;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 400;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
    overflow: hidden;
}

nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one > a:hover {
    background: var(--sidebar-hover-bg);
    color: #ccc;
    text-decoration: none;
}

nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one.active > a,
nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one.show > a {
    background: var(--sidebar-active-bg);
    border-left-color: var(--sidebar-active-border);
    color: var(--sidebar-active-color);
}

/* Always show FA icons in sidebar */
nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one .fas {
    display: inline-block !important;
    width: 22px;
    font-size: 14px;
    margin-right: 10px;
    flex-shrink: 0;
    opacity: 0.75;
}

nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one.active .fas {
    opacity: 1;
}

nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one > a.dropdown-toggle::after {
    display: none !important;
}

nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one > a .caret {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 10px;
    opacity: 0.5;
    transition: transform 0.2s;
}

nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one.show > a .caret {
    transform: rotate(90deg);
    opacity: 0.8;
}

/* Submenus: inline expanded in sidebar */
nav.navbar.navbar-dark.admin-sidebar .dropdown-menu {
    box-shadow: none;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0; /* Remove padding for tighter fit */
    margin: 0;
    width: 100%;
    float: none;
}

nav.navbar.navbar-dark.admin-sidebar .nav-one.show > .dropdown-menu,
nav.navbar.navbar-dark.admin-sidebar .nav-one.open > .dropdown-menu {
    display: block;
}

nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two > a {
    display: flex;
    align-items: center;
    padding: 8px 14px 8px 36px; /* Increased left padding for hierarchy */
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 12px;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s;
    line-height: 1.2;
}

nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two > a:hover,
nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two.sactive > a {
    background: var(--sidebar-hover-bg);
    color: #ccc;
    border-left-color: rgba(255, 159, 10, 0.4);
}

nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two .fas {
    display: inline-block !important;
    width: 18px;
    font-size: 12px;
    margin-right: 8px;
    flex-shrink: 0;
    opacity: 0.6;
}

/* Sidebar toggle button (arrow) - Floating 50% inside/outside */
.sidebar-toggle {
    display: none; /* Desktop only via media query below */
    position: absolute;
    top: 20px; /* Align with Home item (approx padding top 8px + half item height) */
    right: 12px;
    width: 24px;
    height: 24px;
    background: var(--admin-surface-1); /* Needs background to hide line behind it */
    border: 1px solid var(--admin-border-strong);
    padding: 0;
    color: var(--admin-text-soft);
    cursor: pointer;
    transition: color 0.2s, background 0.2s, right 0.2s;
    font-size: 10px;
    /* Flex alignment to ensure icon is centered */
    display: flex; 
    align-items: center;
    justify-content: center;
    
    border-radius: 50%; /* Circle shape as requested originally ("make it a little circle") */
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sidebar-toggle:hover {
    background: var(--admin-surface-2);
    color: var(--admin-text-main);
    border-color: var(--admin-accent);
}

body.moon .sidebar-toggle {
    background: var(--admin-surface-2);
    border-color: var(--admin-border-strong);
}

body.moon .sidebar-toggle:hover {
    background: var(--admin-surface-3);
}

/* Fix z-index stacking context */
nav.navbar.navbar-dark.admin-sidebar {
    overflow: visible !important; /* Allow button to hang out */
}

.sidebar-toggle i {
    transition: transform 0.3s ease;
}

/* Default state (expanded): arrow points left (to collapse) */
.sidebar-toggle .fa-chevron-left {
    display: block;
}
.sidebar-toggle .fa-chevron-right {
    display: none;
}

/* Collapsed state: arrow points right (to expand) */
/* Increased specificity to ensure this applies */
body.sidebar-collapsed .sidebar-toggle .fa-chevron-left,
body.sidebar-collapsed nav .sidebar-toggle .fa-chevron-left {
    display: none !important;
}
body.sidebar-collapsed .sidebar-toggle .fa-chevron-right,
body.sidebar-collapsed nav .sidebar-toggle .fa-chevron-right {
    display: block !important;
}

.sidebar-toggle-text {
    display: none; /* Hide text, icon only */
}

/* Show collapse toggle on desktop only */
@media (min-width: 1200px) {
    .sidebar-toggle {
        display: flex;
    }
    .sidebar-mobile-toggle {
        display: none !important;
    }
}

/*
  Underheader ΓÇö breadcrumbs strip (sticky inside .admin-main)
*/
.underheader {
    position: sticky;
    top: 0;
    padding: 5px 0;
    z-index: 5;
}

.nav-hide .underheader {
    display: none;
}

.underheader .container {
    max-width: 1420px;
}

.underheader .container .pull-left,
.underheader .container .float-start {
    font-size: 11px;
    padding: 3px 0;
}

.underheader .breadcrumbs {
    padding: 0 0 0 7px;
}

.underheader .breadcrumbs ul {
    margin: 0;
    padding: 0;
}

.underheader .breadcrumbs ul li {
    list-style: none;
    display: inline-block;
    color: #555;
    font-size: 11px;
}

.underheader .breadcrumbs ul li:not(:last-child):after {
    content: '\00bb';
    display: inline-block;
    padding: 0 5px;
    font-size: 12px;
    position: relative;
    top: -1px;
}

.underheader .breadcrumbs ul li a {
    color: #777;
}

/*
  Admin Main ΓÇö scrollable content column
*/
main.admin-main {
    grid-area: main;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    background: #fefefe;
    min-height: 0;
}

.wrap {
    position: relative;
    padding: 24px 20px 40px;
    flex: 1;
}

/*
  Collapsed Sidebar (desktop: icon-only, 60px)
*/
@media (min-width: 1200px) {
    body.sidebar-collapsed .admin-layout {
        grid-template-columns: var(--sidebar-collapsed-width) 1fr;
    }
}

body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar {
    overflow: visible;
}

body.sidebar-collapsed .sidebar-toggle .sidebar-toggle-text {
    display: none;
}


body.sidebar-collapsed .admin-sidebar-footer {
    justify-content: center;
    padding: 8px 0;
}

body.sidebar-collapsed .sidebar-toggle {
    right: -25px;
    width: 18px;
    height: 18px;

}

body.sidebar-collapsed .admin-sidebar-body {
    padding-top: 15px;
}

body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one > a {
    padding: 11px 0;
    justify-content: center;
    border-left-width: 0;
    border-left-color: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.15s, color 0.15s;
}

body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one.active > a {
    background: var(--sidebar-active-bg);
    border-bottom-color: rgba(255, 159, 10, 0.15);
}

body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one > a .nav-text {
    display: none !important;
}

/* Ensure no text is displayed on collapsed state if specific selectors fail */
body.sidebar-collapsed nav.navbar.admin-sidebar .navbar-nav .nav-one > a .nav-text {
    display: none !important;
}

body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one > a .caret {
    display: none !important;
}

body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one .fas {
    margin: 0;
    width: auto;
    font-size: 16px;
}

/* Keep submenu icon/text spacing in collapsed flyout menus. */
body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two .fas {
    width: 18px;
    margin-right: 8px;
    font-size: 12px;
}

/* Collapsed: flyout submenus ΓÇö use opacity instead of display so JS can
   measure and position the flyout BEFORE it becomes visible (avoids bounce). */
body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .dropdown-menu {
    position: fixed !important;
    left: var(--sidebar-collapsed-width) !important;
    top: 0;
    bottom: auto !important;
    display: block !important;
    min-width: 180px;
    padding: 5px 0;
    border-radius: 0 6px 6px 0;
    border-top: 0;
    border-left: 0;
    background: #202429;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 1060;
    transition: opacity 0.08s ease-in;
}

body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .nav-one.flyout-open > .dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two > a {
    padding: 9px 16px;
}

/* Collapsed: invisible hover bridge so the mouse can travel from sidebar icon
   to the flyout without losing :hover on the li.nav-one parent. */
body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .dropdown-menu::after {
    content: '';
    position: absolute;
    left: -20px;
    top: 0;
    width: 20px;
    height: 100%;
    background: transparent;
}

/* Collapsed: flyout arrow */
body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .dropdown-menu::before {
    content: '';
    display: block;
    position: absolute;
    left: -5px;
    top: var(--arrow-offset, 15px);
    width: 0;
    height: 0;
    border-right: 5px solid #202429;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

/* Collapsed: tooltip for items without submenus */
body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one.no-submenu > a {
    position: relative;
}

body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one.no-submenu > a[title]:hover::after {
    content: attr(title);
    position: absolute;
    left: calc(var(--sidebar-collapsed-width) + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: #23282d;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1100;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Sidebar expand tooltip */
body.sidebar-collapsed .sidebar-toggle[data-tooltip-expand]:hover::after {
    content: attr(data-tooltip-expand);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: #23282d;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/*
  Mobile / Tablet Responsive (<1200px): sliding overlay sidebar
*/
@media (max-width: 1199px) {
    .admin-layout {
        grid-template-areas: "header" "main";
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-height) 1fr;
    }

    .admin-header {
        position: relative;
        z-index: 1041; /* above sidebar (1040) so MOCO + hamburger remain visible */
    }

    nav.navbar.navbar-dark.admin-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: var(--sidebar-width);
        z-index: 1040;
        transform: translateX(calc(-1 * var(--sidebar-width)));
        transition: transform 0.28s ease;
        grid-area: unset;
    }

    body.sidebar-open nav.navbar.navbar-dark.admin-sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }

    body.sidebar-open .admin-sidebar-backdrop {
        display: block;
    }

    .sidebar-mobile-toggle {
        display: flex !important;
    }

    .sidebar-toggle {
        display: none !important;
    }

    /* Reset any collapsed styles when sidebar is open on mobile */
    body.sidebar-open nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one > a {
        padding: 10px 16px;
        justify-content: flex-start;
        border-left-width: 3px;
        border-bottom: none;
    }

    body.sidebar-open nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one > a .nav-text {
        display: inline !important;
    }

    body.sidebar-open nav.navbar.navbar-dark.admin-sidebar .navbar-nav .nav-one .fas {
        margin-right: 10px;
        width: 22px;
        font-size: 14px;
    }

    body.sidebar-open nav.navbar.navbar-dark.admin-sidebar .dropdown-menu {
        box-shadow: none;
        background: rgba(0, 0, 0, 0.18);
    }
}

/*
  Third-level submenus (nav-two.dropdown group headers and nav-three items)
*/

/* Group header cursor and caret */
nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two.dropdown > a {
    cursor: pointer;
}

nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two.dropdown > a .caret {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 10px;
    opacity: 0.5;
    transition: transform 0.2s;
}

nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two.dropdown.show > a .caret {
    transform: rotate(90deg);
    opacity: 0.8;
}

/* Third-level dropdown: inline, hidden until JS adds .show */
nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two.dropdown > .dropdown-menu {
    display: none;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
    position: static !important;
    width: 100%;
    float: none;
}

nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two.dropdown.show > .dropdown-menu {
    display: block;
}

/* nav-three items */
nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two.dropdown .nav-three > a {
    display: flex;
    align-items: center;
    padding: 7px 14px 7px 52px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 11.5px;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s;
    line-height: 1.2;
}

body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two.dropdown .nav-three > a {
    padding: 7px 14px 7px 28px;
}

nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two.dropdown .nav-three .fas {
    display: inline-block !important;
    width: 18px;
    font-size: 11px;
    margin-right: 8px;
    flex-shrink: 0;
    opacity: 0.6;
}

/*
  Collapsed flyout: override fixed positioning for third-level dropdowns so
  they expand inline within the flyout panel. Hover to expand.
*/
body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two.dropdown > .dropdown-menu {
    position: static !important;
    left: auto !important;
    top: auto !important;
    bottom: auto !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    box-shadow: none !important;
    background: transparent !important;
    border: 0 !important;
    padding: 0 !important;
    display: none !important;
}

body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two.dropdown > .dropdown-menu::before,
body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two.dropdown > .dropdown-menu::after {
    display: none;
}

body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two.dropdown:hover > .dropdown-menu,
body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two.dropdown.show > .dropdown-menu {
    display: block !important;
}

/* Keep nav-three icon spacing inside collapsed flyout */
body.sidebar-collapsed nav.navbar.navbar-dark.admin-sidebar .dropdown-menu .nav-two.dropdown .nav-three .fas {
    width: 18px;
    margin-right: 8px;
    font-size: 11px;
}
