/* MYERP UI density overrides - sidebar min width safeguard
   Ensures the left menu never shrinks below 200px (even in flex layouts). */

:root{
  /* 원하는 기본 폭(넉넉하게) */
  --myerp-sidebar-default: 200px;

  /* 요청하신 최소 폭(절대 아래로 내려가지 않게) */
  --myerp-sidebar-min: 160px;
}

html{
  font-size: 14px; /* 16px -> 14px (전체 -2 느낌) */
}

.btn{
  font-size: 0.9rem; /* 버튼 텍스트만 -1 */
}

/* Common sidebar containers used across templates */
.sidebar,
.app-sidebar,
#sidebar,
#app-sidebar,
nav.sidebar,
aside.sidebar{
  min-width: var(--myerp-sidebar-minw) !important;
  flex: 0 0 var(--myerp-sidebar-minw) !important; /* prevents flex shrink */
  width: auto;
}

/* If a wrapper controls the sidebar width */
.sidebar-wrapper,
.app-sidebar-wrapper,
#sidebar-wrapper,
.layout-sidebar{
  min-width: var(--myerp-sidebar-minw) !important;
}

/* Keep menu items readable when very narrow screens */
@media (max-width: 420px){
  .sidebar,
  .app-sidebar,
  #sidebar,
  #app-sidebar{
    min-width: var(--myerp-sidebar-minw) !important;
  }
}


/* ----------------
   Sidebar width (Desktop)
   - 핵심: flex 아이템인 .sidebar-desktop을 고정
   - display는 각 화면/인라인 CSS가 제어해도 됨
   ---------------- */
@media (min-width: 992px){
  /* 레이아웃이 .app-shell flex 구조일 때 */
  .app-shell > .sidebar-desktop{
    /* 기본 폭은 260px, 하지만 최소 200px은 보장 */
    width: max(var(--myerp-sidebar-default), var(--myerp-sidebar-min)) !important;
    min-width: var(--myerp-sidebar-min) !important;

    /* flex shrink 방지 */
    flex: 0 0 max(var(--myerp-sidebar-default), var(--myerp-sidebar-min)) !important;
  }

  /* 사이드바 내부 컨테이너도 안전하게 */
  .sidebar-desktop .sidebar,
  .sidebar{
    min-width: var(--myerp-sidebar-min) !important;
  }

  /* 본문은 줄어들 수 있게(사이드바 대신 main이 줄어들고 스크롤되게) */
  .app-shell > main,
  .app-shell > .main,
  main{
    min-width: 0 !important;
  }
}

/* ----------------
   Sidebar width (General safety)
   - 어떤 구조에서든 sidebar가 너무 눌리지 않게
   ---------------- */
.sidebar-desktop{
  min-width: var(--myerp-sidebar-min);
}

/* ----------------
   Wide tables: allow horizontal scroll
   - /imports/transactions, /cash-plans 같은 화면에서 필수
   ---------------- */
.table-responsive,
.table-responsive-sm,
.table-responsive-md,
.table-responsive-lg,
.table-responsive-xl{
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table{
  /* 테이블이 레이아웃을 밀어내지 않게 */
  max-width: 100%;
}

/* 필요하면 특정 컨테이너도 스크롤 허용(안전) */
.card,
.card-body,
.content,
.content-body{
  max-width: 100%;
}

/* ----------------
   Optional: Theme token mapping helpers (있다면 유지)
   - 이미 테마 적용을 위해 bg-body로 바꾸셨다면 필요 없지만,
     특정 화면이 bg-white/bg-light를 박는 경우 대비
   ---------------- */
.bg-light{ background-color: var(--bs-body-bg) !important; }
.bg-white{ background-color: var(--bs-body-bg) !important; } /* 카드가 있다면 --bs-tertiary-bg로 바꿔도 됩니다 */

/* =======================================
   Account autocomplete dropdown (Dark fix)
   ======================================= */

[data-bs-theme="dark"] .btn{
  background-color: var(--bs-body-bg) !important;
}

