/* Material 3 MudBlazor overrides — AppBar, Drawer, NavLink, Buttons, Table. */

.yg-shell-layout {
  --yg-shell-appbar-h: 64px;
  --yg-shell-drawer-w: 280px;
  --yg-shell-rail-w: 48px;
  --yg-shell-content-offset: 0px;
  --yg-shell-drawer-current-w: var(--yg-shell-drawer-w);
  min-height: 100vh;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--md-sys-color-background);
}

.yg-shell-layout.yg-shell--desktop-expanded {
  --yg-shell-content-offset: var(--yg-shell-drawer-w);
  --yg-shell-drawer-current-w: var(--yg-shell-drawer-w);
}

.yg-shell-layout.yg-shell--desktop-collapsed,
.yg-shell-layout.yg-shell--tablet {
  --yg-shell-content-offset: var(--yg-shell-rail-w);
  --yg-shell-drawer-current-w: var(--yg-shell-rail-w);
}

.yg-shell-layout.yg-shell--tablet-overlay {
  --yg-shell-content-offset: var(--yg-shell-rail-w);
  --yg-shell-drawer-current-w: var(--yg-shell-drawer-w);
}

.yg-shell-layout.yg-shell--mobile,
.yg-shell-layout.yg-shell--no-drawer {
  --yg-shell-content-offset: 0px;
}

.yg-shell-layout .yg-shell-drawer.mud-drawer {
  top: var(--yg-shell-appbar-h) !important;
  width: var(--yg-shell-drawer-current-w) !important;
  min-width: var(--yg-shell-drawer-current-w) !important;
  max-width: var(--yg-shell-drawer-current-w) !important;
  height: calc(100vh - var(--yg-shell-appbar-h)) !important;
  max-height: calc(100vh - var(--yg-shell-appbar-h)) !important;
  height: calc(100dvh - var(--yg-shell-appbar-h)) !important;
  max-height: calc(100dvh - var(--yg-shell-appbar-h)) !important;
  z-index: calc(var(--mud-zindex-appbar) - 1) !important;
  overflow-x: hidden;
  border-right: none;
  background: color-mix(in oklch, var(--md-sys-color-surface) 84%, transparent) !important;
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
  transition:
    width var(--transition-medium),
    min-width var(--transition-medium),
    max-width var(--transition-medium),
    transform var(--transition-medium);
}

.yg-shell-layout.yg-shell--mobile .yg-shell-drawer.mud-drawer,
.yg-shell-layout.yg-shell--tablet-overlay .yg-shell-drawer.mud-drawer {
  width: var(--yg-shell-drawer-w) !important;
  min-width: var(--yg-shell-drawer-w) !important;
  max-width: var(--yg-shell-drawer-w) !important;
}

.yg-shell-layout.yg-shell--tablet-overlay .yg-shell-drawer.mud-drawer {
  box-shadow: 18px 0 36px color-mix(in oklch, black 22%, transparent);
}

.yg-shell-brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1.25rem 1rem 1rem;
}

.yg-shell-brand-copy {
  display: grid;
  gap: 0.1rem;
}

.yg-shell-nav-wrap {
  padding: 0.5rem 0.75rem;
  flex: 1 1 auto;
}

/* MudDivider inside drawer must not stretch — its default flex:1 0 auto pushes nav down. */
.yg-shell-drawer .mud-drawer-content > .mud-divider,
.yg-shell-drawer .mud-drawer-content > hr.mud-divider {
  flex: 0 0 auto !important;
  height: 1px;
}

.yg-shell-nav {
  gap: 0.25rem;
}

/* M3 Navigation Drawer Item — pill-right, active filled with secondary-container */
.yg-shell-link {
  border-radius: 9999px !important;
  padding: 0.75rem 1rem !important;
  min-height: 56px;
  color: var(--md-sys-color-on-surface-variant) !important;
  overflow: hidden;
  transition:
    background var(--transition-fast),
    color var(--transition-fast);
}

/* Keep the label on a single line with ellipsis so it can't wrap into
   two rows mid-drawer-transition. During the 225 ms expand/collapse the
   link width grows/shrinks smoothly; clipping the overflow avoids the
   visual "drift" where labels split onto multiple lines for a frame. */
.yg-shell-link .mud-nav-link-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.yg-shell-link-copy {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.yg-shell-link:hover {
  background: color-mix(in oklch, var(--md-sys-color-on-surface) 8%, transparent) !important;
  color: var(--md-sys-color-on-surface) !important;
  transform: none;
}

.yg-shell-link.is-active {
  background: var(--md-sys-color-secondary-container) !important;
  color: var(--md-sys-color-on-secondary-container) !important;
  transform: none;
  border: none;
}

.yg-shell-link.is-active .mud-nav-link-icon {
  color: var(--md-sys-color-on-secondary-container);
}

.yg-shell-link .mud-nav-link-icon {
  margin-inline-end: 0.75rem;
  color: inherit;
}

.yg-shell-rail-footer {
  display: grid;
  gap: 0.75rem;
  padding: 0.75rem;
  margin-top: auto;
}

.yg-shell-rail-footer:empty {
  display: none;
}

.yg-shell-main {
  position: fixed;
  top: var(--yg-shell-appbar-h);
  bottom: 0;
  left: 0;
  min-height: 0;
  height: calc(100vh - var(--yg-shell-appbar-h));
  height: calc(100dvh - var(--yg-shell-appbar-h));
  min-width: 0;
  width: calc(100% - var(--yg-shell-content-offset)) !important;
  max-width: calc(100% - var(--yg-shell-content-offset)) !important;
  margin-left: var(--yg-shell-content-offset) !important;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  background: var(--md-sys-color-background);
  transition:
    margin-left var(--transition-medium),
    width var(--transition-medium),
    max-width var(--transition-medium);
}

.yg-shell-stage {
  padding-top: 0;
}

/* M3 Top App Bar (Small) */
.yg-shell-appbar {
  display: flex;
  flex-direction: row !important;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  max-width: none !important;
  height: var(--yg-shell-appbar-h);
  min-height: var(--yg-shell-appbar-h);
  margin-left: 0 !important;
  transform: none !important;
  padding-block: 0;
  padding-inline: 8px;
  border-bottom: 1px solid color-mix(in oklch, var(--md-sys-color-outline-variant) 38%, transparent);
  box-shadow: none;
  background: color-mix(in oklch, var(--md-sys-color-surface) 72%, transparent) !important;
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.yg-shell-topbar-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1 1 auto;
}

.yg-shell-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-inline-end: 1rem;
  flex-wrap: nowrap;
  flex: 0 0 auto;
}

.yg-shell-topbar-actions > [data-sep] {
  border-left: 1px solid var(--md-sys-color-outline-variant);
  padding-left: 0.55rem;
  margin-left: 0.5rem;
}

.yg-shell-topbar-copy {
  display: grid;
  gap: 0.05rem;
  min-width: 0;
}

.yg-shell-kicker {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1rem;
}

.yg-shell-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.375rem;
  font-weight: 400;
  line-height: 1.75rem;
  letter-spacing: 0;
  color: var(--md-sys-color-on-surface);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.yg-shell-content {
  padding: 1.5rem !important;
}

.yg-shell-appbar .mud-button-root,
.yg-shell-appbar .mud-input-control,
.yg-shell-appbar .mud-chip {
  margin: 0;
}

/* MudAppBar wraps its content in .mud-toolbar; let the toolbar follow the
   shell geometry instead of MudBlazor drawer layout classes. */
.yg-shell-appbar .mud-toolbar {
  flex: 1 1 auto !important;
  width: 100%;
  padding-inline: 0 !important;
}

/* --- M3 Buttons ------------------------------------------------------- */
.mud-button-root {
  text-transform: none !important;
  border-radius: 9999px !important;
  height: 40px;
  min-height: 40px;
  padding-inline: 24px !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  letter-spacing: 0.00625rem !important;
  line-height: 1.25rem !important;
  box-shadow: none !important;
  transition: background var(--transition-fast), color var(--transition-fast);
}

/* Filled */
.mud-button-filled.mud-button-filled-primary {
  background: var(--md-sys-color-primary) !important;
  color: var(--md-sys-color-on-primary) !important;
  border: none !important;
}

.mud-button-filled.mud-button-filled-primary:hover {
  background: color-mix(in oklch, var(--md-sys-color-on-primary) 8%, var(--md-sys-color-primary)) !important;
}

.mud-button-filled.mud-button-filled-secondary {
  background: var(--md-sys-color-secondary-container) !important;
  color: var(--md-sys-color-on-secondary-container) !important;
}

.mud-button-filled.mud-button-filled-error {
  background: var(--md-sys-color-error) !important;
  color: var(--md-sys-color-on-error) !important;
}

.mud-button-filled.mud-button-filled-warning {
  background: var(--md-sys-color-secondary-container) !important;
  color: var(--md-sys-color-on-secondary-container) !important;
}

.mud-button-filled.mud-button-filled-success {
  background: var(--md-sys-color-tertiary-container) !important;
  color: var(--md-sys-color-on-tertiary-container) !important;
}

/* Outlined */
.mud-button-outlined {
  border: 1px solid var(--md-sys-color-outline) !important;
  background: transparent !important;
  color: var(--md-sys-color-primary) !important;
}

.mud-button-outlined:hover {
  background: color-mix(in oklch, var(--md-sys-color-primary) 8%, transparent) !important;
}

.mud-button-outlined.mud-button-outlined-default {
  color: var(--md-sys-color-on-surface) !important;
}

.mud-button-outlined.mud-button-outlined-error {
  border-color: var(--md-sys-color-error) !important;
  color: var(--md-sys-color-error) !important;
}

/* Text */
.mud-button-text {
  background: transparent !important;
  color: var(--md-sys-color-primary) !important;
  padding-inline: 12px !important;
}

.mud-button-text:hover {
  background: color-mix(in oklch, var(--md-sys-color-primary) 8%, transparent) !important;
}

.mud-button-text.mud-button-text-default {
  color: var(--md-sys-color-on-surface) !important;
}

.mud-button-text.mud-button-text-error {
  color: var(--md-sys-color-error) !important;
}

/* Icon buttons — round hit area */
.mud-icon-button {
  width: 40px !important;
  min-width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 !important;
  border-radius: 9999px !important;
  color: var(--md-sys-color-on-surface-variant) !important;
  transition: background var(--transition-fast);
}

.mud-icon-button:hover {
  background: color-mix(in oklch, var(--md-sys-color-on-surface) 8%, transparent) !important;
}

/* Table */
.mud-table-container {
  border-radius: var(--md-sys-shape-medium);
  background: var(--md-sys-color-surface-container-low);
}

/* Avatar */
.mud-avatar-root {
  border-radius: 9999px;
}

.yg-shell-topbar-actions .mud-avatar-root,
.yg-shell-topbar-actions .mud-avatar {
  background: var(--md-sys-color-primary-container) !important;
  color: var(--md-sys-color-on-primary-container) !important;
}

.yg-shell-user {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.yg-shell-user-avatar.mud-avatar-root,
.yg-shell-user-avatar.mud-avatar {
  width: 40px !important;
  min-width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  font-size: 1rem !important;
  font-weight: 700;
  line-height: 1;
  border: 1px solid color-mix(in oklch, var(--md-sys-color-primary) 34%, var(--md-sys-color-outline-variant)) !important;
  box-shadow: 0 8px 20px color-mix(in oklch, var(--md-sys-color-primary) 12%, transparent);
}

.yg-shell-user-avatar.mud-avatar-root:hover,
.yg-shell-user-avatar.mud-avatar:hover {
  background: color-mix(in oklch, var(--md-sys-color-primary-container) 88%, white 12%) !important;
  box-shadow: 0 10px 24px color-mix(in oklch, var(--md-sys-color-primary) 18%, transparent);
}

/* Menus / popovers */
.mud-menu .mud-list {
  background: var(--md-sys-color-surface-container-high);
}

.mud-list-item {
  border-radius: var(--md-sys-shape-small);
}

.mud-list-item:hover {
  background: color-mix(in oklch, var(--md-sys-color-on-surface) 8%, transparent);
}

/* Menu button is always shown — it toggles between mini-rail and full drawer. */
.yg-shell-menu-button {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 0 0 40px;
  width: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  max-height: 40px !important;
  margin-left: 0 !important;
  margin-inline-start: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--md-sys-color-on-surface) !important;
}

.yg-shell-menu-button:hover {
  background: color-mix(in oklch, var(--md-sys-color-on-surface) 7%, transparent) !important;
}

.yg-shell-auth {
  display: inline-flex;
  align-items: center;
}

.yg-shell-auth-button.mud-button-root {
  height: 36px;
  min-height: 36px;
  padding-inline: 12px 14px !important;
  border-radius: 9999px !important;
  border: 1px solid color-mix(in oklch, var(--md-sys-color-outline-variant) 64%, transparent) !important;
  background: color-mix(in oklch, var(--md-sys-color-surface-container-high) 46%, transparent) !important;
  color: var(--md-sys-color-on-surface) !important;
  box-shadow: none !important;
  backdrop-filter: blur(12px) saturate(135%);
  -webkit-backdrop-filter: blur(12px) saturate(135%);
}

.yg-shell-auth-button.mud-button-root:hover {
  border-color: color-mix(in oklch, var(--md-sys-color-primary) 42%, var(--md-sys-color-outline-variant)) !important;
  background: color-mix(in oklch, var(--md-sys-color-surface-container-high) 64%, transparent) !important;
  box-shadow: 0 8px 20px color-mix(in oklch, var(--md-sys-color-primary) 10%, transparent) !important;
}

.yg-shell-auth-button .mud-button-icon-start {
  margin-inline-end: 0.42rem !important;
  color: var(--md-sys-color-primary);
}

/* Mini-rail tweaks: hide labels + brand copy, center icons in the compact rail.
   The .yg-shell-drawer class is applied to the same <aside> that carries
   .mud-drawer--mini/--open, so selectors must target the same element
   (not a descendant). */
.yg-shell-layout.yg-shell--rail-collapsed .yg-shell-drawer .yg-shell-brand-copy,
.yg-shell-layout.yg-shell--rail-collapsed .yg-shell-drawer .yg-shell-link-copy,
.yg-shell-layout.yg-shell--rail-collapsed .yg-shell-drawer .yg-shell-rail-footer,
.yg-shell-drawer.mud-drawer-mini:not(.mud-drawer--open) .yg-shell-brand-copy,
.yg-shell-drawer.mud-drawer-mini:not(.mud-drawer--open) .yg-shell-link-copy,
.yg-shell-drawer.mud-drawer-mini:not(.mud-drawer--open) .yg-shell-rail-footer {
  display: none;
}

.yg-shell-layout.yg-shell--rail-collapsed .yg-shell-drawer .yg-shell-brand,
.yg-shell-layout.yg-shell--rail-collapsed .yg-shell-drawer .mud-drawer-header,
.yg-shell-drawer.mud-drawer-mini:not(.mud-drawer--open) .yg-shell-brand,
.yg-shell-drawer.mud-drawer-mini:not(.mud-drawer--open) .mud-drawer-header {
  display: none !important;
}

.yg-shell-layout.yg-shell--rail-collapsed .yg-shell-drawer .mud-drawer-content > .mud-divider,
.yg-shell-layout.yg-shell--rail-collapsed .yg-shell-drawer .mud-drawer-content > hr.mud-divider,
.yg-shell-drawer.mud-drawer-mini:not(.mud-drawer--open) .mud-drawer-content > .mud-divider,
.yg-shell-drawer.mud-drawer-mini:not(.mud-drawer--open) .mud-drawer-content > hr.mud-divider {
  display: none !important;
}

.yg-shell-layout.yg-shell--rail-collapsed .yg-shell-drawer .yg-shell-nav-wrap,
.yg-shell-drawer.mud-drawer-mini:not(.mud-drawer--open) .yg-shell-nav-wrap {
  flex: 0 0 auto;
  padding: 0.45rem 0 0;
}

.yg-shell-layout.yg-shell--rail-collapsed .yg-shell-drawer .yg-shell-nav,
.yg-shell-drawer.mud-drawer-mini:not(.mud-drawer--open) .yg-shell-nav {
  display: grid;
  justify-items: center;
  gap: 0.2rem;
}

.yg-shell-rail-nav {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
}

.yg-shell-rail-link {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--md-sys-color-on-surface-variant);
  text-decoration: none;
  transition:
    background var(--transition-fast),
    color var(--transition-fast);
}

.yg-shell-rail-link .mud-icon-root {
  display: block;
  margin: 0;
  font-size: 1.25rem;
}

.yg-shell-rail-link:hover,
.yg-shell-rail-link:focus-visible {
  background: color-mix(in oklch, var(--md-sys-color-on-surface) 8%, transparent);
  color: var(--md-sys-color-on-surface);
  outline: none;
}

.yg-shell-rail-link.is-active {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.yg-shell-layout.yg-shell--rail-collapsed .yg-shell-drawer .yg-shell-link,
.yg-shell-drawer.mud-drawer-mini:not(.mud-drawer--open) .yg-shell-link {
  display: grid !important;
  place-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  min-width: 36px;
  min-height: 36px;
  width: 36px;
  height: 36px;
  margin: 0 auto;
  gap: 0;
  border-radius: 10px !important;
}

.yg-shell-layout.yg-shell--rail-collapsed .yg-shell-drawer .yg-shell-link .mud-nav-link-icon,
.yg-shell-drawer.mud-drawer-mini:not(.mud-drawer--open) .yg-shell-link .mud-nav-link-icon {
  display: grid !important;
  place-items: center !important;
  flex: 0 0 36px !important;
  width: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  height: 36px !important;
  margin-inline-end: 0 !important;
  margin: 0 !important;
}

.yg-shell-layout.yg-shell--rail-collapsed .yg-shell-drawer .yg-shell-link .mud-nav-link-icon .mud-icon-root,
.yg-shell-drawer.mud-drawer-mini:not(.mud-drawer--open) .yg-shell-link .mud-nav-link-icon .mud-icon-root {
  display: block;
  font-size: 1.2rem !important;
}

.yg-shell-layout.yg-shell--rail-collapsed .yg-shell-drawer .yg-shell-link .mud-nav-link-text,
.yg-shell-drawer.mud-drawer-mini:not(.mud-drawer--open) .yg-shell-link .mud-nav-link-text {
  display: none;
}

/* --- Compact top app bar on narrow viewports -------------------------- */
/* On mobile the kicker+title+actions row gets cramped: title gets clipped
   to 2-3 characters and starts visually overlapping neighbouring icons.
   Drop the kicker, shrink the title and tighten paddings so the app bar
   stays readable and icons keep breathing room. */
@media (max-width: 1279px) {
  .yg-shell-appbar {
    gap: 0.5rem;
    padding-inline: 4px;
  }

  .yg-shell-topbar-copy,
  .yg-shell-kicker,
  .yg-shell-title {
    display: none;
  }

  .yg-shell-content {
    padding: 1rem !important;
  }

  .yg-shell-topbar-main {
    flex: 0 0 auto;
    gap: 0;
  }

  /* Actions row on mobile: drop the separator visual, tighten spacing. */
  .yg-shell-topbar-actions > [data-sep] {
    border-left: none;
    padding-left: 0;
    margin-left: 0;
  }
}
