/* =========================================================
   IMoS Layout CSS (최종 정리본)
   - 공통 토큰 / reset / base / 공통 유틸 / 공통 컴포넌트
   - 헤더 고정 / 사이드바 고정 / 본문 가변 구조
   - 사이드바 서브메뉴 / 뱃지 / 드롭다운 / 반응형 포함
   - 중복 스타일 제거 완료
   ========================================================= */

/* =========================================================
   1. 폰트
   ========================================================= */
@font-face {
  font-family: 'Noto Sans KR';
  src: url('/assets/fonts/NotoSansKR-Regular.woff') format('woff'),
    url('/assets/fonts/NotoSansKR-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Noto Sans KR';
  src: url('/assets/fonts/NotoSansKR-Medium.woff') format('woff'),
    url('/assets/fonts/NotoSansKR-Medium.ttf') format('truetype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Noto Sans KR';
  src: url('/assets/fonts/NotoSansKR-SemiBold.woff') format('woff'),
    url('/assets/fonts/NotoSansKR-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Noto Sans KR';
  src: url('/assets/fonts/NotoSansKR-Bold.woff') format('woff'),
    url('/assets/fonts/NotoSansKR-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* =========================================================
   2. 디자인 토큰
   ========================================================= */
:root {
  --background: #ffffff;
  --foreground: #1a1a1a;
  --dashboard-background: #f9fafb;

  --card: #ffffff;
  --border: rgba(0, 0, 0, 0.1);

  --muted: #ececf0;
  --muted-foreground: #717182;

  --primary: #030213;
  --primary-foreground: #ffffff;

  --secondary: #f3f3f5;
  --destructive: #d4183d;

  --success-background: #dcfce7;
  --success-foreground: #166534;

  --warning-background: #fef3c7;
  --warning-foreground: #92400e;

  --danger-background: #fee2e2;
  --danger-foreground: #991b1b;

  --info-background: #dbeafe;
  --info-foreground: #1e40af;
  --info: #3b82f6;

  --radius: 0.625rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;

  --text-400: #9ca3af;
  --text-500: #6b7280;
  --text-600: #4b5563;
  --text-700: #374151;
  --text-900: #111827;

  --header-height: 73px;
  --sidebar-width: 256px;
  --sidebar-collapsed-width: 80px;
}

/* =========================================================
   3. Reset
   ========================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

/* =========================================================
   4. Base
   ========================================================= */
html,
body {
  min-height: 100%;
}

body {
  font-family: 'Noto Sans KR', sans-serif;
  background-color: var(--dashboard-background);
  color: var(--foreground);
  line-height: 1.5;
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

/* =========================================================
   5. 공통 유틸리티
   ========================================================= */
.stack-6>*+* {
  margin-top: var(--space-6);
}

.list-stack>*+* {
  margin-top: var(--space-3);
}

.scroll-y {
  max-height: 18rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.text-xs {
  font-size: 0.75rem;
}

.text-sm {
  font-size: 0.875rem;
}

.text-2xl {
  font-size: 1.5rem;
}

.font-medium {
  font-weight: 500;
}

.font-semibold {
  font-weight: 600;
}

.font-extrabold {
  font-weight: 800;
}

.text-gray-400 {
  color: var(--text-400);
}

.text-gray-500 {
  color: var(--text-500);
}

.text-gray-600 {
  color: var(--text-600);
}

.text-gray-700 {
  color: var(--text-700);
}

.text-gray-900 {
  color: var(--text-900);
}

.mt-1 {
  margin-top: var(--space-1);
}

.mt-4 {
  margin-top: var(--space-4);
}

/* =========================================================
   6. 공통 카드 / 박스
   ========================================================= */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-6);
}

.soft-box {
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 0.75rem;
  background-color: #f9fafb;
}

.outline-box {
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 0.75rem;
}

/* =========================================================
   7. 버튼 / 뱃지 / Pill
   ========================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  font-size: 0.875rem;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    opacity 0.2s ease;
}

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

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

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

.btn.primary:hover {
  opacity: 0.9;
}

.pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid #e5e7eb;
  border-radius: 9999px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-500);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
}

.badge.success {
  background-color: var(--success-background);
  color: var(--success-foreground);
}

.badge.warning {
  background-color: var(--warning-background);
  color: var(--warning-foreground);
}

.badge.danger {
  background-color: var(--danger-background);
  color: var(--danger-foreground);
}

.badge.info {
  background-color: var(--info-background);
  color: var(--info-foreground);
}

/* =========================================================
   8. 공통 입력 / 선택
   ========================================================= */
.form-select {
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  background-color: #fff;
  color: var(--foreground);
}

/* =========================================================
   9. 공통 텍스트 요소
   ========================================================= */
.section-heading {
  font-size: 1.25rem;
  font-weight: 700;
}

.sub-heading {
  font-size: 1.125rem;
  font-weight: 600;
}

.block-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.field-label {
  font-size: 0.875rem;
  color: #4b5563;
}

.helper-text {
  font-size: 0.75rem;
  color: #9ca3af;
}

.value-unit {
  margin-left: 0.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-500);
}

/* =========================================================
   10. 공통 아이콘
   ========================================================= */
.icon {
  width: 20px;
  height: 20px;
}

.icon-small {
  width: 16px;
  height: 16px;
}

.icon-blue {
  filter: brightness(0) saturate(100%) invert(42%) sepia(93%) saturate(1352%) hue-rotate(209deg) brightness(101%) contrast(93%);
}

.icon-red {
  filter: brightness(0) saturate(100%) invert(18%) sepia(88%) saturate(5423%) hue-rotate(354deg) brightness(91%) contrast(92%);
}

.icon-green {
  filter: brightness(0) saturate(100%) invert(48%) sepia(81%) saturate(417%) hue-rotate(94deg) brightness(92%) contrast(91%);
}

.icon-purple {
  filter: brightness(0) saturate(100%) invert(26%) sepia(89%) saturate(5833%) hue-rotate(256deg) brightness(96%) contrast(97%);
}

.icon-yellow {
  filter: brightness(0) saturate(100%) invert(56%) sepia(80%) saturate(2335%) hue-rotate(15deg) brightness(96%) contrast(97%);
}

/* =========================================================
   11. 고정 Header / Sidebar / Main 구조
   ========================================================= */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 0 1.5rem;
  z-index: 1000;
  display: flex;
  align-items: center;
}

.header-content {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 100%;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
}

.header-left {
  gap: 1rem;
}

.header-right {
  gap: 1rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 6px;
}

.logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-text h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #111827;
}

.logo-text p {
  font-size: 0.75rem;
  color: #6b7280;
}

.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: #fff;
  border-right: 1px solid #e5e7eb;
  padding: 1rem;
  overflow-y: auto;
  z-index: 900;
  transition:
    width 0.3s ease,
    left 0.3s ease;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-overlay {
  display: none;
}

.main-content {
  margin-top: var(--header-height);
  margin-left: var(--sidebar-width);
  min-height: calc(100vh - var(--header-height));
  padding: 1.5rem;
  background: var(--dashboard-background);
  transition: margin-left 0.3s ease;
}

.sidebar.collapsed~.main-content {
  margin-left: var(--sidebar-collapsed-width);
}

/* =========================================================
   12. 사이드바 메뉴
   ========================================================= */
.menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.25rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
}

.menu-item:hover {
  background: #f3f4f6;
}

.menu-item.active {
  background: #dbeafe;
  color: #2563eb;
}

.menu-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: block;
}

.submenu {
  display: none;
  margin-top: 0.25rem;
  margin-left: 1.5rem;
}

.submenu .menu-item,
.submenu-item {
  padding: 0.625rem 0.875rem 0.625rem 1rem;
  font-size: 0.8125rem;
}

.menu-badge {
  margin-left: auto;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: #ef4444;
  color: #ffffff;
  font-size: 0.625rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.collapse-btn {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
}

.sidebar.collapsed .menu-text,
.sidebar.collapsed .collapse-text {
  display: none;
}

.sidebar.collapsed .menu-item {
  justify-content: center;
}

.collapse-arrow {
  transition: transform 0.2s ease;
  transform-origin: 50% 50%;
}

.sidebar.collapsed .collapse-arrow {
  transform: rotate(180deg);
}

/* =========================================================
   13. 사이드바 버튼/포커스 보정
   ========================================================= */
.sidebar button.menu-item {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
}

.sidebar form {
  margin: 0;
}

.sidebar .menu-item[role="button"] {
  background: transparent;
  border: none;
}

.sidebar-logout-btn {
  width: 100%;
  background: transparent;
  border: none;
}

.menu-item:focus {
  outline: none;
}

.menu-item:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.menu-right {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.submenu-arrow-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: block;
}

.sidebar.collapsed .menu-right {
  display: none;
}

/* =========================================================
   14. 헤더 사용자 영역 / 드롭다운
   ========================================================= */
.header-user-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.header-user-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.625rem;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
}

.header-user-trigger:focus {
  outline: none;
}

.header-user-trigger:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
  border-radius: 0.875rem;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 42px;
  padding-left: 0.75rem;
  padding-right: 0;
  border-left: 1px solid #e5e7eb;
  min-width: 0;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: #eff6ff;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-avatar-icon {
  width: 22px;
  height: 22px;
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  line-height: 1.25;
  min-width: 0;
}

.user-info p:first-child {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  color: #111827;
}

.user-info p:last-child {
  margin: 0.125rem 0 0;
  font-size: 0.75rem;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.header-user-arrow-wrap {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header-user-arrow {
  width: 16px;
  height: 16px;
  display: block;
  transition: transform 0.18s ease;
}

.header-user-arrow.is-open {
  transform: rotate(180deg);
}

.header-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0.5rem;
  width: 200px;
  min-width: 200px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0.875rem;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.12);
  padding: 0.25rem 0;
  z-index: 1200;

  /* 기본은 닫힘 상태 */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-8px) scale(0.96);
  transform-origin: top right;

  transition:
    opacity 0.18s ease,
    transform 0.18s ease,
    visibility 0.18s ease;
}

.header-dropdown-menu.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.header-dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: none;
  text-decoration: none;
  color: #111827;
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  text-align: left;
}

.header-dropdown-item:hover {
  background: #f8fafc;
}

.header-dropdown-button {
  appearance: none;
  -webkit-appearance: none;
}

.header-dropdown-icon {
  width: 0.95rem;
  height: 0.95rem;
  flex-shrink: 0;
}

.header-dropdown-divider {
  height: 1px;
  margin: 0.25rem 0;
  background: #e5e7eb;
}

.header-dropdown-item.logout {
  color: #ef4444;
}

.header-dropdown-item.logout:hover {
  background: #fef2f2;
}

/* =========================================================
   15. 반응형
   - 1023px 이하: 사이드바 버튼 표시 + 오프캔버스
   - 767px 이하: 헤더/본문 여백 축소
   - 575px 이하: 초소형 화면 보정
   ========================================================= */

/* 1280px 이하 */
@media (max-width: 1280px) {
  :root {
    --sidebar-width: 232px;
  }

  .header {
    padding: 0 1rem;
  }

  .main-content {
    padding: 1.25rem;
  }

  .logo-text h1 {
    font-size: 1.125rem;
  }

  .logo-text p {
    font-size: 0.6875rem;
  }
}

/* 1023px 이하 */
@media (max-width: 1023px) {
  :root {
    --header-height: 64px;
  }

  .mobile-menu-btn {
    display: block;
  }

  .header {
    padding: 0 1rem;
  }

  .header-left {
    gap: 0.75rem;
    min-width: 0;
  }

  .header-right {
    gap: 0.5rem;
  }

  .logo {
    min-width: 0;
  }

  .logo-mark {
    width: 36px;
    height: 36px;
  }

  .logo-text h1 {
    font-size: 1rem;
  }

  .logo-text p {
    font-size: 0.6875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
  }

  .user-profile {
    min-height: 48px;
    padding-left: 0.75rem;
    padding-right: 0;
  }

  .user-avatar {
    width: 40px;
    height: 40px;
  }

  .user-avatar-icon {
    width: 20px;
    height: 20px;
  }

  .user-info p:first-child {
    font-size: 0.9rem;
  }

  .user-info p:last-child {
    font-size: 0.75rem;
  }

  .sidebar {
    left: -256px;
    width: 256px;
    padding: 0.875rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.16);
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar.collapsed {
    width: 256px;
  }

  .main-content,
  .sidebar.collapsed~.main-content {
    margin-left: 0;
    padding: 1rem;
  }

  .sidebar-overlay.open {
    display: block;
    position: fixed;
    inset: 0;
    top: var(--header-height);
    background: rgba(0, 0, 0, 0.45);
    z-index: 800;
  }

  .menu-item {
    padding: 0.75rem 0.875rem;
  }

  .submenu {
    margin-left: 1rem;
  }

  .submenu-item {
    padding-left: 1.5rem;
  }

}

/* 767px 이하 */
@media (max-width: 767px) {
  :root {
    --header-height: 60px;
    --radius: 0.75rem;
  }

  html {
    font-size: 15px;
  }

  .header {
    padding: 0 0.75rem;
  }

  .header-content {
    gap: 0.5rem;
  }

  .header-left {
    flex: 1 1 auto;
    min-width: 0;
  }

  .header-right {
    flex: 0 0 auto;
  }

  .logo-text p {
    display: none;
  }

  .user-info p:last-child {
    display: none;
  }

  .user-profile {
    gap: 0.625rem;
    min-height: 44px;
    padding-left: 0.625rem;
    padding-right: 0;
  }

  .user-avatar {
    width: 38px;
    height: 38px;
  }

  .main-content,
  .sidebar.collapsed~.main-content {
    padding: 0.875rem;
  }

  .card {
    padding: 1rem;
  }

  .btn {
    min-height: 40px;
    padding: 0.5rem 0.875rem;
  }

  .form-select {
    width: 100%;
    min-height: 40px;
  }

  .scroll-y {
    max-height: none;
    padding-right: 0;
  }

  .menu-badge {
    min-width: 1.375rem;
    height: 1.375rem;
    font-size: 0.6875rem;
  }

}

/* 575px 이하 */
@media (max-width: 575px) {
  html {
    font-size: 14px;
  }

  .header {
    padding: 0 0.625rem;
  }

  .logo-mark {
    width: 32px;
    height: 32px;
  }

  .logo-text h1 {
    font-size: 0.9375rem;
  }

  .main-content,
  .sidebar.collapsed~.main-content {
    padding: 0.75rem;
  }

  .card {
    padding: 0.875rem;
  }

  .menu-item {
    gap: 0.625rem;
    padding: 0.6875rem 0.75rem;
    font-size: 0.8125rem;
  }

  .menu-icon {
    width: 18px;
    height: 18px;
  }

  .submenu-item {
    padding-left: 1.25rem;
  }
}