/**
 * Unified admin chrome — header + left full-menu drawer (bo-manage-v2 style).
 */

:root {
  --admin-header-h: 56px;
  --admin-page-tabs-h: 42px;
  --admin-shell-h: calc(var(--admin-header-h) + var(--admin-page-tabs-h));
  --admin-accent: #2563eb;
  --admin-accent-soft: #eff6ff;
  --admin-header-bg: #ffffff;
  --admin-header-border: #e5e7eb;
  --admin-drawer-bg: #ffffff;
  /* Compact floating panel — match bo-manage-v2 menu footprint */
  --admin-drawer-w: min(720px, calc(100vw - 16px));
  --admin-muted: #6b7280;
  --admin-text: #111827;
  --admin-rail: #f3f4f6;
}

html[data-admin-theme="dark"] {
  --admin-accent: #60a5fa;
  --admin-accent-soft: #1e3a5f;
  --admin-header-bg: #121214;
  --admin-header-border: #2e2e35;
  --admin-drawer-bg: #1a1a1e;
  --admin-muted: #a1a1aa;
  --admin-text: #f4f4f5;
  --admin-rail: #0c0c0e;
}

/* Reserve space so page content clears the fixed header */
body.admin-has-shell {
  padding-top: var(--admin-shell-h) !important;
  box-sizing: border-box;
}

#admin-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10050;
  height: var(--admin-header-h);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--admin-header-bg);
  border-bottom: 1px solid var(--admin-header-border);
  color: var(--admin-text);
  font-family: "Pretendard", "Noto Sans KR", "Noto Sans SC", ui-sans-serif, system-ui, sans-serif;
}

#admin-page-tabs {
  position: fixed;
  top: var(--admin-header-h);
  left: 0;
  right: 0;
  z-index: 10040;
  height: var(--admin-page-tabs-h);
  box-sizing: border-box;
  display: flex;
  align-items: stretch;
  gap: 2px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 5px 12px 4px;
  border-bottom: 1px solid var(--admin-header-border);
  background: var(--admin-rail);
  color: var(--admin-text);
  scrollbar-width: thin;
}
.admin-page-tab {
  display: inline-flex;
  flex: 0 0 auto;
  min-width: 0;
  max-width: 220px;
  border: 1px solid transparent;
  border-radius: 6px 6px 0 0;
  color: var(--admin-muted);
}
.admin-page-tab:hover { color: var(--admin-text); background: var(--admin-header-bg); }
.admin-page-tab.is-active {
  border-color: var(--admin-header-border);
  border-bottom-color: var(--admin-header-bg);
  background: var(--admin-header-bg);
  color: var(--admin-accent);
}
.admin-page-tab__open,
.admin-page-tab__close {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
.admin-page-tab__open {
  min-width: 0;
  padding: 0 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
}
.admin-page-tab__close {
  width: 26px;
  padding: 0;
  font-size: 17px;
  line-height: 1;
}
.admin-page-tab__close:hover { color: var(--admin-text); background: var(--admin-rail); }
.admin-page-tab__open:focus-visible,
.admin-page-tab__close:focus-visible {
  outline: 2px solid var(--admin-accent);
  outline-offset: -2px;
}

#admin-topbar .admin-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--admin-accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  text-decoration: none;
  flex: 0 0 auto;
}

#admin-topbar .admin-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: var(--admin-accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
#admin-topbar .admin-menu-btn:hover { filter: brightness(1.05); }
#admin-topbar .admin-menu-btn svg { width: 16px; height: 16px; }

#admin-topbar .admin-search-btn {
  margin-left: 4px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  min-width: 220px;
  max-width: 420px;
  flex: 1 1 auto;
  padding: 0 12px;
  border: 1px solid var(--admin-header-border);
  border-radius: 10px;
  background: var(--admin-rail);
  color: var(--admin-muted);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}
#admin-topbar .admin-search-btn kbd {
  margin-left: auto;
  font: 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--admin-header-border);
  background: var(--admin-header-bg);
  color: var(--admin-muted);
}
#admin-topbar .admin-search-btn svg { width: 16px; height: 16px; flex: 0 0 auto; }

#admin-topbar .admin-top-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
}

#admin-topbar #admin-header-tools {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  min-width: 0;
}

#admin-topbar .admin-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--admin-header-border);
  background: var(--admin-header-bg);
  color: var(--admin-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
#admin-topbar .admin-icon-btn:hover { background: var(--admin-rail); }

#admin-account-menu {
  position: relative;
  flex: 0 0 auto;
  order: 2;
}

#admin-account-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(200px, 28vw);
  height: 36px;
  padding: 0 8px 0 4px;
  border: 1px solid var(--admin-header-border);
  border-radius: 10px;
  background: var(--admin-header-bg);
  color: var(--admin-text);
  cursor: pointer;
  text-align: left;
}
#admin-account-trigger:hover,
#admin-account-menu.is-open #admin-account-trigger {
  background: var(--admin-rail);
}
#admin-account-trigger:focus-visible {
  outline: 2px solid var(--admin-accent);
  outline-offset: 1px;
}

#admin-topbar .admin-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 0;
  background: linear-gradient(145deg, #b53a58 0%, #9b2c4a 48%, #6e1d36 100%);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

#admin-account-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
  line-height: 1.15;
}
#admin-account-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 650;
}
#admin-account-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--admin-muted);
  font-size: 10.5px;
}
#admin-account-chevron {
  width: 12px;
  height: 12px;
  color: var(--admin-muted);
  flex: 0 0 auto;
  transition: transform 140ms ease;
}
#admin-account-menu.is-open #admin-account-chevron {
  transform: rotate(180deg);
}

#admin-account-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 10060;
  min-width: 188px;
  padding: 6px;
  border: 1px solid var(--admin-header-border);
  border-radius: 12px;
  background: var(--admin-header-bg);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
  display: none;
}
#admin-account-menu.is-open #admin-account-dropdown {
  display: grid;
  gap: 2px;
}
#admin-account-dropdown button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--admin-text);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  text-align: left;
}
#admin-account-dropdown button:hover {
  background: var(--admin-rail);
}
#admin-account-dropdown button svg {
  width: 15px;
  height: 15px;
  color: var(--admin-muted);
  flex: 0 0 auto;
}
#admin-account-dropdown .admin-account-logout {
  color: #b42318;
}
#admin-account-dropdown .admin-account-logout svg {
  color: #b42318;
}
html[data-admin-theme="dark"] #admin-account-dropdown .admin-account-logout,
html[data-admin-theme="dark"] #admin-account-dropdown .admin-account-logout svg {
  color: #f19595;
}

@media (max-width: 720px) {
  #admin-account-copy {
    display: none;
  }
  #admin-account-trigger {
    width: 36px;
    max-width: 36px;
    padding: 0;
    justify-content: center;
  }
  #admin-account-chevron {
    display: none;
  }
}

/* Mount lang/theme into header */
#admin-topbar #admin-chrome-bar {
  position: static !important;
  top: auto !important;
  right: auto !important;
  z-index: auto !important;
  box-shadow: none !important;
  display: flex !important;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  order: 1;
}
#admin-topbar #admin-lang-switcher,
#admin-topbar #admin-theme-switcher {
  box-shadow: none !important;
  background: var(--admin-rail) !important;
}
#admin-topbar #admin-lang-switcher button,
#admin-topbar #admin-theme-switcher button {
  color: var(--admin-muted) !important;
}
#admin-topbar #admin-lang-switcher button.is-on,
#admin-topbar #admin-theme-switcher button.is-on {
  background: var(--admin-header-bg) !important;
  color: var(--admin-text) !important;
}

/* Floating full-menu panel (not a half-screen drawer) */
#admin-nav-backdrop {
  position: fixed;
  /* keep header/hotzone above so hover does not flicker */
  top: var(--admin-shell-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10060;
  background: rgba(15, 23, 42, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease;
}
#admin-nav-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

#admin-menu-hotzone {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

#admin-nav-drawer {
  position: fixed;
  /* Flush under header — no gap strip of backdrop */
  top: var(--admin-shell-h);
  left: 8px;
  z-index: 10070;
  width: var(--admin-drawer-w);
  max-width: calc(100vw - 16px);
  box-sizing: border-box;
  max-height: calc(100vh - var(--admin-shell-h) - 12px);
  background: var(--admin-drawer-bg);
  color: var(--admin-text);
  border: 1px solid var(--admin-header-border);
  border-top: 0;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  font-family: "Pretendard", "Noto Sans KR", "Noto Sans SC", ui-sans-serif, system-ui, sans-serif;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity .14s ease, transform .14s ease, visibility .14s ease;
}
#admin-nav-drawer.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

#admin-nav-drawer .admin-drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--admin-header-border);
  flex: 0 0 auto;
}
#admin-nav-drawer .admin-drawer-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}
#admin-nav-drawer .admin-drawer-head p {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--admin-muted);
}
#admin-nav-drawer .admin-drawer-close {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--admin-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
#admin-nav-drawer .admin-drawer-close:hover {
  background: var(--admin-rail);
  color: var(--admin-text);
}

#admin-nav-drawer .admin-drawer-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 10px 12px 12px;
}

#admin-nav-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.admin-nav-card {
  border: 1px solid var(--admin-header-border);
  border-radius: 10px;
  padding: 10px 10px 8px;
  background: var(--admin-drawer-bg);
}
.admin-nav-card__head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.admin-nav-card__icon {
  width: 25px;
  height: 25px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 0;
}
.admin-nav-card__icon svg {
  width: 16px;
  height: 16px;
  display: block;
}
/* Match bo-manage-v2 menu-group-icon palette */
.admin-nav-card__icon.is-blue { background: #eaf3ff; color: #1b64da; }
.admin-nav-card__icon.is-green { background: #eaf8f2; color: #087f5b; }
.admin-nav-card__icon.is-amber { background: #fff4de; color: #ae6800; }
.admin-nav-card__icon.is-violet { background: #eaf3ff; color: #1b64da; }
.admin-nav-card__icon.is-rose { background: #fff4de; color: #ae6800; }
.admin-nav-card__icon.is-slate { background: #f1f5f9; color: #475569; }
html[data-admin-theme="dark"] .admin-nav-card__icon.is-blue,
html[data-admin-theme="dark"] .admin-nav-card__icon.is-violet { background: #1e3a5f; color: #93c5fd; }
html[data-admin-theme="dark"] .admin-nav-card__icon.is-green { background: #14301c; color: #86efac; }
html[data-admin-theme="dark"] .admin-nav-card__icon.is-amber,
html[data-admin-theme="dark"] .admin-nav-card__icon.is-rose { background: #3a2a10; color: #fdba74; }
html[data-admin-theme="dark"] .admin-nav-card__icon.is-slate { background: #27272a; color: #a1a1aa; }

.admin-nav-card__title {
  font-size: 13px;
  font-weight: 700;
  flex: 1 1 auto;
}
.admin-nav-card__count {
  font-size: 11px;
  color: var(--admin-muted);
  font-weight: 600;
}
.admin-nav-card__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1px;
}
.admin-nav-card__list a,
.admin-nav-card__list span {
  display: block;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12px;
  text-decoration: none;
  color: var(--admin-text);
}

@media (max-width: 720px) {
  :root { --admin-page-tabs-h: 40px; }
  #admin-page-tabs { padding-inline: 8px; }
  .admin-page-tab { max-width: 180px; }
  #admin-topbar .admin-search-btn {
    display: none;
  }
  #admin-nav-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #admin-nav-drawer {
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 0 0 12px 12px;
  }
}
.admin-nav-card__list a:hover {
  background: var(--admin-rail);
}
.admin-nav-card__list a.is-active {
  background: var(--admin-accent-soft);
  color: var(--admin-accent);
  font-weight: 600;
}
.admin-nav-card__list span.is-deferred {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Command palette */
#admin-cmdk {
  position: fixed;
  inset: 0;
  z-index: 10080;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  background: rgba(15, 23, 42, 0.4);
}
#admin-cmdk.is-open { display: flex; }
#admin-cmdk .admin-cmdk-panel {
  width: min(560px, calc(100vw - 24px));
  background: var(--admin-drawer-bg);
  border: 1px solid var(--admin-header-border);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0,0,0,.28);
  overflow: hidden;
}
#admin-cmdk input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--admin-header-border);
  padding: 14px 16px;
  font-size: 15px;
  background: transparent;
  color: var(--admin-text);
  outline: none;
  box-sizing: border-box;
}
#admin-cmdk .admin-cmdk-list {
  max-height: 360px;
  overflow: auto;
  padding: 8px;
}
#admin-cmdk .admin-cmdk-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--admin-text);
}
#admin-cmdk .admin-cmdk-item:hover,
#admin-cmdk .admin-cmdk-item.is-on {
  background: var(--admin-accent-soft);
  color: var(--admin-accent);
}
#admin-cmdk .admin-cmdk-item .grp {
  color: var(--admin-muted);
  font-size: 11px;
}
#admin-cmdk .admin-cmdk-empty {
  padding: 20px;
  text-align: center;
  color: var(--admin-muted);
  font-size: 13px;
}

/* Hide old floating chrome when header owns it */
body.admin-has-shell > #admin-chrome-bar:not(#admin-topbar #admin-chrome-bar) {
  display: none !important;
}
