/* 사이드바 스타일 */
.sidebar-nav {
  width: 90px;
  min-width: 90px;
  background-color: #f8f9fa;
  border-right: 1px solid #e0e0e0;
  padding: 12px 6px;
  box-sizing: border-box;
}

/* 장부 선택 컨테이너 */
.book-select-container {
  margin-bottom: 12px;
}

.book-select-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.book-select-label {
  font-size: 12px;
  font-weight: 600;
  color: #495057;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
}

.book-edit-btn {
  font-size: 10px;
  color: #6c757d;
  text-decoration: none;
  padding: 2px 6px;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  background-color: white;
  transition: all 0.2s ease;
  font-weight: 500;
}

.book-edit-btn:hover {
  color: #495057;
  border-color: #adb5bd;
  background-color: #f8f9fa;
}

.book-select {
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  background-color: white;
  color: #212529;
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
  appearance: none;
}

.book-select:hover {
  border-color: #adb5bd;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.book-select:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

/* 사이드바 메뉴 */
.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-menu li {
  margin-bottom: 4px;
}

/* 사이드바 링크 버튼 스타일 */
.sidebar-link {
  display: block;
  position: relative;
  /* 배지 위치 기준 */
  padding: 10px 6px;
  font-size: 13px;
  color: #495057;
  text-decoration: none;
  border-radius: 4px;
  transition: all 0.2s ease;
  background-color: white;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 500;
  text-align: center;
  width: 100%;
  box-sizing: border-box;
}

.sidebar-link.sidebar-action-btn {
  font-family: inherit;
  margin: 0;
}

.sidebar-link:hover {
  background-color: #e9ecef;
  color: #212529;
  border-color: #dee2e6;
  transform: translateX(2px);
}

.sidebar-link.active {
  background-color: #007bff;
  color: white;
  border-color: #007bff;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2);
}

.sidebar-link.active:hover {
  background-color: #0056b3;
  border-color: #0056b3;
  transform: translateX(2px);
}

/* 구분선 */
.sidebar-nav hr {
  margin: 12px 0;
  border: none;
  border-top: 1px solid #dee2e6;
}

/* 환경설정 링크 컨테이너 */
.sidebar-nav>div:last-of-type {
  margin-top: 8px;
}

/* 모바일 대응 */
/* 모바일 대응 */
@media (max-width: 768px) {

  /* 메인 컨테이너 (layout.html에서 인라인 스타일로 정의된 flex-container) */
  body>div:first-of-type {
    flex-direction: column;
    padding-bottom: 60px;
    /* 하단 네비게이션 높이만큼 여백 확보 */
  }

  /* 사이드바 -> 하단 네비게이션 바 */
  .sidebar-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    min-width: auto;
    height: 60px;
    background-color: white;
    border-right: none;
    border-top: 1px solid #ddd;
    border-bottom: none;
    padding: 0 10px;
    z-index: 1000;
    display: flex;
    align-items: center;
    overflow-x: auto;
    white-space: nowrap;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    /* 스크롤바 숨김 (옵션) */
    -ms-overflow-style: none;
    /* IE/Edge */
    scrollbar-width: none;
    /* Firefox */
  }

  .sidebar-nav::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
  }

  /* 모바일에서 장부 선택 숨김 (헤더로 이동 예정) */
  .book-select-container {
    display: none;
  }

  /* 구분선 숨김 */
  .sidebar-nav hr {
    display: none;
  }

  /* 사이드바 내부 래퍼(Thymeleaf fragment) Flex 처리 */
  .sidebar-nav>div {
    display: flex;
    flex-direction: row;
    align-items: center;
    height: 100%;
  }

  /* 메뉴 가로 배치 */
  .sidebar-menu {
    display: flex;
    flex-direction: row;
    gap: 8px;
    /* 항목 간 간격 */
    margin: 0 8px;
    flex-shrink: 0;
  }

  /* 링크 스타일 조정 */
  .sidebar-link {
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 13px;
    margin-bottom: 0;
    width: auto;
  }

  /* Active 상태 강조 수정 */
  .sidebar-link.active {
    box-shadow: none;
    border-bottom: 2px solid #007bff;
    /* 흰색 배경이므로 파란색 강조 */
    background-color: transparent;
    color: #007bff;
  }

  /* 마지막 div (환경설정) 마진 제거 */
  .sidebar-nav>div:last-child {
    margin-top: 0;
  }
}

/* 헤더의 모바일 장부 타이틀 표시 */
@media (max-width: 768px) {
  .mobile-book-title {
    display: block !important;
  }
}

/* 헤더 로그인 폼 스타일 */
.header-login-form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.login-inputs {
  display: flex;
  gap: 6px;
}

.login-input {
  width: 100px;
  padding: 4px;
  font-size: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.login-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.remember-me-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.login-buttons {
  display: flex;
  gap: 6px;
}

.login-btn {
  padding: 4px 8px;
  font-size: 12px;
  background-color: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
}

.signup-btn {
  padding: 4px 8px;
  font-size: 12px;
  text-decoration: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #f5f5f5;
  color: #333;
}

/* 모바일 로그인 화면 개선 */
@media (max-width: 768px) {

  /* 헤더 레이아웃 조정: 기본은 Row, Login 폼일때만 줄바꿈(Wrap) */
  header>div {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0 !important;
    /* gap 제거 (justify-content로 제어) */
  }

  /* 로고 영역 (Left) */
  .header-left {
    margin-bottom: 0;
    /* 마진 저거 */
    text-align: left;
    flex-shrink: 0;
  }

  /* 모바일 장부 선택 드롭다운 표시 */
  .mobile-book-select-wrapper {
    display: block !important;
    margin-top: 4px;
    /* 위치를 조금 아래로 */
  }

  .mobile-header-select {
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    max-width: 140px;
    height: 30px;
    /* 높이 매칭 */
  }

  /* 로그인 폼 컨테이너 (줄바꿈됨) */
  .header-login-form {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    /* 강제 줄바꿈 유발 (flex-wrap: wrap 상태에서) */
    flex-basis: 100%;
    background-color: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
    box-sizing: border-box;
    gap: 12px;
    margin-top: 10px;
    /* 로고와 간격 */
    order: 10;
    /* 가장 마지막에 배치 */
  }

  /* 로그인 후 사용자 메뉴는 줄바꿈 없이 우측 정렬 유지 */
  .header-user-menu {
    width: auto;
    margin-left: auto;
    /* 우측 밀착 */
  }

  .login-inputs {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .login-input {
    width: 100%;
    padding: 10px;
    font-size: 16px;
    box-sizing: border-box;
  }

  .login-actions {
    flex-direction: column;
    width: 100%;
    gap: 12px;
  }

  .remember-me-label {
    justify-content: flex-start;
    width: 100%;
    font-size: 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    padding-left: 2px;
  }

  .remember-me-label input[type="checkbox"] {
    margin: 0 6px 0 0;
    width: auto !important;
    height: auto !important;
    display: inline-block;
  }

  .login-buttons {
    width: 100%;
    display: flex;
    gap: 8px;
  }

  .login-btn,
  .signup-btn {
    flex: 1;
    width: 0;
    height: 44px;
    /* 높이 고정 */
    padding: 0;
    /* 패딩 제거하고 flex로 중앙 정렬 */
    font-size: 15px;
    text-align: center;
    justify-content: center;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    border-radius: 4px;
    margin: 0;
  }

  .login-btn {
    background-color: #007bff;
    color: white;
    border: 1px solid #007bff;
    font-weight: bold;
  }

  .signup-btn {
    border: 1px solid #ccc;
    background: #f8f9fa;
    color: #333;
  }

  /* 하단 메뉴 스크롤 힌트 (우측 그림자) */
  .sidebar-nav::after {
    content: '';
    position: fixed;
    bottom: 0;
    right: 0;
    width: 30px;
    height: 60px;
    /* 네비게이션 높이 */
    background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.9) 70%);
    pointer-events: none;
    /* 클릭 통과 */
    z-index: 1001;
  }
}