/* ==========================================================================
   ElitePanel Admin - Layout (Sidebar + Header + Main + Footer)
   ========================================================================== */

.app-wrapper { display: flex; min-height: 100vh; }

/* ============== Sidebar ============== */
.app-sidebar {
    background: url('/assets/images/profile-cover.jpg');
  width: var(--rt-sidebar-width);
  background: var(--rt-sidebar-bg);
  color: var(--rt-sidebar-text);
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 1040;
  display: flex; flex-direction: column;
  transition: var(--rt-trans);
  border-right: 1px solid var(--rt-sidebar-border);
}
.app-sidebar .sidebar-brand {
  height: var(--rt-header-h);
  display: flex; align-items: center; gap: .65rem;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--rt-sidebar-border);
  color: #fff; font-weight: 700; font-size: 1.25rem;
  letter-spacing: -0.02em;
}
.app-sidebar .sidebar-brand .brand-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--rt-primary), #0EA475);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px;
  box-shadow: 0 6px 14px rgba(20,195,142,.4);
}
.app-sidebar .sidebar-brand .brand-text { color: #fff; }
.app-sidebar .sidebar-brand .brand-text span { color: var(--rt-primary); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem .75rem 2rem; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); }

.sidebar-heading {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: rgba(255,255,255,.35); padding: 1rem .9rem .4rem; font-weight: 600;
  list-style: none;
}
.sidebar-heading::marker { content: ''; }

.sidebar-menu { list-style: none; margin: 0; padding: 0; }
.sidebar-menu .menu-item { margin-bottom: 2px; }
.sidebar-menu .menu-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem .9rem; border-radius: 10px;
  color: var(--rt-sidebar-text); font-size: 14px; font-weight: 500;
  transition: var(--rt-trans); position: relative;
}
.sidebar-menu .menu-link i { font-size: 18px; width: 20px; text-align: center; }
.sidebar-menu .menu-link .menu-arrow { margin-left: auto; transition: transform .25s; font-size: 12px; }
.sidebar-menu .menu-link:hover { background: rgba(255,255,255,.04); color: #fff; }
.sidebar-menu .menu-link.active {
  background: var(--rt-sidebar-active-bg); color: var(--rt-sidebar-active);
}
.sidebar-menu .menu-link.active::before {
  content: ''; position: absolute; left: -.75rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px; background: var(--rt-primary); border-radius: 0 4px 4px 0;
}
.sidebar-menu .menu-link[aria-expanded="true"] .menu-arrow { transform: rotate(90deg); }
.sidebar-menu .menu-link .menu-badge {
  margin-left: auto; font-size: 10px; padding: .15em .5em;
  background: var(--rt-primary); color: #fff; border-radius: 99px; font-weight: 600;
}

.sidebar-submenu { list-style: none; margin: 4px 0 4px 1.7rem; padding: 0;
  border-left: 1px dashed rgba(255,255,255,.08); }
.sidebar-submenu .submenu-link {
  display: block; padding: .45rem .9rem; color: rgba(255,255,255,.55); font-size: 13px;
  border-radius: 8px; transition: var(--rt-trans); position: relative;
}
.sidebar-submenu .submenu-link::before {
  content: ''; position: absolute; left: -1px; top: 50%; transform: translateY(-50%);
  width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.15);
}
.sidebar-submenu .submenu-link:hover, .sidebar-submenu .submenu-link.active {
  color: var(--rt-primary);
}
.sidebar-submenu .submenu-link.active::before { background: var(--rt-primary); }

.sidebar-footer-card {
  margin: 1rem; padding: 1rem; border-radius: 14px;
  background: linear-gradient(160deg, rgba(20,195,142,.18), rgba(20,195,142,.04));
  border: 1px solid rgba(20,195,142,.2); color: #fff;
}
.sidebar-footer-card h6 { color: #fff; font-size: 13px; }
.sidebar-footer-card p { color: rgba(255,255,255,.6); font-size: 12px; margin: .25rem 0 .75rem; }

/* Sidebar mini state */
body.sidebar-mini .app-sidebar { width: var(--rt-sidebar-collapsed); }
body.sidebar-mini .app-sidebar .brand-text,
body.sidebar-mini .app-sidebar .menu-text,
body.sidebar-mini .app-sidebar .menu-arrow,
body.sidebar-mini .app-sidebar .menu-badge,
body.sidebar-mini .app-sidebar .sidebar-heading,
body.sidebar-mini .app-sidebar .sidebar-footer-card,
body.sidebar-mini .app-sidebar .sidebar-submenu { display: none !important; }
body.sidebar-mini .app-sidebar .sidebar-brand { justify-content: center; padding: 0; }
body.sidebar-mini .app-sidebar .menu-link { justify-content: center; padding: .65rem; }
body.sidebar-mini .app-content { margin-left: var(--rt-sidebar-collapsed); }

/* --- Mini sidebar: popout submenu on hover ---------------------- */
/* Hide the injected title by default — only show inside an open popout */
.app-sidebar .popout-title { display: none; }

body.sidebar-mini .app-sidebar .sidebar-menu .menu-item { position: relative; }

body.sidebar-mini .app-sidebar .menu-item.popout-open > .collapse {
  display: block !important;
  position: fixed;
  left: var(--rt-popout-left, var(--rt-sidebar-collapsed));
  /* top is set inline by JS */
  min-width: 220px;
  background: var(--rt-sidebar-bg);
  border: 1px solid var(--rt-sidebar-border);
  border-left: 3px solid var(--rt-primary);
  border-radius: 0 12px 12px 0;
  box-shadow: 12px 12px 30px rgba(0,0,0,0.45);
  z-index: 1100;
  padding: 6px;
  height: auto;
  margin-left: 2px;
  animation: rt-popout-in .15s ease-out;
}
@keyframes rt-popout-in {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

body.sidebar-mini .app-sidebar .menu-item.popout-open > .collapse .popout-title {
  display: block;
  padding: 8px 12px 10px;
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid var(--rt-sidebar-border);
  letter-spacing: .02em;
}

body.sidebar-mini .app-sidebar .menu-item.popout-open > .collapse .sidebar-submenu {
  display: block !important;
  list-style: none;
  margin: 0;
  padding: 0;
}

body.sidebar-mini .app-sidebar .menu-item.popout-open > .collapse .submenu-link {
  display: block;
  padding: 7px 12px;
  border-radius: 6px;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  text-decoration: none;
  transition: var(--rt-trans);
  white-space: nowrap;
}

body.sidebar-mini .app-sidebar .menu-item.popout-open > .collapse .submenu-link::before {
  display: none;
}

body.sidebar-mini .app-sidebar .menu-item.popout-open > .collapse .submenu-link:hover,
body.sidebar-mini .app-sidebar .menu-item.popout-open > .collapse .submenu-link.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

/* ============== Header ============== */
.app-header {
  position: sticky; top: 0; z-index: 1030; height: var(--rt-header-h);
  background: var(--rt-header-bg); border-bottom: 1px solid var(--rt-border);
  display: flex; align-items: center; padding: 0 1.5rem;
  backdrop-filter: blur(8px);
}
.app-header .header-inner { display: flex; align-items: center; width: 100%; gap: 1rem; }
.app-header .menu-toggle { background: transparent; border: 0; color: var(--rt-text); font-size: 22px; padding: 6px; }

/* Header brand — hidden by default, shown in horizontal layout */
.app-header .header-brand { display: none; align-items: center; gap: .65rem; text-decoration: none; color: var(--rt-heading); font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; }
.app-header .header-brand .brand-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--rt-primary), #0EA475);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px;
  box-shadow: 0 6px 14px rgba(20,195,142,.4);
}
.app-header .header-brand .brand-text span { color: var(--rt-primary); }
body.layout-horizontal .app-header .menu-toggle { display: none; }
body.layout-horizontal .app-header .header-brand { display: inline-flex; }

.header-search { position: relative; max-width: 380px; flex: 1; }
.header-search .form-control {
  padding-left: 2.5rem; background: var(--rt-body-bg); color: var(--rt-text); border-color: transparent; height: 42px;
}
.header-search .form-control::placeholder { color: var(--rt-text-muted); }
.header-search .form-control:focus { background: var(--rt-card-bg); color: var(--rt-text); border-color: var(--rt-primary); }
.header-search i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--rt-text-muted); font-size: 16px; }
.header-search .kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 11px; padding: 2px 6px; background: var(--rt-card-bg); border: 1px solid var(--rt-border);
  border-radius: 4px; color: var(--rt-text-muted); font-family: monospace;
}

.header-actions { display: flex; align-items: center; gap: .5rem; margin-inline-start: auto; }
.header-action-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 12px; background: var(--rt-body-bg);
  border: 0; color: var(--rt-text); font-size: 18px; transition: var(--rt-trans);
}
.header-action-btn:hover { background: var(--rt-primary-light); color: var(--rt-primary); }
.header-action-btn .action-dot {
  position: absolute; top: 9px; right: 11px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--rt-danger); border: 2px solid var(--rt-header-bg);
}

.header-profile { display: flex; align-items: center; gap: .65rem; padding: 4px 4px 4px 14px;
  background: var(--rt-card-bg); border: 1px solid var(--rt-border); border-radius: 99px;
  cursor: pointer; transition: var(--rt-trans); }
.header-profile:hover { background: var(--rt-primary-light); border-color: var(--rt-primary-light); }
.header-profile .profile-info { line-height: 1.15; }
.header-profile .profile-info .name { font-weight: 600; font-size: 13px; color: var(--rt-text); }
.header-profile .profile-info .role { font-size: 11px; color: var(--rt-text-muted); }

/* Notifications dropdown */
.notif-dropdown { width: 360px; padding: 0; }
.notif-dropdown .notif-header { padding: 1rem 1.1rem; border-bottom: 1px solid var(--rt-border);
  display: flex; align-items: center; justify-content: space-between; }
.notif-dropdown .notif-list { max-height: 380px; overflow-y: auto; }
.notif-dropdown .notif-item { padding: .75rem 1.1rem; display: flex; gap: .75rem;
  border-bottom: 1px solid var(--rt-border); transition: var(--rt-trans); cursor: pointer; }
.notif-dropdown .notif-item:hover { background: var(--rt-body-bg); }
.notif-dropdown .notif-item:last-child { border-bottom: 0; }
.notif-dropdown .notif-item .notif-icon { width: 40px; height: 40px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-dropdown .notif-footer { padding: .65rem; text-align: center; border-top: 1px solid var(--rt-border); }

/* Profile dropdown */
.profile-dropdown { width: 260px; padding: 0; }
.profile-dropdown .profile-head { padding: 1rem; display: flex; gap: .75rem; align-items: center;
  border-bottom: 1px solid var(--rt-border); }
.profile-dropdown ul { list-style: none; margin: 0; padding: .5rem; }
.profile-dropdown ul li a { display: flex; align-items: center; gap: .65rem;
  padding: .55rem .75rem; border-radius: 8px; color: var(--rt-text); font-size: 14px; }
.profile-dropdown ul li a:hover { background: var(--rt-body-bg); color: var(--rt-primary); }
.profile-dropdown .profile-footer { padding: .65rem 1rem; border-top: 1px solid var(--rt-border); }

/* ============== Main / Content ============== */
.app-content {
  flex: 1; margin-left: var(--rt-sidebar-width);
  display: flex; flex-direction: column; min-height: 100vh;
  transition: var(--rt-trans);
  min-width: 0;          /* prevent flex child from growing past parent */
  overflow-x: hidden;    /* contain wide content like kanban / tables */
  max-width: calc(100% - var(--rt-sidebar-width));
}
.app-main { flex: 1; padding: 1.5rem; min-width: 0; overflow-x: hidden; }
.app-main > .row { margin-left: 0; margin-right: 0; }
body.sidebar-mini .app-content { max-width: calc(100% - var(--rt-sidebar-collapsed)); }
@media (max-width: 991.98px) {
  .app-content { max-width: 100%; }
}

.page-header { margin-bottom: 1.5rem; display: flex; flex-wrap: wrap; align-items: flex-end;
  justify-content: space-between; gap: 1rem; }
.page-header h1 { font-size: 1.5rem; margin: 0 0 .25rem; font-weight: 700; }
.page-header .breadcrumb { margin-top: .25rem; }

/* Footer */
.app-footer {
  border-top: 1px solid var(--rt-border); padding: 1rem 1.5rem; background: var(--rt-card-bg);
  display: flex; justify-content: space-between; align-items: center; font-size: 13px;
  color: var(--rt-text-muted);
}
.app-footer a { color: var(--rt-text); margin: 0 .5rem; }
.app-footer a:hover { color: var(--rt-primary); }

/* ============== Responsive ============== */
@media (max-width: 991.98px) {
  /* Default left-drawer behavior — applies regardless of layout-boxed / layout-horizontal */
  .app-sidebar,
  body.layout-boxed .app-sidebar,
  body.layout-horizontal .app-sidebar {
    position: fixed;
    top: 0; bottom: 0;
    left: 0; right: auto;
    width: var(--rt-sidebar-width);
    height: 100%;
    flex-direction: column;
    border-right: 1px solid var(--rt-sidebar-border);
    border-bottom: 0;
    border-left: 0;
    transform: translateX(-100%);
    z-index: 1040;
    overflow-y: auto;
  }
  body.sidebar-open .app-sidebar,
  body.layout-boxed.sidebar-open .app-sidebar,
  body.layout-horizontal.sidebar-open .app-sidebar { transform: translateX(0); }

  /* RTL — drawer slides in from the RIGHT */
  html[dir="rtl"] .app-sidebar,
  html[dir="rtl"] body.layout-boxed .app-sidebar,
  html[dir="rtl"] body.layout-horizontal .app-sidebar {
    left: auto; right: 0;
    border-right: 0; border-left: 1px solid var(--rt-sidebar-border);
    transform: translateX(100%);
  }
  html[dir="rtl"] body.sidebar-open .app-sidebar { transform: translateX(0); }

  /* Content takes full width, no sidebar margin on any layout */
  .app-content,
  body.layout-boxed .app-content,
  body.layout-boxed.sidebar-mini .app-content,
  body.layout-horizontal .app-content {
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100% !important;
  }
  /* Boxed wrapper goes full width on mobile */
  body.layout-boxed .app-wrapper { max-width: 100%; box-shadow: none; background: transparent; }

  .header-search { max-width: none; }
  .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1035; }
  body.sidebar-open .sidebar-backdrop { display: block; }

  /* On mobile: always show menu-toggle, hide header brand even in horizontal mode */
  .app-header .menu-toggle { display: inline-flex !important; }
  body.layout-horizontal .app-header .header-brand { display: none !important; }

  /* Inside the drawer, restore the brand + vertical menu/heading look (overrides horizontal styles) */
  body.layout-horizontal .app-sidebar .sidebar-brand { display: flex !important; }
  body.layout-horizontal .app-sidebar .sidebar-nav {
    display: block;
    padding: 1rem .75rem 2rem;
    overflow: visible;
  }
  body.layout-horizontal .menu-group { display: block; position: static; }
  body.layout-horizontal .sidebar-heading {
    display: block !important;
    font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
    color: rgba(255,255,255,.35); padding: 1rem .9rem .4rem;
    font-weight: 600; cursor: default; background: transparent !important;
    border-radius: 0; margin: 0;
  }
  body.layout-horizontal .sidebar-heading::after { display: none; }
  body.layout-horizontal .menu-group .sidebar-menu {
    display: block !important;
    position: static;
    background: transparent;
    border: 0; box-shadow: none; padding: 0; margin: 0;
    flex-direction: column !important;
    max-height: none; overflow: visible;
  }
  body.layout-horizontal .menu-group .sidebar-menu .menu-item > .collapse {
    position: static !important;
    background: transparent;
    border: 0; box-shadow: none; padding: 0; margin: 0;
    display: none !important;          /* Bootstrap collapse controls open/close */
    max-height: none; overflow: visible;
  }
  body.layout-horizontal .menu-group .sidebar-menu .menu-item > .collapse.show { display: block !important; }
  body.layout-horizontal .menu-group .sidebar-menu .menu-item:hover > .collapse { display: none !important; }
  body.layout-horizontal .menu-group .sidebar-menu .menu-item.popout-open > .collapse.show { display: block !important; }
  body.layout-horizontal .menu-link .menu-arrow { transform: none; margin-left: auto; }
  body.layout-horizontal .menu-link[aria-expanded="true"] .menu-arrow { transform: rotate(90deg); }

  body.layout-horizontal .app-main { padding-top: 1rem; }
}
@media (max-width: 575.98px) {
  .header-search { display: none; }
  .header-profile .profile-info { display: none; }
  .app-main { padding: 1rem; }
  .app-header { padding: 0 1rem; }
}

/* ============== Theme Settings Panel ============== */
.settings-panel { width: 360px; max-width: 100%; background: var(--rt-card-bg); color: var(--rt-text); }
.settings-panel .settings-head { border-bottom: 1px solid var(--rt-border); padding: 1.1rem 1.25rem; align-items: flex-start; }
.settings-panel .offcanvas-title { font-size: 16px; font-weight: 700; margin: 0; }
.settings-panel .settings-head small { display: block; margin-top: 2px; font-size: 12px; }
.settings-panel .offcanvas-body { padding: 1rem 1.25rem 1.5rem; }

.settings-section { padding: 1rem 0; border-bottom: 1px dashed var(--rt-border); }
.settings-section:last-of-type { border-bottom: 0; }
.settings-section-title {
  font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: var(--rt-text-muted); margin-bottom: .85rem;
}

.theme-mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode-card input { position: absolute; opacity: 0; pointer-events: none; }
.mode-card { cursor: pointer; display: block; margin: 0; }
.mode-card-inner {
  display: block; padding: 10px 10px 12px; border-radius: 12px;
  border: 2px solid var(--rt-border); background: var(--rt-body-bg);
  transition: var(--rt-trans);
  text-align: center;
}
.mode-card-inner svg { width: 100%; height: auto; display: block; border-radius: 6px; }
.mode-card-label { display: block; font-size: 12.5px; font-weight: 700; margin-top: 8px; color: var(--rt-text); }
.mode-card:hover .mode-card-inner { border-color: var(--rt-primary); }
.mode-card input:checked + .mode-card-inner {
  border-color: var(--rt-primary);
  box-shadow: 0 0 0 4px rgba(20,195,142,.15);
}
.mode-card input:checked + .mode-card-inner .mode-card-label { color: var(--rt-primary); }

.settings-toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 0;
}
.settings-toggle-row + .settings-toggle-row { border-top: 1px dashed var(--rt-border); }
.settings-toggle-label { font-size: 13.5px; font-weight: 600; color: var(--rt-heading); line-height: 1.2; }
.settings-row-disabled { opacity: .45; pointer-events: none; }
.settings-row-disabled .form-check-input { cursor: not-allowed; }

/* Layout: Boxed — center the entire shell (sidebar + content) inside a 1440px frame */
body.layout-boxed { background: var(--rt-body-bg); }
body.layout-boxed .app-wrapper {
  max-width: 1440px;
  margin: 0 auto;
  position: relative;
  box-shadow: 0 0 40px rgba(15,23,42,.10);
  background: var(--rt-card-bg);
}
[data-theme="dark"] body.layout-boxed .app-wrapper { box-shadow: 0 0 40px rgba(0,0,0,.45); }
/* Sidebar is position:fixed — offset its `left` so it aligns with the boxed shell's left edge */
body.layout-boxed .app-sidebar { left: max(0px, calc((100vw - 1440px) / 2)); }
/* In boxed mode the wrapper is already centered, so .app-content margin-left
   only needs the sidebar width (no extra viewport offset — that would double up). */
body.layout-boxed .app-content {
  margin-left: var(--rt-sidebar-width);
  max-width: calc(1440px - var(--rt-sidebar-width));
}
body.layout-boxed.sidebar-mini .app-content {
  margin-left: var(--rt-sidebar-collapsed);
  max-width: calc(1440px - var(--rt-sidebar-collapsed));
}
/* The fixed top header inside the boxed shell — match the same horizontal offset */
body.layout-boxed .app-header { left: 0; right: 0; }
/* Popout submenus in boxed + mini mode — shift to the right of the offset sidebar column */
body.layout-boxed.sidebar-mini { --rt-popout-left: calc(max(0px, calc((100vw - 1440px) / 2)) + var(--rt-sidebar-collapsed)); }

/* Layout: Horizontal — DESKTOP ONLY (≥ 992px).
   Below 992px the sidebar reverts to the default left-drawer styling automatically. */
@media (min-width: 992px) {
body.layout-horizontal .app-sidebar {
  position: relative;            /* in normal flow — scrolls with the page */
  top: auto; left: auto; right: auto; bottom: auto;
  width: 100%; height: auto;
  border-right: 0;
  border-bottom: 1px solid var(--rt-sidebar-border);
  z-index: 5;
  transform: none;
  overflow: visible;
  flex-direction: row;
}
body.layout-horizontal .app-sidebar .sidebar-brand,
body.layout-horizontal .app-sidebar .sidebar-footer-card { display: none !important; }
body.layout-horizontal .app-sidebar .sidebar-nav {
  flex: 1;
  display: flex; align-items: center;
  padding: 0 1rem;
  overflow: visible;
}

/* Each .menu-group wraps one heading + its sidebar-menu (added by JS) */
body.layout-horizontal .menu-group {
  position: relative;
  display: inline-flex; align-items: center;
}

/* Top-level: the heading itself */
body.layout-horizontal .sidebar-heading {
  display: inline-flex !important; align-items: center;
  font-size: 13.5px; font-weight: 600;
  text-transform: none; letter-spacing: 0;
  color: var(--rt-sidebar-text);
  padding: .85rem 1rem;
  cursor: pointer; white-space: nowrap;
  border-radius: 8px;
  margin: 0 1px;
  transition: var(--rt-trans);
  position: relative;
}
body.layout-horizontal .sidebar-heading::after {
  content: ""; margin-left: 6px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: .65;
}
body.layout-horizontal .menu-group:hover .sidebar-heading,
body.layout-horizontal .sidebar-heading:hover { background: rgba(255,255,255,.06); color: #fff; }

/* Level-2 dropdown (the .sidebar-menu) — hidden until the group is hovered */
body.layout-horizontal .menu-group .sidebar-menu {
  display: none;
  position: absolute;
  top: 100%; left: 0;
  min-width: 240px;
  background: var(--rt-sidebar-bg);
  border: 1px solid var(--rt-sidebar-border);
  border-top: 0;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
  padding: 6px; margin: 0;
  z-index: 1100;
  flex-direction: column !important;
  flex-wrap: nowrap;
  align-items: stretch !important;
}
body.layout-horizontal .menu-group:hover > .sidebar-menu,
body.layout-horizontal .menu-group .sidebar-menu:hover { display: flex; }

/* Level-2 menu items — full-width rows */
body.layout-horizontal .menu-group .sidebar-menu .menu-item {
  margin: 0 !important;
  position: relative;
}
body.layout-horizontal .menu-group .sidebar-menu .menu-link {
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 13px;
  display: flex; align-items: center;
  white-space: nowrap;
}
body.layout-horizontal .menu-group .sidebar-menu .menu-link i.menu-arrow {
  margin-left: auto; transform: none;
  font-size: 11px;
}

/* Level-3: a sub-menu cascades to the right of its parent menu-item on hover */
body.layout-horizontal .menu-group .sidebar-menu .menu-item > .collapse {
  display: none !important;
  position: absolute;
  top: -6px; left: 100%;
  min-width: 220px;
  background: var(--rt-sidebar-bg);
  border: 1px solid var(--rt-sidebar-border);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
  padding: 6px;
  margin-left: 4px;
  z-index: 1101;
  height: auto !important;
  max-height: calc(100vh - var(--rt-header-h) - 60px);
  overflow-y: auto;
}
body.layout-horizontal .menu-group .sidebar-menu .menu-item > .collapse::-webkit-scrollbar { width: 6px; }
body.layout-horizontal .menu-group .sidebar-menu .menu-item > .collapse::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }
body.layout-horizontal .menu-group .sidebar-menu .menu-item:hover > .collapse {
  display: block !important;
}
body.layout-horizontal .menu-group .sidebar-menu .menu-item > .collapse .sidebar-submenu {
  display: block !important;
  list-style: none; margin: 0; padding: 0;
}
body.layout-horizontal .menu-group .sidebar-menu .menu-item > .collapse .submenu-link {
  display: block;
  padding: 7px 12px;
  border-radius: 6px;
  color: rgba(255,255,255,.7);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}
body.layout-horizontal .menu-group .sidebar-menu .menu-item > .collapse .submenu-link::before { display: none; }
body.layout-horizontal .menu-group .sidebar-menu .menu-item > .collapse .submenu-link:hover,
body.layout-horizontal .menu-group .sidebar-menu .menu-item > .collapse .submenu-link.active {
  background: rgba(255,255,255,.08); color: #fff;
}

/* Content area — no left margin; sidebar is now in flow inside .app-content */
body.layout-horizontal .app-content { margin-left: 0 !important; max-width: 100% !important; }
body.layout-horizontal .app-main { padding-top: 1.5rem; }
} /* end @media (min-width: 992px) for layout-horizontal desktop */

/* ====== Mobile (< 992px) overrides for layout-horizontal — minimal ======
   The desktop horizontal CSS is now wrapped in @media (min-width: 992px), so it
   doesn't apply on mobile. The default sidebar styling takes over naturally.
   We only need a few small overrides here for content margin and topbar. */
@media (max-width: 991.98px) {
  body.layout-horizontal .app-content { margin-left: 0 !important; margin-right: 0 !important; max-width: 100% !important; padding-top: 0 !important; }
  body.layout-horizontal .app-main { padding-top: 1rem !important; }
  body.layout-horizontal .app-header .menu-toggle { display: inline-flex !important; }
  body.layout-horizontal .app-header .header-brand { display: none !important; }
  /* Mobile sidebar logo — give it comfortable top/bottom breathing room */
  .app-sidebar .sidebar-brand {
    height: auto;
    padding: 1.25rem 1.25rem;
  }
}

/* RTL */
html[dir="rtl"] .app-sidebar { left: auto; right: 0; border-right: 0; border-left: 1px solid var(--rt-sidebar-border); }
html[dir="rtl"] .app-content { margin-left: 0; margin-right: var(--rt-sidebar-width); }
html[dir="rtl"] body.sidebar-mini .app-content { margin-right: var(--rt-sidebar-collapsed); margin-left: 0; }

/* RTL + Boxed — sidebar pins to the boxed wrapper's RIGHT edge, not the viewport edge */
html[dir="rtl"] body.layout-boxed .app-sidebar {
  left: auto;
  right: max(0px, calc((100vw - 1440px) / 2));
}
html[dir="rtl"] body.layout-boxed .app-content {
  margin-left: 0;
  margin-right: var(--rt-sidebar-width);
}
html[dir="rtl"] body.layout-boxed.sidebar-mini .app-content {
  margin-left: 0;
  margin-right: var(--rt-sidebar-collapsed);
}
/* RTL Settings Panel — slide in from the LEFT side, mirror the mockup SVGs */
html[dir="rtl"] .settings-panel.offcanvas-end {
  right: auto !important;
  left: 0 !important;
  border-right: 1px solid var(--rt-border);
  border-left: 0;
  transform: translateX(-100%);
}
html[dir="rtl"] .settings-panel.offcanvas-end.show { transform: none; }
html[dir="rtl"] .settings-panel .mode-card-inner svg { transform: scaleX(-1); }
/* Force the close button to the LEFT in RTL via absolute positioning,
   leaving the title flush against the right edge of the header. */
html[dir="rtl"] .settings-panel .offcanvas-header { position: relative; padding-left: 3rem; padding-right: 1.25rem; }
html[dir="rtl"] .settings-panel .offcanvas-header .btn-close {
  position: absolute;
  left: 1rem;
  top: 1.25rem;
  margin: 0;
}

/* RTL popout submenus — open to the LEFT of the icon column (mirrored).
   Anchor to right, swap accent edge, mirror radius/shadow/animation. */
html[dir="rtl"] body.sidebar-mini .app-sidebar .menu-item.popout-open > .collapse {
  left: auto;
  right: var(--rt-popout-left, var(--rt-sidebar-collapsed));
  border-left: 1px solid var(--rt-sidebar-border);
  border-right: 3px solid var(--rt-primary);
  border-radius: 12px 0 0 12px;
  box-shadow: -12px 12px 30px rgba(0,0,0,0.45);
  margin-left: 0;
  margin-right: 2px;
  animation: rt-popout-in-rtl .15s ease-out;
}
@keyframes rt-popout-in-rtl {
  from { opacity: 0; transform: translateX(6px); }
  to   { opacity: 1; transform: translateX(0); }
}
html[dir="rtl"] body.layout-boxed.sidebar-mini { --rt-popout-left: calc(max(0px, calc((100vw - 1440px) / 2)) + var(--rt-sidebar-collapsed)); }

/* ============== Dark theme adjustments (header / dropdowns / footer) === */
[data-theme="dark"] .header-profile { background: #1B2740; border-color: #283452; }
[data-theme="dark"] .header-profile:hover {
  background: rgba(20,195,142,.12);
  border-color: rgba(20,195,142,.35);
}
[data-theme="dark"] .header-action-btn { background: #1B2740; color: var(--rt-text); }
[data-theme="dark"] .header-action-btn:hover { background: rgba(20,195,142,.12); color: var(--rt-primary); }

[data-theme="dark"] .header-search .form-control { background: #0F1A2E; border-color: transparent; }
[data-theme="dark"] .header-search .form-control:focus { background: #1B2740; border-color: var(--rt-primary); }
[data-theme="dark"] .header-search .kbd { background: #0F1A2E; border-color: #283452; }

/* Bootstrap dropdown menus in dark mode */
[data-theme="dark"] .dropdown-menu {
  background: var(--rt-card-bg);
  border-color: var(--rt-border);
  color: var(--rt-text);
  box-shadow: 0 14px 40px rgba(0,0,0,.45);
}
[data-theme="dark"] .dropdown-item { color: var(--rt-text); }
[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus { background: rgba(20,195,142,.12); color: var(--rt-primary); }
[data-theme="dark"] .dropdown-divider { border-color: var(--rt-border); }
[data-theme="dark"] .dropdown-header { color: var(--rt-text-muted); }

/* Quick Apps tiles use text-dark inline — flip to readable text in dark */
[data-theme="dark"] .dropdown-menu .text-dark { color: var(--rt-text) !important; }
[data-theme="dark"] .dropdown-menu .text-dark:hover { background: rgba(20,195,142,.10); color: var(--rt-primary) !important; }

/* Notification + profile dropdowns */
[data-theme="dark"] .notif-dropdown .notif-item:hover,
[data-theme="dark"] .profile-dropdown ul li a:hover { background: rgba(255,255,255,.04); }
[data-theme="dark"] .notif-dropdown .notif-header,
[data-theme="dark"] .notif-dropdown .notif-item,
[data-theme="dark"] .notif-dropdown .notif-footer,
[data-theme="dark"] .profile-dropdown .profile-head,
[data-theme="dark"] .profile-dropdown .profile-footer { border-color: var(--rt-border); }

/* Notification icon tints — make soft backgrounds work on dark */
[data-theme="dark"] .bg-primary-soft   { background: rgba(20,195,142,.18) !important; color: #6EE7B7; }
[data-theme="dark"] .bg-success-soft   { background: rgba(34,197,94,.18)  !important; color: #86EFAC; }
[data-theme="dark"] .bg-warning-soft   { background: rgba(245,158,11,.18) !important; color: #FCD34D; }
[data-theme="dark"] .bg-danger-soft    { background: rgba(239,68,68,.18)  !important; color: #FCA5A5; }
[data-theme="dark"] .bg-info-soft      { background: rgba(14,165,233,.18) !important; color: #7DD3FC; }
[data-theme="dark"] .bg-secondary-soft { background: rgba(148,163,184,.18) !important; color: #CBD5E1; }
[data-theme="dark"] .bg-purple-soft    { background: rgba(139,92,246,.18)  !important; color: #C4B5FD; }
[data-theme="dark"] .bg-pink-soft      { background: rgba(236,72,153,.18)  !important; color: #F9A8D4; }
[data-theme="dark"] .bg-orange-soft    { background: rgba(249,115,22,.18)  !important; color: #FDBA74; }
[data-theme="dark"] .bg-teal-soft      { background: rgba(20,184,166,.18)  !important; color: #5EEAD4; }

/* Page header / breadcrumb readability */
[data-theme="dark"] .page-header h1 { color: var(--rt-heading); }
[data-theme="dark"] .breadcrumb-item,
[data-theme="dark"] .breadcrumb-item a { color: var(--rt-text-muted); }
[data-theme="dark"] .breadcrumb-item.active { color: var(--rt-text); }

/* Footer link color in dark mode */
[data-theme="dark"] .app-footer { background: var(--rt-card-bg); }
[data-theme="dark"] .app-footer a { color: var(--rt-text); }
