/* ==========================================================================
 * 1. MODERN ARCHIVE SHELL (TRANSLUCENT TOP BAR + TONE-ON-TONE SIDENAV)
 * ========================================================================== */
.admin-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 1020;
  min-height: 60px;
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--nav-fg);
  padding: 0.65rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--nav-border);
}

.navbar-top-tier {
  display: contents;
}

.brand-row,
.navbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-identity {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: inherit;
  min-width: 0;
}

.brand-emblem-btn {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  outline: none;
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.brand-emblem-btn:hover {
  transform: translateY(-1px);
}

.brand-emblem-btn:active {
  transform: translateY(0);
}

.brand-emblem-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.brand-emblem,
.brand-icon {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.brand-emblem-btn:hover .brand-emblem {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.brand-emblem .emblem-letter {
  display: inline-block;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.brand-emblem .emblem-menu-icon {
  position: absolute;
  opacity: 0;
  transform: scale(0.65);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
  color: var(--primary-fg);
}

.brand-emblem-btn:hover .brand-emblem .emblem-letter {
  opacity: 0;
  transform: scale(0.65);
}

.brand-emblem-btn:hover .brand-emblem .emblem-menu-icon {
  opacity: 1;
  transform: scale(1);
}

.brand-emblem.emblem-sm {
  width: 26px;
  height: 26px;
  font-size: 0.75rem;
  border-radius: 6px;
}

.brand-titles {
  min-width: 0;
  cursor: pointer;
  user-select: none;
}

.brand-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  margin: 0;
  font-size: 0.7rem;
  color: var(--nav-muted);
  white-space: nowrap;
}

.admin-body {
  display: flex;
  flex: 1;
  min-height: calc(100vh - 60px);
}

.admin-sidenav {
  width: 244px;
  flex-shrink: 0;
  background: var(--nav-bg);
  color: var(--nav-fg);
  border-right: 1px solid var(--nav-border);
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: width 0.2s ease;
}

.admin-sidenav.collapsed {
  width: 64px;
  padding: 1.25rem 0.5rem;
}

.admin-sidenav.collapsed .sidenav-label,
.admin-sidenav.collapsed .sidenav-group-title,
.admin-sidenav.collapsed .sidenav-badge,
.admin-sidenav.collapsed .sidenav-footer-note {
  display: none;
}

.sidenav-group {
  margin-bottom: 1.4rem;
}

.sidenav-group-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--nav-muted);
  padding: 0 0.65rem;
  margin-bottom: 0.45rem;
  font-weight: 600;
}

.sidenav-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}

.sidenav-item {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--fg-secondary);
  padding: 0.54rem 0.68rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: left;
  transition: all 0.15s ease;
  font-family: inherit;
}

.sidenav-item-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.sidenav-icon {
  font-size: 0.92rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.78;
}

.sidenav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidenav-item:hover {
  background: var(--nav-bg-elevated);
  color: var(--fg-primary);
}

.sidenav-item.active {
  background: var(--primary);
  color: var(--primary-fg);
  font-weight: 600;
}

.sidenav-badge {
  background: rgba(120, 113, 108, 0.14);
  color: inherit;
  font-size: 0.7rem;
  padding: 0.08rem 0.45rem;
  border-radius: 999px;
  font-weight: 600;
}

.sidenav-item.active .sidenav-badge {
  background: rgba(255, 255, 255, 0.2);
  color: var(--primary-fg);
}

.sidenav-footer-note {
  font-size: 0.65rem;
  color: var(--nav-muted);
  padding: 0.4rem 0.65rem 0.2rem;
  border-top: 1px solid var(--nav-border);
  line-height: 1.35;
  margin-top: auto;
  opacity: 0.82;
}

.sidenav-footer-note strong {
  display: block;
  font-size: 0.68rem;
  color: var(--fg-secondary);
  font-weight: 600;
  margin-bottom: 0.05rem;
  letter-spacing: -0.01em;
}

.sidenav-footer-note .sidenav-footer-meta {
  display: block;
  font-size: 0.62rem;
  color: var(--nav-muted);
  line-height: 1.3;
}

.mobile-nav-backdrop {
  display: none;
}

.drawer-header {
  display: none;
}

body.mobile-nav-active {
  overflow: hidden !important;
  touch-action: none;
}

.admin-main {
  padding: 1.75rem 2.25rem 3rem;
  max-width: 1520px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  min-width: 0;
}

@media (max-width: 960px) {
  .mobile-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .mobile-nav-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }

  .admin-body {
    flex-direction: column;
  }

  .admin-sidenav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px !important;
    max-width: 82vw;
    height: 100vh;
    height: 100dvh;
    background: var(--nav-bg);
    border-right: 1px solid var(--nav-border);
    border-bottom: none;
    box-shadow: 6px 0 28px rgba(0, 0, 0, 0.2);
    z-index: 1050;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.15rem 0.85rem;
  }

  .admin-sidenav.mobile-open {
    transform: translateX(0);
  }

  .admin-sidenav.collapsed {
    width: 280px !important;
    padding: 1.15rem 0.85rem;
  }

  .admin-sidenav.collapsed .sidenav-label,
  .admin-sidenav.collapsed .sidenav-group-title,
  .admin-sidenav.collapsed .sidenav-badge,
  .admin-sidenav.collapsed .sidenav-footer-note {
    display: inline !important;
  }

  .admin-sidenav.collapsed .sidenav-group-title,
  .admin-sidenav.collapsed .sidenav-footer-note {
    display: block !important;
  }

  .drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.85rem;
    margin-bottom: 0.85rem;
    border-bottom: 1px solid var(--nav-border);
  }

  .drawer-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
  }

  .drawer-brand-titles {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    line-height: 1.2;
  }

  .drawer-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--nav-fg);
    letter-spacing: -0.01em;
  }

  .drawer-sub {
    font-size: 0.65rem;
    color: var(--nav-muted);
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }

  .drawer-close-btn {
    background: transparent;
    border: 1px solid var(--nav-border);
    color: var(--nav-fg);
    width: 30px;
    height: 30px;
    border-radius: 6px;
    font-size: 1.1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
  }

  .drawer-close-btn:hover {
    background: var(--nav-bg-elevated);
  }

  .sidenav-list {
    flex-direction: column;
    flex-wrap: nowrap;
  }

  .sidenav-item {
    width: 100%;
  }

  .admin-main {
    padding: 1.15rem 1rem 3rem;
  }
}

/* ==========================================================================
 * 2. CONTROLS, BUTTONS, PILLS & BANNERS
 * ========================================================================== */
.nav-tabs,
.btn-group,
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Theme Toggle Button (Web Reader Parity) */
.theme-toggle-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--fg-primary);
  height: 32px;
  padding: 0 0.65rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.theme-toggle-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

.theme-icon {
  font-size: 0.85rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-label {
  white-space: nowrap;
}

/* Locale Dropdown (Web Reader Parity) */
.locale-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.locale-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 0.55rem;
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  color: var(--fg-primary);
  font-size: 0.76rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
}

.locale-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

.locale-btn[aria-expanded="true"] {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(45, 74, 62, 0.15);
}

.locale-icon {
  font-size: 0.85rem;
  line-height: 1;
  opacity: 0.85;
}

.locale-current-code {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.locale-chevron {
  font-size: 0.65rem;
  opacity: 0.65;
  margin-left: 0.05rem;
}

.locale-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 1060;
  min-width: 145px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.locale-dropdown-item {
  background: transparent;
  border: none;
  color: var(--fg-primary);
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  transition: all 0.12s ease;
  width: 100%;
}

.locale-dropdown-item:hover {
  background: var(--nav-bg-elevated);
  color: var(--primary);
}

.locale-dropdown-item.active {
  background: var(--primary);
  color: var(--primary-fg);
  font-weight: 600;
}

.locale-item-code {
  font-size: 0.72rem;
  opacity: 0.65;
  margin-left: 0.4rem;
}

.locale-dropdown-item.active .locale-item-code {
  opacity: 0.85;
  color: var(--primary-fg);
}

.locale-item-check {
  font-size: 0.78rem;
  margin-left: 0.3rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* User Profile Pill (Web Reader Parity) */
.user-profile-pill {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 4px 2px 3px;
  height: 34px;
  gap: 0.35rem;
  flex-shrink: 0;
  transition: border-color 0.15s ease;
}

.user-profile-pill:hover {
  border-color: var(--border-strong);
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-profile-pill .user-badge {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--fg-secondary);
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 0.25rem;
  background: transparent;
  border: none;
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--fg-muted);
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.73rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.15s ease;
  line-height: 1;
}

.btn-logout:hover {
  background: var(--bg-elevated);
  color: var(--danger-fg);
}

.btn-logout svg {
  flex-shrink: 0;
}

.locale-select,
.input {
  padding: 0.4rem 0.72rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.84rem;
  background: var(--bg-surface);
  color: var(--fg-primary);
  outline: none;
  transition: border-color 0.15s ease;
}

.locale-select:focus,
.input:focus {
  border-color: var(--primary);
}

.btn {
  padding: 0.42rem 0.85rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.83rem;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: inherit;
  transition: all 0.15s ease;
}

.btn-sm {
  padding: 0.28rem 0.62rem;
  font-size: 0.76rem;
  border-radius: 7px;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline,
.btn-nav {
  background: var(--bg-surface);
  color: var(--fg-primary);
  border-color: var(--border);
}

.btn-outline:hover,
.btn-nav:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger-fg);
  border-color: var(--danger-border);
}

.btn-success {
  background: var(--success-bg);
  color: var(--success-fg);
  border-color: var(--success-border);
}

.btn:disabled {
  background: var(--bg-elevated);
  color: var(--fg-muted);
  border-color: var(--border);
  opacity: 0.55;
  cursor: not-allowed;
}

.pill {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 0.32rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--fg-secondary);
  transition: all 0.15s ease;
}

.pill:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

.pill.active {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
}

.user-badge {
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--fg-secondary);
  padding: 0.3rem 0.68rem;
  border-radius: 999px;
}

.banner {
  padding: 0.65rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.banner-info {
  background: var(--bg-elevated);
  color: var(--fg-primary);
}
.banner-success {
  background: var(--success-bg);
  color: var(--success-fg);
  border-bottom-color: var(--success-border);
}
.banner-error {
  background: var(--danger-bg);
  color: var(--danger-fg);
  border-bottom-color: var(--danger-border);
}
.banner-close {
  background: none;
  border: none;
  font-size: 1.15rem;
  cursor: pointer;
  color: inherit;
}

@media (max-width: 640px) {
  .admin-header {
    padding: 0.45rem 0.6rem 0.55rem;
    gap: 0.4rem;
  }

  .brand-sub {
    display: none;
  }

  .brand-title {
    font-size: 0.88rem;
  }

  .header-controls {
    gap: 0.25rem;
  }

  .theme-toggle-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }

  .theme-label {
    display: none;
  }

  .locale-btn {
    height: 30px;
    padding: 0 0.45rem;
    font-size: 0.72rem;
    gap: 0.18rem;
  }

  .locale-icon {
    font-size: 0.78rem;
  }

  .locale-current-code {
    font-size: 0.7rem;
  }

  .user-profile-pill {
    height: 30px;
    padding: 2px 3px 2px 2px;
    gap: 0.2rem;
  }

  .user-profile-pill .user-badge {
    display: none;
  }

  .user-profile-pill .user-avatar {
    width: 22px;
    height: 22px;
    font-size: 0.68rem;
  }

  .btn-logout {
    width: 22px;
    height: 22px;
    padding: 0;
    justify-content: center;
  }

  .logout-text {
    display: none;
  }
}
