/* [SEJP-V8-T009..T012] YouTube Mini Rail (76px) + 5-Breakpoint Anti-Overflow Shell */
.sejp-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  background: var(--bg-page);
  color: var(--text-primary);
  overflow-x: clip;
}

.sejp-shell.sidebar-collapsed,
html[data-sidebar-collapsed="1"] .sejp-shell {
  grid-template-columns: 76px minmax(0, 1fr);
}

.sejp-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  padding: 12px 10px;
  z-index: var(--z-sidebar, 1020);
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.2s ease, transform 0.22s ease;
}

.sejp-drawer-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 14px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.sejp-topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  text-decoration: none !important;
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.sejp-topbar-brand:hover {
  color: var(--accent-primary);
  text-decoration: none !important;
}

.sejp-brand-logo,
.sejp-topbar-brand img,
.sejp-drawer-header img {
  width: 32px !important;
  height: 32px !important;
  max-width: 32px !important;
  max-height: 32px !important;
  border-radius: 8px;
  object-fit: contain;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.sejp-yt-hamburger {
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.12s ease;
  flex-shrink: 0;
}

.sejp-yt-hamburger:hover {
  background: var(--accent-soft);
  color: var(--accent-primary);
}

.sejp-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sejp-nav-group-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 10px 12px 2px;
  text-transform: uppercase;
}

.sejp-sidebar a,
.sejp-topbar a,
.sejp-nav-link {
  text-decoration: none !important;
}

.sejp-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none !important;
  transition: background 0.16s ease, color 0.16s ease, transform 0.14s ease;
}

.sejp-nav-link:hover,
.sejp-nav-link.active {
  background: var(--accent-soft);
  color: var(--accent-primary);
  text-decoration: none !important;
}

.sejp-nav-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3.5px;
  border-radius: 0 4px 4px 0;
  background: var(--accent-primary);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.55);
}

.sejp-nav-link i {
  width: 22px;
  text-align: center;
  font-size: 1.12rem;
  flex-shrink: 0;
}

.sejp-rail-label,
.nav-label-short {
  display: none !important;
}

.sejp-nav-label,
.nav-label-full {
  display: inline;
}

/* Desktop YouTube Mini Rail (76px): Icon on top + short 1-2 word label below */
@media (min-width: 1024px) {
  .sidebar-collapsed .sejp-sidebar,
  html[data-sidebar-collapsed="1"] .sejp-sidebar {
    padding: 10px 4px;
  }
  .sidebar-collapsed .sejp-nav-link,
  html[data-sidebar-collapsed="1"] .sejp-nav-link {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 3px;
    padding: 10px 4px;
  }
  .sidebar-collapsed .sejp-nav-label,
  .sidebar-collapsed .nav-label-full,
  .sidebar-collapsed .sejp-nav-group-label,
  .sidebar-collapsed .sejp-sidebar-footer-text,
  html[data-sidebar-collapsed="1"] .sejp-nav-label,
  html[data-sidebar-collapsed="1"] .nav-label-full,
  html[data-sidebar-collapsed="1"] .sejp-nav-group-label,
  html[data-sidebar-collapsed="1"] .sejp-sidebar-footer-text {
    display: none !important;
  }
  .sidebar-collapsed .sejp-rail-label,
  .sidebar-collapsed .nav-label-short,
  html[data-sidebar-collapsed="1"] .sejp-rail-label,
  html[data-sidebar-collapsed="1"] .nav-label-short {
    display: block !important;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.15;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 68px;
  }
}

.sejp-main-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

.sejp-topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar, 1025);
  min-height: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 18px;
  min-width: 0;
  width: 100%;
  background: var(--bg-surface);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.2s ease, box-shadow 0.2s ease, backdrop-filter 0.2s ease;
}

.sejp-topbar.is-scrolled {
  background: color-mix(in srgb, var(--bg-surface) 88%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
}

.sejp-topbar-left,
.sejp-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
}

.sejp-topbar-left > *,
.sejp-topbar-right > * {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
}

.sejp-topbar .form-select-sm,
.sejp-topbar .btn-sm,
.sejp-topbar .sejp-badge,
.sejp-topbar .theme-toggle-btn,
.sejp-topbar #sejp-quick-lang,
.sejp-topbar #sejp-open-search {
  height: 36px;
  min-height: 36px;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  margin-top: 0;
  margin-bottom: 0;
  vertical-align: middle;
}

.sejp-topbar #sejp-quick-lang {
  width: auto;
  min-width: 0;
  max-width: 168px;
}

.sejp-content {
  width: 100%;
  min-width: 0;
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 22px 48px;
  flex: 1;
}

/* Defensive Anti-1-Char Vertical Wrapping across all cards, panels & columns */
.sejp-content .card,
.sejp-content .card-body,
.sejp-content .alert,
.sejp-content .hub-panel,
.sejp-content .row > * {
  min-width: 0;
  max-width: 100%;
}

.sejp-content .card-body,
.sejp-content .alert {
  overflow-wrap: break-word;
  word-break: normal;
}

.sejp-footer {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  text-align: center;
  padding: 14px 18px;
  font-size: 0.85rem;
}

.sejp-bottom-bar { display: none; }
.sejp-drawer-backdrop { display: none; }

.table-scroll-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Breakpoint 5: Ultrawide / Desktop >= 1440px */
@media (min-width: 1440px) {
  .sejp-content {
    max-width: 1360px;
    padding: 26px 32px 56px;
  }
}

/* Breakpoint 4: Laptop 1024px - 1439px */
@media (min-width: 1024px) and (max-width: 1439px) {
  .sejp-shell {
    grid-template-columns: 236px minmax(0, 1fr);
  }
  .sejp-content {
    max-width: 1180px;
    padding: 20px 20px 44px;
  }
}

/* Compact Topbar < 900px: prevent right-edge clipping */
@media (max-width: 899px) {
  .sejp-topbar {
    padding: 8px 12px;
    gap: 6px;
  }
  .sejp-topbar-brand-name {
    display: none;
  }
  .sejp-badge-txt,
  .sejp-user-admin-pill {
    display: none;
  }
  .sejp-topbar #sejp-quick-lang {
    max-width: 132px;
    font-size: 0.8rem;
    padding-left: 8px;
    padding-right: 24px;
  }
}

/* Breakpoint 3: Tablet 768px - 1023px (820px optimized spacing) */
@media (min-width: 768px) and (max-width: 1023px) {
  .sejp-content {
    padding: 18px 18px 44px;
  }
}

/* Tablet & Mobile < 1024px (Full-width content + Slide-Over Overlay Drawer) */
@media (max-width: 1023px) {
  .sejp-shell,
  .sejp-shell.sidebar-collapsed,
  html[data-sidebar-collapsed="1"] .sejp-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .sejp-drawer-header {
    display: flex;
  }
  .sejp-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 268px;
    max-width: 84vw;
    z-index: var(--z-drawer, 1040);
    transform: translateX(-105%);
    box-shadow: var(--shadow-lg);
  }
  .sejp-sidebar.drawer-open {
    transform: translateX(0);
  }
  .sejp-drawer-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.48);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: calc(var(--z-drawer, 1040) - 5);
  }
  .sejp-content {
    padding: 16px 16px 44px;
  }
}

/* Breakpoint 1 & 2: Mobile <= 767px (375px & 640px — Bottom 5-Hub Bar) */
@media (max-width: 767px) {
  .sejp-content {
    padding: 12px 10px 88px;
  }
  .sejp-footer {
    padding-bottom: 78px;
  }
  .sejp-topbar-user-name {
    display: none;
  }
  .sejp-topbar #sejp-quick-lang {
    max-width: 112px;
  }
  .sejp-bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: color-mix(in srgb, var(--bg-surface) 92%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-subtle);
    padding: 6px 2px calc(6px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.08);
  }
  .sejp-bottom-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 4px 2px;
    text-decoration: none;
  }
  .sejp-bottom-item.active {
    color: var(--accent-primary);
  }
  .sejp-bottom-item i {
    font-size: 1.05rem;
  }
}
