/* ==========================================================================
   Ergon HR — Application Shell Design Tokens
   ========================================================================== */
:root {
  --shell-sidebar-width: 264px;
  --shell-topbar-height: 64px;
  --shell-radius-sm: 8px;
  --shell-radius-md: 12px;
  --shell-radius-lg: 16px;
  --shell-space-xs: 4px;
  --shell-space-sm: 8px;
  --shell-space-md: 16px;
  --shell-space-lg: 24px;
  --shell-space-xl: 32px;
  --shell-bg: #f1f5f9;
  --shell-surface: #ffffff;
  --shell-border: rgba(15, 23, 42, 0.08);
  --shell-text: #0f172a;
  --shell-text-muted: #64748b;
  --shell-sidebar-bg: linear-gradient(180deg, #0f172a 0%, #111827 55%, #0b1220 100%);
  --shell-sidebar-text: rgba(255, 255, 255, 0.78);
  --shell-sidebar-text-active: #ffffff;
  --shell-primary: #6366f1;
  --shell-primary-soft: rgba(99, 102, 241, 0.16);
  --shell-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shell-shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shell-transition: 180ms ease;
  --shell-focus-transition: 280ms cubic-bezier(0.4, 0, 0.2, 1);
  --shell-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ==========================================================================
   Shell layout
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--shell-bg);
  font-family: var(--shell-font);
  color: var(--shell-text);
}

.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--shell-sidebar-width);
  z-index: 1040;
  background: var(--shell-sidebar-bg);
  color: var(--shell-sidebar-text);
  display: flex;
  flex-direction: column;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.05);
  transition:
    transform var(--shell-focus-transition),
    width var(--shell-focus-transition),
    opacity var(--shell-focus-transition),
    left var(--shell-focus-transition),
    visibility var(--shell-focus-transition);
}

.app-main {
  flex: 1;
  margin-left: var(--shell-sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--shell-focus-transition);
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: var(--shell-topbar-height);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--shell-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--shell-space-lg);
  box-shadow: var(--shell-shadow-sm);
}

.app-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--shell-space-lg);
}

.app-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1035;
  opacity: 0;
  transition: opacity var(--shell-transition);
}

.app-shell.sidebar-open .app-sidebar-overlay {
  display: block;
  opacity: 1;
}

/* ==========================================================================
   Sidebar internals
   ========================================================================== */
.app-sidebar {
  box-shadow: none;
  border-right: 1px solid var(--shell-border);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 12px 10px;
  overflow: hidden;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0 -10px;
  padding: 0 10px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--ds-border, #e4e4e7) transparent;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 14px;
  flex-shrink: 0;
  color: var(--shell-text);
  text-decoration: none;
}

.sidebar-brand:hover {
  color: var(--shell-text);
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--shell-primary);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--shell-text);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-group-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ds-text-faint, #71717a);
  padding: 0 10px 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--shell-sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  transition: background var(--shell-transition), color var(--shell-transition);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.sidebar-link i.nav-icon {
  width: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--ds-text-faint, #71717a);
  transition: color var(--shell-transition);
}

.sidebar-link:hover {
  color: var(--shell-text);
  background: var(--ds-surface-hover, #f4f4f5);
}

.sidebar-link:hover i.nav-icon {
  color: var(--shell-text);
}

.sidebar-link.active {
  color: var(--shell-sidebar-text-active);
  background: var(--shell-primary-soft);
}

.sidebar-link.active i.nav-icon {
  color: var(--shell-primary);
}

/* A section toggle is only "active" in colour; the open submenu shows where you are. */
button.sidebar-link.active {
  background: transparent;
  color: var(--shell-text);
}

.sidebar-link .nav-chevron {
  margin-left: auto;
  font-size: 10px;
  color: var(--ds-text-faint, #71717a);
  transition: transform var(--shell-transition);
}

.sidebar-link .nav-chevron.open {
  transform: rotate(180deg);
}

.sidebar-submenu {
  display: none;
  flex-direction: column;
  gap: 1px;
  margin: 1px 0 4px 17px;
  padding-left: 9px;
  border-left: 1px solid var(--shell-border);
}

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

.sidebar-submenu .sidebar-link {
  min-height: 30px;
  font-size: 13px;
  padding: 0 10px;
}

.sidebar-footer {
  flex-shrink: 0;
  gap: 1px;
  padding-top: 8px;
  border-top: 1px solid var(--shell-border);
}

.sidebar-link.logout-link:hover {
  background: var(--ds-danger-soft, #fef2f2);
  color: var(--ds-danger, #b91c1c);
}

.sidebar-link.logout-link:hover i.nav-icon {
  color: var(--ds-danger, #b91c1c);
}

/* ==========================================================================
   Topbar
   ========================================================================== */
.app-topbar {
  background: color-mix(in srgb, var(--shell-surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  box-shadow: none;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.topbar-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  flex: none;
  border: 1px solid var(--shell-border);
  border-radius: 8px;
  background: var(--shell-surface);
  color: var(--shell-text);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--shell-transition);
}

.topbar-menu-btn:hover {
  background: var(--ds-surface-hover, #f4f4f5);
}

.topbar-heading {
  min-width: 0;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--shell-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(360px, 100%);
  min-height: 36px;
  margin-left: auto;
  padding: 0 8px 0 11px;
  border: 1px solid var(--shell-border);
  border-radius: 8px;
  background: var(--ds-surface-2, #fafafa);
  color: var(--shell-text-muted);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--shell-transition), background var(--shell-transition);
}

.topbar-search:hover {
  border-color: var(--ds-border-strong, #d4d4d8);
  background: var(--shell-surface);
}

.topbar-search span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.topbar-icon-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--shell-text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all var(--shell-transition);
  text-decoration: none;
}

.topbar-icon-btn:hover {
  color: var(--shell-text);
  background: var(--ds-surface-hover, #f4f4f5);
}

.topbar-icon-btn.is-active {
  color: var(--shell-primary);
  background: var(--shell-primary-soft);
}

.topbar-badge {
  position: absolute;
  top: -2px;
  right: -9px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  border: 2px solid var(--shell-surface);
  box-sizing: content-box;
  font-size: 10px;
  font-weight: 600;
  display: grid;
  place-items: center;
  line-height: 1;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px 3px 3px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  text-decoration: none;
  color: var(--shell-text);
  transition: background var(--shell-transition);
}

.topbar-user:hover {
  background: var(--ds-surface-hover, #f4f4f5);
  color: var(--shell-text);
}

.topbar-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--shell-primary-soft);
  color: var(--shell-sidebar-text-active);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
}

.topbar-user-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.topbar-user-role {
  font-size: 12px;
  color: var(--shell-text-muted);
}

/* ==========================================================================
   Profile menu (global account dropdown)
   ========================================================================== */
.profile-menu {
  position: relative;
}

.profile-menu-trigger {
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.profile-menu-trigger:hover,
.profile-menu.open .profile-menu-trigger {
  border-color: rgba(99, 102, 241, 0.35);
}

.profile-menu-chevron {
  font-size: 10px;
  color: var(--shell-text-muted);
  margin-left: 2px;
  transition: transform var(--shell-transition);
}

.profile-menu.open .profile-menu-chevron {
  transform: rotate(180deg);
}

.profile-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(300px, calc(100vw - 24px));
  background: var(--shell-surface);
  border: 1px solid var(--shell-border);
  border-radius: var(--shell-radius-lg);
  box-shadow: var(--shell-shadow-md), 0 20px 50px rgba(15, 23, 42, 0.12);
  z-index: 1080;
  padding: 8px 0;
  overflow: hidden;
}

.profile-menu-header {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  align-items: center;
}

.profile-menu-header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 800;
  flex-shrink: 0;
}

.profile-menu-header-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--shell-text);
  line-height: 1.2;
}

.profile-menu-header-email {
  font-size: 12px;
  color: var(--shell-text-muted);
  margin-top: 2px;
  word-break: break-all;
}

.profile-menu-role-badge {
  display: inline-block;
  margin-top: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--shell-primary-soft);
  color: var(--shell-primary);
}

.profile-menu-divider {
  height: 1px;
  background: var(--shell-border);
  margin: 6px 0;
}

.profile-menu-item,
.profile-menu-subitem {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--shell-text);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--shell-transition);
  text-align: left;
}

.profile-menu-item i:first-child {
  width: 18px;
  text-align: center;
  color: var(--shell-text-muted);
  font-size: 14px;
}

.profile-menu-item:hover,
.profile-menu-item:focus,
.profile-menu-subitem:hover,
.profile-menu-subitem:focus {
  background: rgba(99, 102, 241, 0.06);
  color: var(--shell-text);
  outline: none;
}

.profile-menu-item-value {
  margin-left: auto;
  font-size: 12px;
  color: var(--shell-text-muted);
  font-weight: 500;
}

.profile-menu-item-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--shell-text-muted);
  opacity: 0.6;
}

.profile-menu-sub-chevron {
  margin-left: 4px;
  font-size: 10px;
  color: var(--shell-text-muted);
  transition: transform var(--shell-transition);
}

.profile-menu-item-toggle.open .profile-menu-sub-chevron {
  transform: rotate(180deg);
}

.profile-menu-submenu {
  padding: 0 8px 6px 36px;
}

.profile-menu-subitem {
  padding: 8px 12px;
  border-radius: var(--shell-radius-sm);
  font-size: 13px;
}

.profile-menu-subitem.active,
.profile-menu-subitem[aria-checked="true"] {
  background: var(--shell-primary-soft);
  color: var(--shell-primary);
}

.profile-menu-item-danger {
  color: #dc2626;
}

.profile-menu-item-danger i:first-child {
  color: #dc2626;
}

.profile-menu-item-danger:hover {
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
}

/* Dark theme colours live in design-system.css */

[data-theme="dark"] .profile-menu-dropdown {
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.pref-compact-sidebar .sidebar-link span:not(.nav-icon),
.pref-compact-sidebar .workspace-label {
  font-size: 12px;
}

.pref-reduced-motion *,
.pref-reduced-motion *::before,
.pref-reduced-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

/* ==========================================================================
   Content area helpers (used by existing pages)
   ========================================================================== */
.app-content .main-content,
.app-content .page-header {
  background: transparent;
  min-height: auto;
  padding: 0;
}

.app-content .page-title {
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--shell-text);
}

.app-content .page-subtitle {
  color: var(--shell-text-muted);
}

/* Notification modal items (legacy) */
.notification-item {
  padding: 12px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}
.notification-item:hover { background: #f8fafc; }
.notification-item.unread { background: #fffbeb; }
.notification-item .time { font-size: 11px; color: #94a3b8; }

/* ==========================================================================
   Notification Center (global panel)
   ========================================================================== */
.nc-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1090;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 200ms ease;
}

.nc-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.notification-center {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 100vw);
  height: 100vh;
  background: var(--shell-surface);
  border-left: 1px solid var(--shell-border);
  box-shadow: none;
  visibility: hidden;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  /* Stay visible while sliding out, then hide so the closed panel casts no shadow */
  transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1), visibility 0s linear 280ms;
}

.notification-center.open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -12px 0 40px rgba(15, 23, 42, 0.12);
}

.nc-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 1.25rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--shell-border);
}

.nc-title {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0;
  color: var(--shell-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.nc-subtitle {
  font-size: 12px;
  color: var(--shell-text-muted);
  margin: 4px 0 0;
}

.nc-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--shell-border);
  border-radius: 10px;
  background: transparent;
  color: var(--shell-text-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.nc-close:hover {
  background: #f8fafc;
  color: var(--shell-text);
}

.nc-tabs {
  display: flex;
  gap: 6px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--shell-border);
  flex-shrink: 0;
}

.nc-tab {
  border: 1px solid var(--shell-border);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--shell-text-muted);
  white-space: nowrap;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 150ms ease;
}

.nc-tab:hover {
  border-color: rgba(99, 102, 241, 0.35);
  color: var(--shell-primary);
}

.nc-tab.active {
  background: var(--shell-primary);
  border-color: var(--shell-primary);
  color: #fff;
}

.nc-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.nc-item {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  display: flex;
  gap: 12px;
  padding: 12px 1rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  cursor: pointer;
  position: relative;
  transition: background 150ms ease;
}

.nc-item:hover {
  background: #f8fafc;
}

.nc-item.unread {
  background: rgba(99, 102, 241, 0.04);
}

.nc-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 16px;
}

.nc-item-body {
  flex: 1;
  min-width: 0;
}

.nc-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.nc-item-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--shell-text);
}

.nc-item-msg {
  font-size: 13px;
  color: var(--shell-text-muted);
  margin: 4px 0 6px;
  line-height: 1.4;
}

.nc-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nc-cat-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
}

.nc-time {
  font-size: 11px;
  color: #94a3b8;
}

.nc-priority {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.nc-unread-dot {
  position: absolute;
  top: 18px;
  right: 14px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--shell-primary);
}

.nc-footer {
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--shell-border);
  display: flex;
  gap: 8px;
  justify-content: space-between;
  flex-shrink: 0;
}

.nc-empty,
.nc-loading {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--shell-text-muted);
}

.nc-empty i {
  font-size: 2rem;
  opacity: 0.4;
  margin-bottom: 0.75rem;
}

.nc-error {
  color: #b91c1c;
}

/* ==========================================================================
   Focus mode (collapse sidebar, expand content)
   ========================================================================== */
@media (min-width: 992px) {
  html[data-focus-mode] .app-sidebar,
  .app-shell.focus-mode .app-sidebar {
    left: calc(-1 * var(--shell-sidebar-width));
    width: 0;
    min-width: 0;
    transform: translateX(-100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    overflow: hidden;
  }

  html[data-focus-mode] .app-main,
  .app-shell.focus-mode .app-main {
    margin-left: 0;
    width: 100%;
  }
}

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

  .app-shell.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

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

  .topbar-menu-btn {
    display: inline-flex;
  }

  .topbar-user-meta {
    display: none;
  }

  .app-content {
    padding: var(--shell-space-md);
  }
}

@media (max-width: 575.98px) {
  .topbar-title {
    font-size: 16px;
  }
}


/* Bootstrap modals above app shell (sidebar z-index: 1040) */
.modal-backdrop {
  z-index: 1080 !important;
}

.modal {
  z-index: 1090 !important;
}

/* Auth / landing pages bypass shell */
body.auth .app-shell,
body.landing .app-shell {
  display: none;
}
