/*
 * Lyvion Hub — application shell after the legacy index.php: fixed header (60px),
 * fixed sidebar (60px, 240px on hover or keyboard focus), content area.
 * Mobile (< 768px, E52): menu button in the header opens the sidebar as a drawer.
 */

/* Header */
.app-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: var(--layer-header);
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0 var(--space-5);
  background: var(--sidebar-bg);
  border-bottom: var(--border-width) solid var(--border-color);
  transition: background-color var(--motion) var(--ease);
}

.app-header__start,
.app-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-primary);
  text-decoration: none;
}

.app-brand__icon {
  width: var(--brand-icon-size);
  height: var(--brand-icon-size);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--bg-gradient);
  color: var(--text-on-primary);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
}

/* Two or more characters ("LH", several emoji): smaller so they stay inside the box */
.app-brand__icon--long {
  font-size: var(--text-sm);
}

/* No coloured box: the symbol alone, in the accent colour */
.app-brand__icon--plain {
  background: none;
  color: var(--primary);
}

.app-brand__name {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
}

/* Header icon buttons (legacy .nav-btn) */
.header-btn {
  min-width: var(--control-height-icon);
  height: var(--control-height-header);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-4);
  border: var(--border-width) solid var(--border-color);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color var(--motion-fast) var(--ease), border-color var(--motion-fast) var(--ease);
}

.header-btn:hover {
  background: var(--hover-bg);
  border-color: var(--primary);
}

.header-btn--menu {
  display: none;
}

/* Sidebar */
.app-sidebar {
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  z-index: var(--layer-sidebar);
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--sidebar-bg);
  border-right: var(--border-width) solid var(--border-color);
  transition: width var(--motion) var(--ease), background-color var(--motion) var(--ease);
}

.app-sidebar:hover,
.app-sidebar:focus-within {
  width: var(--sidebar-width-open);
  box-shadow: var(--shadow-lg);
}

.app-sidebar__nav {
  flex: 1;
  padding: var(--space-3) 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
}

.app-sidebar__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Section heading of the menu (legacy: small capitals, secondary colour, divider above). Collapsed, only the divider shows. */
.sidebar-section {
  margin-top: var(--space-2);
  padding: var(--space-3) var(--space-4) var(--space-1);
  border-top: var(--border-width) solid var(--border-color);
}

.sidebar-section__label {
  display: block;
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--motion-fast) var(--ease);
}

.app-sidebar:hover .sidebar-section__label,
.app-sidebar:focus-within .sidebar-section__label,
.app-sidebar.is-open .sidebar-section__label {
  opacity: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--nav-item-height);
  padding: var(--space-1) var(--space-3);
  border-left: var(--border-width-accent) solid transparent;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}

.sidebar-link:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
}

.sidebar-link[aria-current="page"] {
  background: var(--primary-bg-strong);
  border-left-color: var(--primary);
  color: var(--primary);
}

.sidebar-link__icon {
  width: var(--nav-icon-size);
  height: var(--nav-icon-size);
  min-width: var(--nav-icon-size);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--primary-bg);
  font-size: var(--text-xl);
}

.sidebar-link__text {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  opacity: 0;
  transition: opacity var(--motion-fast) var(--ease);
}

/* Count beside an entry (accounts waiting for approval); shown with the text, i.e. when the sidebar is wide */
.sidebar-link__badge {
  margin-left: auto;
  min-width: var(--space-5);
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--warning-bg);
  color: var(--warning);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: var(--space-5);
  text-align: center;
  opacity: 0;
  transition: opacity var(--motion-fast) var(--ease);
}

.app-sidebar:hover .sidebar-link__badge,
.app-sidebar:focus-within .sidebar-link__badge,
.app-sidebar.is-open .sidebar-link__badge {
  opacity: 1;
}

.sidebar-user__text {
  opacity: 0;
  transition: opacity var(--motion-fast) var(--ease);
}

.app-sidebar:hover .sidebar-link__text,
.app-sidebar:focus-within .sidebar-link__text,
.app-sidebar.is-open .sidebar-link__text,
.app-sidebar:hover .sidebar-user__text,
.app-sidebar:focus-within .sidebar-user__text,
.app-sidebar.is-open .sidebar-user__text {
  opacity: 1;
}

/* An open user menu keeps the sidebar wide, even when the pointer leaves it */
.app-sidebar:has(.dropdown__menu:not([hidden])) {
  width: var(--sidebar-width-open);
  box-shadow: var(--shadow-lg);
}

.app-sidebar__bottom {
  border-top: var(--border-width) solid var(--border-color);
}

.drawer-backdrop {
  display: none;
}

/* Content */
.app-main {
  /* padding instead of margin: a top margin would collapse into body and add a scrollbar */
  min-height: 100vh;
  padding: calc(var(--header-height) + var(--content-padding)) var(--content-padding) var(--content-padding)
    calc(var(--sidebar-width) + var(--content-padding));
}

.app-main:focus {
  outline: none;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.page-header__title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
}

.page-header__subtitle {
  margin-top: var(--space-1);
  color: var(--text-secondary);
  font-size: var(--text-md);
}

.page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* Mobile: menu button + drawer (E52) */
@media (max-width: 767px) {
  .header-btn--menu {
    display: inline-flex;
  }

  .app-sidebar {
    width: var(--sidebar-width-open);
    z-index: var(--layer-drawer);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform var(--motion) var(--ease), visibility 0s linear var(--motion);
  }

  .app-sidebar:hover,
  .app-sidebar:focus-within {
    width: var(--sidebar-width-open);
    box-shadow: none;
  }

  .app-sidebar.is-open {
    transform: none;
    visibility: visible;
    box-shadow: var(--shadow-lg);
    transition: transform var(--motion) var(--ease), visibility 0s;
  }

  .sidebar-section__label,
  .sidebar-link__text,
  .sidebar-user__text {
    opacity: 1;
  }

  .drawer-backdrop.is-open {
    display: block;
    position: fixed;
    inset: var(--header-height) 0 0 0;
    z-index: var(--layer-drawer-backdrop);
    background: var(--overlay-bg);
  }

  .app-main {
    padding: calc(var(--header-height) + var(--space-4)) var(--space-4) var(--space-4);
  }

  .app-brand__name {
    display: none;
  }
}

/* Theme switch shows the target mode's symbol */
[data-theme="dark"] .theme-icon--light,
[data-theme="light"] .theme-icon--dark {
  display: none;
}

/* Turbo page-load bar (appears when a page change takes longer than 500 ms) in the accent colour */
.turbo-progress-bar {
  height: var(--progress-height);
  background: var(--bg-gradient);
}
