/* ============================================================
   AX Catalog Portal — Layout
   1920px / Sidebar 280px fixed / Content fill
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font: var(--font-body);
  color: var(--text-primary);
  background: var(--surface-page);
  -webkit-font-smoothing: antialiased;
}

/* ── Utility ── */
.hidden { display: none !important; }

/* ── App Shell ── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Login ── */
#screen-login {
  display: none;
  width: 100vw;
  height: 100vh;
}
#screen-login.active {
  display: block;
}
.login-wrap {
  display: grid;
  place-items: center;
  height: 100vh;
  background: #fff;
  padding: 32px;
}
.login-panel {
  width: min(100%, 420px);
  text-align: center;
}
.login-title {
  margin: 0;
  color: #15171a;
  font-size: 36px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0;
}
.login-desc {
  margin: 14px auto 34px;
  color: #555b63;
  font-size: 15px;
  line-height: 1.6;
  max-width: 360px;
}
.login-entra-btn {
  width: 100%;
  height: 50px;
  padding: 8px 16px 8px 12px;
  border: 1px solid #8b8f97;
  border-radius: 8px;
  background: transparent;
  color: #191a1b;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.48;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.login-entra-btn:hover {
  border-color: #5f646c;
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.08);
}
.login-kt-logo {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex: 0 0 auto;
}
.login-test-panel {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid #e2e5e9;
  text-align: left;
}
.login-test-panel__title {
  color: #22262b;
  font-size: 13px;
  font-weight: 800;
}
.login-test-panel__desc {
  margin-top: 4px;
  color: #767d86;
  font-size: 12px;
}
.login-test-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.login-test-btn {
  height: 34px;
  padding: 0 13px;
  border: 1px solid #d3d8df;
  border-radius: 6px;
  background: #f8f9fb;
  color: #2b3036;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.login-test-btn:hover {
  border-color: #aeb4bd;
  background: #fff;
}
.login-test-btn--ghost {
  color: #7b2428;
  border-color: #efd4d6;
  background: #fff7f7;
}
.login-error {
  margin-top: 10px;
  color: #e0282f;
  font-size: 12px;
  font-weight: 700;
}
.login-alert {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: rgba(17, 24, 39, 0.48);
  padding: 24px;
}
.login-alert.hidden {
  display: none;
}
.login-alert__dialog {
  width: min(100%, 380px);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(17, 24, 39, 0.24);
  padding: 26px 24px 22px;
  text-align: center;
}
.login-alert__title {
  color: #15171a;
  font-size: 18px;
  font-weight: 800;
}
.login-alert__body {
  margin-top: 12px;
  color: #4f5660;
  font-size: 14px;
  line-height: 1.6;
}
.login-alert__button {
  width: 100%;
  height: 42px;
  margin-top: 22px;
  border-radius: 6px;
}

/* ── Sidebar ── */
.sidebar {
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--surface-sidebar);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar__logo {
  height: 72px;
  padding: 0 16px 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.sidebar__logo-circle {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--brand-red);
  display: flex;
  align-items: center;
  justify-content: center;
  font: var(--font-label);
  color: var(--text-inverse);
  flex-shrink: 0;
}

.sidebar__logo-text {
  font: var(--font-logo);
  color: var(--text-inverse);
}

.sidebar__divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 0 20px;
  flex-shrink: 0;
}

.sidebar__nav {
  flex: 1;
  padding: var(--space-xs) 0;
  overflow-y: auto;
}

.sidebar__nav::-webkit-scrollbar { display: none; }

.nav-item {
  position: relative;
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  cursor: pointer;
  font: var(--font-nav-item);
  color: rgba(255, 255, 255, 0.6);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.85);
}

.nav-item.active {
  background: var(--surface-sidebar-active);
  font: var(--font-nav-active);
  color: var(--text-inverse);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  background: var(--brand-red);
  border-radius: 0 2px 2px 0;
}

.nav-item__icon {
  width: 20px;
  height: 20px;
  opacity: 0.7;
  flex-shrink: 0;
}

.nav-item.active .nav-item__icon { opacity: 1; }

.sidebar__profile {
  height: 64px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--surface-sidebar-bottom);
  flex-shrink: 0;
}

.sidebar__profile-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--surface-sidebar-active);
  display: flex;
  align-items: center;
  justify-content: center;
  font: var(--font-caption);
  color: var(--text-inverse);
  flex-shrink: 0;
}

.sidebar__profile-info { flex: 1; min-width: 0; }

.sidebar__profile-name {
  font: var(--font-nav-active);
  color: var(--text-inverse);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__profile-role {
  font: var(--font-caption);
  color: rgba(255, 255, 255, 0.45);
}

/* ── Main ── */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── UtilBar ── */
.utilbar {
  height: var(--utilbar-height);
  flex-shrink: 0;
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-default);
  padding: 0 var(--content-padding);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.utilbar__left {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  min-width: 0;
}

.utilbar__back {
  display: flex;
  align-items: center;
  gap: 4px;
  font: var(--font-body);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.utilbar__back:hover { color: var(--text-primary); }

.utilbar__back-sep {
  color: var(--border-default);
  margin: 0 4px;
}

.utilbar__title {
  font: var(--font-page-title);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.utilbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
}

/* ── Content Body ── */
.content-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: var(--content-padding);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.content-body::-webkit-scrollbar { width: 6px; }
.content-body::-webkit-scrollbar-track { background: transparent; }
.content-body::-webkit-scrollbar-thumb {
  background: var(--fill-secondary);
  border-radius: var(--radius-full);
}

/* ── Screen visibility ── */
.screen { display: none; }
.screen.active { display: contents; }

/* ── Modal overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.hidden { display: none; }

/* ============================================================
   사이드바 접기/펼치기 (브라우저 width 무관)
   - 펼침: 로고 우측에 panel 토글 노출
   - 닫힘: 토글 미노출, 로고 hover 시 panel(펼침) 아이콘으로 변경 후 클릭 시 펼침
   - 닫힘 시 64px 아이콘 레일, 모든 텍스트(선택 항목 포함) 숨김
   ============================================================ */
.sidebar { transition: flex-basis 0.18s ease, width 0.18s ease; }

.sidebar__logo-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
}

.sidebar__logo-circle { position: relative; }
.sidebar__logo-circle-text { transition: opacity 0.12s; }
.sidebar__logo-expand-icon {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  color: var(--text-inverse);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}

/* 펼침 토글 버튼 (로고 우측) */
.sidebar__toggle {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  border-radius: var(--radius-md);
}
.sidebar__toggle svg { width: 20px; height: 20px; display: block; pointer-events: none; }
.sidebar__toggle:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

/* SVG 아이콘이 부모 hover를 가로채지 않도록 */
.nav-item__icon { pointer-events: none; }

/* ── 닫힘 상태 ── */
.sidebar.collapsed { flex-basis: 64px; width: 64px; }
.sidebar.collapsed .sidebar__logo { justify-content: center; padding: 0; }
.sidebar.collapsed .sidebar__toggle { display: none; }          /* 닫힘 시 토글 미노출 */
.sidebar.collapsed .sidebar__logo-text { display: none; }
.sidebar.collapsed .sidebar__logo-brand { cursor: pointer; }

/* 닫힘 + 로고 hover → AX 숨기고 panel(펼침) 아이콘 노출 */
.sidebar.collapsed .sidebar__logo-brand:hover .sidebar__logo-circle { background: rgba(255, 255, 255, 0.12); }
.sidebar.collapsed .sidebar__logo-brand:hover .sidebar__logo-circle-text { opacity: 0; }
.sidebar.collapsed .sidebar__logo-brand:hover .sidebar__logo-expand-icon { opacity: 1; }

.sidebar.collapsed .sidebar__divider { margin: 0 12px; }
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0;
  gap: 0;
  font-size: 0;             /* 모든 항목 텍스트 숨김 (active 포함) */
}
.sidebar.collapsed .nav-item.active { font-size: 0; }
.sidebar.collapsed .nav-item__icon { font-size: initial; }

.sidebar.collapsed .sidebar__profile { justify-content: center; padding: 0; }
.sidebar.collapsed .sidebar__profile-info { display: none; }

/* ============================================================
   반응형 — 노트북~태블릿 (사이드바는 폭과 무관, 아래는 그 외 요소)
   ============================================================ */

/* ── ≤1024px: 로그인 축소 + utilbar 줄바꿈 ── */
@media (max-width: 1024px) {
  .utilbar { flex-wrap: wrap; row-gap: 8px; height: auto; padding-top: 12px; padding-bottom: 12px; }
}

/* ── ≤768px: 패딩 축소 ──
   (폼/상세 스택 오버라이드는 소스 순서상 components.css 하단에 위치) */
@media (max-width: 768px) {
  :root { --content-padding: 16px; }

  .login-wrap { padding: 24px; }
  .login-title { font-size: 32px; }
}
