/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */
body {
  font-family: "Nunito", serif;
  font-style: normal;
}

/* =============================================
   FLOATING SIDEBAR NAVIGATION
   ============================================= */

/* ---- Base Floating Container ---- */
.app-sidebar {
  position: fixed;
  top: 14px;
  left: 14px;
  bottom: 14px;
  width: 68px;
  background: var(--tblr-bg-surface, #ffffff);
  border: 1px solid var(--tblr-border-color, rgba(0, 0, 0, 0.08));
  border-radius: 26px;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.03);
  z-index: 1045;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.28s ease;
}

.app-sidebar:hover {
  width: 264px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.13), 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* ---- Content offset for collapsed sidebar ---- */
.page > .page-wrapper {
  margin-left: 92px;
  transition: margin-left 0.28s ease;
}

/* ---- Sidebar Header (Circular Logo + User details) ---- */
.sidebar-header {
  height: 68px;
  display: flex;
  align-items: center;
  padding: 0 13px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--tblr-border-color, rgba(0, 0, 0, 0.06));
}

.sidebar-avatar-wrapper {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.sidebar-avatar-wrapper:hover {
  transform: scale(1.05);
}

.sidebar-avatar-img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.sidebar-profile-info {
  margin-left: 12px;
  opacity: 0;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.18s ease;
  flex: 1;
  pointer-events: none;
}

.app-sidebar:hover .sidebar-profile-info {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-user-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--tblr-body-color, #1e293b);
  line-height: 1.2;
}

.sidebar-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: #64748b;
  text-decoration: none;
  margin-top: 2px;
  padding: 1px 6px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 6px;
  transition: background 0.15s ease;
}

.sidebar-role-badge:hover {
  background: rgba(32, 107, 196, 0.1);
  color: #206bc4;
}

.sidebar-user-role {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 2px;
}

/* ---- Nav Scroll Area ---- */
.sidebar-nav-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 0;
  scrollbar-width: thin;
}

/* Hide scrollbar when collapsed */
.app-sidebar:not(:hover) .sidebar-nav-scroll {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.app-sidebar:not(:hover) .sidebar-nav-scroll::-webkit-scrollbar {
  display: none;
}

.sidebar-nav-scroll::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav-scroll::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 4px;
}

/* ---- Menu List ---- */
.sidebar-menu-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-menu-item {
  margin: 3px 10px;
}

.sidebar-menu-link {
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 11px;
  border-radius: 14px;
  color: #475569;
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  gap: 12px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  font-family: inherit;
}

.sidebar-menu-link:hover {
  background: #f1f5f9;
  color: #0f172a;
  text-decoration: none;
}

/* Active Menu Item Pill */
.sidebar-menu-item.active > .sidebar-menu-link {
  background: #eff6ff;
  color: #206bc4;
  font-weight: 600;
}

.sidebar-menu-item.active > .sidebar-menu-link .sidebar-menu-icon svg {
  stroke: #206bc4;
}

/* ---- Menu Icon ---- */
.sidebar-menu-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-menu-icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.7;
}

/* ---- Menu Text ---- */
.sidebar-menu-text {
  opacity: 0;
  transition: opacity 0.15s ease;
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-sidebar:hover .sidebar-menu-text {
  opacity: 1;
}

/* ---- Menu Arrow (chevron) ---- */
.sidebar-menu-arrow {
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.2s ease;
  margin-left: auto;
  display: flex;
  align-items: center;
}

.app-sidebar:hover .sidebar-menu-arrow {
  opacity: 0.5;
}

.sidebar-menu-arrow svg {
  width: 15px;
  height: 15px;
}

.sidebar-menu-item.open > .sidebar-menu-link .sidebar-menu-arrow {
  transform: rotate(90deg);
  opacity: 1;
}

/* ---- Submenu (accordion) ---- */
.sidebar-submenu {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-sidebar:hover .sidebar-menu-item.open > .sidebar-submenu {
  max-height: 900px;
}

.sidebar-submenu .sidebar-menu-item {
  margin: 2px 4px;
}

.sidebar-submenu .sidebar-menu-link {
  height: 36px;
  padding-left: 46px;
  font-size: 0.8125rem;
  color: #64748b;
  font-weight: 400;
  border-radius: 10px;
}

.sidebar-submenu .sidebar-menu-link:hover {
  color: #0f172a;
  background: #f8fafc;
}

.sidebar-submenu .sidebar-menu-item.active > .sidebar-menu-link {
  color: #206bc4;
  font-weight: 600;
  background: #eff6ff;
}

.sidebar-submenu form {
  margin: 0;
  padding: 0;
  width: 100%;
}

.sidebar-submenu button.sidebar-menu-link {
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  font-family: inherit;
}

/* Level 2 submenu (nested) */
.sidebar-submenu .sidebar-submenu .sidebar-menu-link {
  padding-left: 58px;
  font-size: 0.775rem;
}

/* ---- Sidebar Footer ---- */
.sidebar-footer {
  padding: 10px 8px;
  border-top: 1px solid var(--tblr-border-color, rgba(0, 0, 0, 0.06));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  transition: all 0.25s ease;
}

/* Desktop only: Collapsed = vertical column, Hovered = horizontal row */
@media (min-width: 768px) {
  .app-sidebar:not(:hover) .sidebar-footer {
    flex-direction: column;
    gap: 6px;
    padding: 8px 6px;
  }

  .app-sidebar:hover .sidebar-footer {
    flex-direction: row;
    justify-content: space-evenly;
    padding: 12px 14px;
  }
}

.sidebar-footer-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #f1f5f9;
  border: 1px solid transparent;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  flex-shrink: 0;
  padding: 0;
}

.sidebar-footer-btn:hover {
  background: #e2e8f0;
  color: #1e293b;
  transform: translateY(-1px);
}

.sidebar-footer-btn.btn-logout:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fecaca;
}

.sidebar-footer-btn svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.8;
}

/* ---- Mobile Close Button ---- */
.sidebar-close-btn {
  background: none;
  border: none;
  color: #64748b;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
  margin-left: auto;
}

.sidebar-close-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #1e293b;
}

[data-bs-theme="dark"] .sidebar-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
}

/* ---- Mobile Header ---- */
.mobile-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--tblr-bg-surface, #ffffff);
  border-bottom: 1px solid var(--tblr-border-color, #e6e7e9);
  display: none;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 1030;
}

.mobile-header-logo {
  height: 28px;
  width: auto;
}

.sidebar-mobile-toggle {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--tblr-body-color, #1e293b);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-mobile-toggle svg {
  width: 24px;
  height: 24px;
}

/* ---- Sidebar Overlay (mobile backdrop) ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  z-index: 1040;
}

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

/* ---- Responsive: Mobile (<768px) ---- */
@media (max-width: 767.98px) {
  .app-sidebar,
  .app-sidebar:hover {
    top: 0;
    left: 0;
    bottom: 0;
    border-radius: 0 24px 24px 0;
    width: 280px;
    max-width: 85vw;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    z-index: 1050;
  }

  .app-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 6px 0 32px rgba(0, 0, 0, 0.2);
  }

  .app-sidebar .sidebar-profile-info,
  .app-sidebar .sidebar-menu-text,
  .app-sidebar .sidebar-menu-arrow {
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .app-sidebar .sidebar-menu-item.open > .sidebar-submenu {
    max-height: 900px !important;
  }

  /* Mobile footer: ALWAYS inline horizontal row */
  .app-sidebar .sidebar-footer,
  .app-sidebar:not(:hover) .sidebar-footer,
  .app-sidebar:hover .sidebar-footer {
    flex-direction: row !important;
    justify-content: space-evenly !important;
    align-items: center !important;
    padding: 14px 16px !important;
    gap: 12px !important;
  }

  .app-sidebar .sidebar-footer .sidebar-footer-btn {
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }

  .app-sidebar .sidebar-footer .sidebar-footer-btn svg {
    width: 22px;
    height: 22px;
  }

  .mobile-header {
    display: flex;
  }

  .page > .page-wrapper {
    margin-left: 0;
    padding-top: 64px;
  }
}

/* ---- Dark Mode ---- */
[data-bs-theme="dark"] .app-sidebar {
  background: #182234;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

[data-bs-theme="dark"] .sidebar-header {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

[data-bs-theme="dark"] .sidebar-avatar-wrapper {
  background: #1e293b;
  border-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .sidebar-menu-link {
  color: #94a3b8;
}

[data-bs-theme="dark"] .sidebar-menu-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #f1f5f9;
}

[data-bs-theme="dark"] .sidebar-menu-item.active > .sidebar-menu-link {
  background: rgba(32, 107, 196, 0.2);
  color: #60a5fa;
}

[data-bs-theme="dark"] .sidebar-menu-item.active > .sidebar-menu-link .sidebar-menu-icon svg {
  stroke: #60a5fa;
}

[data-bs-theme="dark"] .sidebar-submenu .sidebar-menu-link {
  color: #64748b;
}

[data-bs-theme="dark"] .sidebar-submenu .sidebar-menu-link:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.04);
}

[data-bs-theme="dark"] .sidebar-submenu .sidebar-menu-item.active > .sidebar-menu-link {
  color: #60a5fa;
  background: rgba(32, 107, 196, 0.2);
}

[data-bs-theme="dark"] .sidebar-footer {
  border-top-color: rgba(255, 255, 255, 0.06);
}

[data-bs-theme="dark"] .sidebar-footer-btn {
  background: #1e2d44;
  color: #94a3b8;
}

[data-bs-theme="dark"] .sidebar-footer-btn:hover {
  background: #283955;
  color: #f1f5f9;
}

[data-bs-theme="dark"] .sidebar-footer-btn.btn-logout:hover {
  background: rgba(214, 57, 57, 0.25);
  color: #f87171;
  border-color: rgba(214, 57, 57, 0.3);
}

[data-bs-theme="dark"] .mobile-header {
  background: #182234;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .bg-light,
[data-bs-theme="dark"] .card-header.bg-light {
  background-color: var(--tblr-card-bg, #182234) !important;
  color: inherit !important;
}

/* ---- General helpers (preserved from original) ---- */
.wrap-text {
  white-space: normal !important;
  word-break: break-word;
}

#modal-confirmation, #modal-alert {
  z-index: 1060 !important;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
}

.permission-item {
  padding: 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.permission-item:hover {
  background-color: #f8f9fa;
}

.permission-label {
  word-break: break-word;
}

.module-counter {
  margin-left: 10px;
}

.no-results {
  padding: 2rem;
  text-align: center;
  width: 100%;
  color: #6c757d;
}
