/**
 * Application layout shell styles.
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--apj-font);
  background: var(--apj-body-bg);
  color: var(--apj-text);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--apj-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

code {
  font-family: var(--apj-mono);
  font-size: 0.9em;
  background: var(--apj-primary-soft);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}


.text-muted { color: var(--apj-muted) !important; }
.text-center { text-align: center; }
.small { font-size: 0.875rem; }

/* Layout */
#layout-wrapper {
  min-height: 100vh;
}

.main-content {
  margin-left: var(--apj-sidebar-width);
  padding-top: var(--apj-topbar-height);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease;
}

body[data-sidebar-size="sm"] .main-content {
  margin-left: var(--apj-sidebar-collapsed);
}

.page-content {
  flex: 1;
  padding: 1.25rem 0 2rem;
}

.container-fluid {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.app-content {
  min-height: 280px;
  position: relative;
}

/* Topbar */
.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--apj-sidebar-width);
  height: var(--apj-topbar-height);
  background: var(--apj-topbar-bg);
  border-bottom: 1px solid var(--apj-border);
  z-index: 1002;
  transition: left 0.2s ease;
}

body[data-sidebar-size="sm"] .topbar {
  left: var(--apj-sidebar-collapsed);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 1rem;
  gap: 0.75rem;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--apj-text);
  text-decoration: none;
  font-weight: 700;
}

.brand-logo:hover { text-decoration: none; }

.brand-logo-img {
  height: 32px;
  width: auto;
  max-width: 150px;
  object-fit: contain;
  display: block;
}

.brand-text {
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--apj-text);
  border-radius: 8px;
  cursor: pointer;
  position: relative;
}

.btn-icon:hover {
  background: var(--apj-primary-soft);
  color: var(--apj-primary);
}

.btn-icon .icon,
.icon {
  width: 20px;
  height: 20px;
}

.icon-sm {
  width: 16px;
  height: 16px;
}

.badge-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--apj-danger);
}

.badge-count {
  position: absolute;
  top: 4px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--apj-danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.badge-count[hidden],
.badge-dot[hidden] {
  display: none !important;
}

.dropdown-menu-notif {
  width: min(360px, calc(100vw - 1.5rem));
  max-height: min(420px, 70vh);
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dropdown-menu-notif[hidden] {
  display: none !important;
}

.dropdown-header-notif {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--apj-border);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--apj-text);
}

#staff-notif-mark-all {
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 0.25rem 0.55rem;
}

#staff-notif-mark-all[hidden] {
  display: none !important;
}

.staff-notif-list {
  overflow-y: auto;
  max-height: 340px;
}

.staff-notif-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  width: 100%;
  text-align: left;
  white-space: normal;
  border-bottom: 1px solid var(--apj-border);
  padding: 0.85rem 1rem;
  cursor: pointer;
}

.staff-notif-item:last-child {
  border-bottom: none;
}

.staff-notif-item.is-unread {
  background: rgba(11, 58, 102, 0.06);
}

.staff-notif-item:hover {
  background: var(--apj-primary-soft);
}

.staff-notif-type {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  background: var(--apj-primary-soft);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--apj-primary);
  line-height: 1.3;
}

.staff-notif-title {
  display: block;
  width: 100%;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--apj-text);
  line-height: 1.35;
}

.staff-notif-body {
  display: block;
  width: 100%;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--apj-muted);
}

.staff-notif-meta {
  display: block;
  font-size: 0.72rem;
  color: var(--apj-muted);
  margin-top: 0.1rem;
}

.nav-group-label {
  flex: 1 1 auto;
  min-width: 0;
}

.nav-badge {
  margin-left: 0.35rem;
  margin-right: 0;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--apj-danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  flex-shrink: 0;
  line-height: 1;
}

.nav-badge[hidden] {
  display: none !important;
}

body[data-sidebar-size="sm"] .nav-badge {
  display: none !important;
}

.user-trigger {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  border: none;
  background: transparent;
  color: var(--apj-text);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
}

.user-trigger:hover {
  background: var(--apj-primary-soft);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--apj-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.user-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 600;
}

.user-role {
  font-size: 0.75rem;
  color: var(--apj-muted);
}

/* Dropdown */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--apj-surface);
  border: 1px solid var(--apj-border);
  border-radius: var(--apj-radius);
  box-shadow: var(--apj-shadow-lg);
  padding: 0.5rem 0;
  z-index: 1100;
}

.dropdown-header {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--apj-muted);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--apj-text);
  padding: 0.55rem 1rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.dropdown-item:hover:not(:disabled) {
  background: var(--apj-primary-soft);
}

.dropdown-item:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.dropdown-header.dropdown-header-notif {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--apj-text);
}

.dropdown-item.staff-notif-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 0.85rem 1rem;
  white-space: normal;
  border-bottom: 1px solid var(--apj-border);
}

.dropdown-item.staff-notif-item:last-child {
  border-bottom: none;
}

.dropdown-divider {
  height: 1px;
  background: var(--apj-border);
  margin: 0.35rem 0;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--apj-sidebar-width);
  height: 100vh;
  background: var(--apj-sidebar-bg);
  border-right: 1px solid var(--apj-border);
  z-index: 1003;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, transform 0.2s ease;
  overflow: hidden;
}

body[data-sidebar-size="sm"] .sidebar {
  width: var(--apj-sidebar-collapsed);
}

.sidebar-header {
  height: var(--apj-topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  border-bottom: 1px solid var(--apj-border);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--apj-text);
  text-decoration: none;
  font-weight: 700;
  overflow: hidden;
}

.sidebar-brand:hover { text-decoration: none; }

.sidebar-brand-logo {
  display: block;
  height: 32px;
  width: auto;
  max-width: 168px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0.5rem 1.5rem;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* legacy Edge */
}

.sidebar-nav::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.nav-group {
  margin-bottom: 0.35rem;
}

.nav-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border: none;
  background: transparent;
  color: var(--apj-muted);
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
}

.nav-group-toggle:hover {
  background: var(--apj-primary-soft);
  color: var(--apj-primary);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-chevron {
  width: 14px;
  height: 14px;
  margin-left: auto;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.nav-group.collapsed .nav-chevron {
  transform: rotate(-90deg);
}

.nav-group.collapsed .nav-items {
  display: none;
}

.nav-items {
  list-style: none;
  margin: 0;
  padding: 0 0 0 0.5rem;
}

.nav-link {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  color: var(--apj-text);
  font-size: 0.9rem;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--apj-primary-soft);
  color: var(--apj-primary);
  text-decoration: none;
}

.nav-link.active {
  background: var(--apj-primary);
  color: #fff;
  font-weight: 600;
}

body[data-sidebar-size="sm"] .sidebar-brand-text,
body[data-sidebar-size="sm"] .nav-group-label,
body[data-sidebar-size="sm"] .nav-chevron,
body[data-sidebar-size="sm"] .nav-items {
  display: none;
}

body[data-sidebar-size="sm"] .sidebar-brand-logo {
  height: 22px;
  max-width: 52px;
}

body[data-sidebar-size="sm"] .nav-group-toggle {
  justify-content: center;
  padding: 0.65rem;
}

body[data-sidebar-size="sm"] .sidebar-header {
  justify-content: center;
  padding: 0;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1002;
}

/* Breadcrumb & title */
.breadcrumb-nav {
  margin-bottom: 0.5rem;
}

.breadcrumb-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
  color: var(--apj-muted);
}

.breadcrumb-item:not(:last-child)::after {
  content: "/";
  margin-left: 0.35rem;
  color: var(--apj-muted);
}

.breadcrumb-item a {
  color: var(--apj-muted);
}

.breadcrumb-item.active {
  color: var(--apj-text);
  font-weight: 600;
}

.page-title-box {
  margin-bottom: 1.25rem;
}

.page-title {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 700;
}

.page-description {
  margin: 0;
  font-size: 0.9rem;
}

/* Footer */
.app-footer {
  border-top: 1px solid var(--apj-border);
  background: var(--apj-surface);
  padding: 0.85rem 1.25rem;
  margin-top: auto;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--apj-muted);
  max-width: 1400px;
  margin: 0 auto;
}

/* Page progress bar */
.page-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--apj-primary), #38bdf8);
  z-index: 2000;
  transition: width 0.2s ease;
}

.page-progress.is-active {
  width: 70%;
}

.page-progress.is-done {
  width: 100%;
  opacity: 0;
  transition: width 0.15s ease, opacity 0.3s ease 0.15s;
}

.btn-mobile-only {
  display: none;
  }
/* Utility */
.d-none { display: none !important; }

[hidden] {
    display: none !important;
}
