/* ==========================================================================
   De Novo NoMo — Layout (Sidebar / Topbar / Content)
   ========================================================================== */

/* ---------- App Layout Shell ---------- */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--color-primary-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 900;
  transition: width 0.25s ease;
}

.sidebar-collapsed .sidebar,
.sidebar.is-collapsed {
  width: var(--sidebar-collapsed);
}

/* ---------- Sidebar Header ---------- */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 56px;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--color-accent-400);
  border-radius: var(--radius-default);
  flex-shrink: 0;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--color-primary-900);
}

.sidebar-brand {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9375rem;
  white-space: nowrap;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.sidebar.is-collapsed .sidebar-brand {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: auto;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

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

.sidebar.is-collapsed .sidebar-toggle {
  margin-left: 0;
}

/* ---------- Sidebar Navigation ---------- */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: var(--space-3) var(--space-2);
  gap: 2px;
}

.sidebar-section {
  margin-bottom: var(--space-3);
}

.sidebar-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.35);
  padding: var(--space-2) var(--space-3);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.is-collapsed .sidebar-section-label {
  opacity: 0;
  height: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px 12px;
  border-radius: var(--radius-default);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  position: relative;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-decoration: none;
}

.nav-item.is-active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.nav-item.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--color-accent-400);
  border-radius: 0 2px 2px 0;
}

.nav-item svg,
.nav-item i {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.is-active svg,
.nav-item.is-active i {
  opacity: 1;
}

.nav-item-label {
  opacity: 1;
  transition: opacity 0.2s ease;
}

.sidebar.is-collapsed .nav-item-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.nav-item-badge {
  margin-left: auto;
  background: var(--color-accent-500);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  line-height: 1.4;
}

.sidebar.is-collapsed .nav-item-badge {
  display: none;
}

/* Sub-items (e.g., Locations) */
.nav-sub-items {
  padding-left: 34px;
}

.nav-sub-items .nav-item {
  font-size: 0.8125rem;
  padding: 6px 12px;
  color: rgba(255, 255, 255, 0.55);
}

.nav-sub-items .nav-item.is-active {
  color: #fff;
}

.sidebar.is-collapsed .nav-sub-items {
  display: none;
}

/* ---------- Sidebar Footer ---------- */
.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: var(--space-3) var(--space-3);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2);
  border-radius: var(--radius-default);
  cursor: pointer;
  transition: background 0.15s ease;
}

.sidebar-user:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-user .avatar {
  background: var(--color-accent-400);
  color: var(--color-primary-900);
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.sidebar-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.6875rem;
  color: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
}

.sidebar.is-collapsed .sidebar-user-info {
  display: none;
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.25s ease;
}

.sidebar-collapsed .main-content,
.main-content.sidebar-is-collapsed {
  margin-left: var(--sidebar-collapsed);
}

/* ==========================================================================
   Topbar
   ========================================================================== */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 var(--space-5);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.topbar-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-default);
  color: var(--color-text);
  cursor: pointer;
}

.topbar-hamburger:hover {
  background: var(--color-bg-subtle);
}

/* Topbar action buttons */
.topbar-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-default);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  position: relative;
}

.topbar-action:hover {
  background: var(--color-bg-subtle);
  color: var(--color-text);
}

.topbar-action svg {
  width: 18px;
  height: 18px;
}

/* Notification badge on bell */
.notification-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--color-error);
  border-radius: 50%;
  border: 2px solid var(--color-bg);
}

/* User menu in topbar */
.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 8px 4px 4px;
  border-radius: var(--radius-default);
  cursor: pointer;
  transition: background 0.12s ease;
}

.topbar-user:hover {
  background: var(--color-bg-subtle);
}

.topbar-user-name {
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
}

/* ==========================================================================
   Breadcrumb
   ========================================================================== */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  min-width: 0;
}

.breadcrumb-item {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.breadcrumb-item a {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color 0.12s ease;
}

.breadcrumb-item a:hover {
  color: var(--color-text);
  text-decoration: none;
}

.breadcrumb-separator {
  color: var(--color-border);
  margin: 0 2px;
  user-select: none;
}

.breadcrumb-item:last-child {
  color: var(--color-text);
  font-weight: 500;
}

/* ==========================================================================
   Content Area
   ========================================================================== */

.content-area {
  flex: 1;
  padding: var(--space-6);
  overflow-y: auto;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.content-header h1 {
  font-size: 1.5rem;
}

.content-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ==========================================================================
   Command Palette
   ========================================================================== */

.command-palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 42, 67, 0.45);
  backdrop-filter: blur(4px);
  z-index: 1100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.command-palette-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

.command-palette {
  background: var(--color-bg);
  border-radius: var(--radius-modal);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 520px;
  overflow: hidden;
  transform: translateY(-8px) scale(0.98);
  transition: transform 0.15s ease;
}

.command-palette-overlay.is-active .command-palette {
  transform: translateY(0) scale(1);
}

.command-palette-input {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.command-palette-input svg {
  width: 18px;
  height: 18px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.command-palette-input input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 0.9375rem;
  background: transparent;
}

.command-palette-input kbd {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  padding: 2px 6px;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
}

.command-palette-results {
  max-height: 320px;
  overflow-y: auto;
  padding: var(--space-2) 0;
}

.command-palette-group-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  padding: var(--space-2) var(--space-5);
}

.command-palette-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px var(--space-5);
  cursor: pointer;
  transition: background 0.1s ease;
  font-size: 0.875rem;
}

.command-palette-item:hover,
.command-palette-item.is-highlighted {
  background: var(--color-bg-subtle);
}

.command-palette-item svg {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.command-palette-empty {
  padding: var(--space-7) var(--space-5);
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

/* ==========================================================================
   Notification Dropdown
   ========================================================================== */

.notification-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 360px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
}

.notification-dropdown.is-active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.notification-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  font-size: 0.8125rem;
  font-weight: 600;
}

.notification-list {
  max-height: 380px;
  overflow-y: auto;
}

.notification-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background 0.1s ease;
}

.notification-item:hover {
  background: var(--color-bg-subtle);
}

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

.notification-item.is-unread {
  background: var(--color-primary-50);
}

.notification-item-content {
  flex: 1;
  min-width: 0;
}

.notification-item-title {
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: 2px;
}

.notification-item-time {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
}

/* ==========================================================================
   Responsive — Tablet & Mobile (< 1024px)
   ========================================================================== */

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 1000;
    box-shadow: none;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.is-collapsed {
    width: var(--sidebar-width);
  }

  .sidebar-toggle {
    display: none;
  }

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

  .main-content.sidebar-is-collapsed {
    margin-left: 0;
  }

  .topbar-hamburger {
    display: flex;
  }

  /* Overlay behind sidebar */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(16, 42, 67, 0.4);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
  }

  .sidebar-overlay.is-active {
    opacity: 1;
    visibility: visible;
  }

  .content-area {
    padding: var(--space-4);
  }

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

@media (max-width: 640px) {
  .content-area {
    padding: var(--space-3);
  }

  .content-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar {
    padding: 0 var(--space-3);
  }
}
