/**
 * Unified admin chrome — header + left full-menu drawer (bo-manage-v2 style).
 */

:root {
  --admin-header-h: 56px;
  --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-header-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-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;
}

#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-topbar .admin-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--admin-header-border);
  background: var(--admin-accent-soft);
  color: var(--admin-accent);
  font-weight: 800;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 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;
  gap: 6px;
}
#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-header-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-header-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-header-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) {
  #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;
}
