/*
  좌측 사이드바 + 앱 셸 (ChatGPT/Cursor 스타일 파일 접근)
  - .app-sidebar: 좌측 고정 칼럼(--sidebar-w)
  - .app-main: 사이드바 폭만큼 우측으로 밀린 메인 영역
*/

.app-shell {
  min-height: 100vh;
}

/* ===== 모바일 토글/오버레이 (데스크톱 숨김) ===== */
.sidebar-toggle {
  display: none;
}

.sidebar-overlay {
  display: none;
}

/* ===== 사이드바 ===== */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background-color: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 60;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--foreground);
}

.sidebar-brand:hover {
  text-decoration: none;
}

.sidebar-new-form {
  display: contents;
}

button.sidebar-new {
  background: none;
  cursor: pointer;
}

.sidebar-new {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--foreground);
  border: 2px solid #000;
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  white-space: nowrap;
}

.sidebar-new:hover {
  text-decoration: none;
  background-color: var(--background);
}

/* ===== 보드 목록 ===== */
.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-cell {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 8px;
}

.sidebar-cell:hover {
  background-color: var(--background);
}

.sidebar-cell.active {
  background-color: #ececef;
}

.sidebar-cell-link {
  flex: 1;
  min-width: 0;
  padding: 0.5rem;
  font-size: 0.875rem;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-cell-link:hover {
  text-decoration: none;
}

.sidebar-cell.active .sidebar-cell-link {
  font-weight: 600;
}

/* 셀 우측: 최근 접속일 */
.sidebar-cell-date {
  flex-shrink: 0;
  font-size: 0.6875rem;
  color: var(--muted);
  white-space: nowrap;
  padding-right: 2px;
}

/* 셀 메뉴 (native details) */
.sidebar-cell-menu {
  position: relative;
}

.sidebar-cell-more {
  list-style: none;
  cursor: pointer;
  padding: 0 0.5rem;
  color: var(--muted);
  opacity: 0;
  font-size: 1rem;
  line-height: 1;
  user-select: none;
}

.sidebar-cell-more::-webkit-details-marker {
  display: none;
}

.sidebar-cell:hover .sidebar-cell-more,
.sidebar-cell-menu[open] .sidebar-cell-more {
  opacity: 1;
}

.sidebar-menu-pop {
  position: absolute;
  right: 0;
  top: 100%;
  min-width: 120px;
  background-color: #fff;
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-menu-pop form {
  margin: 0;
}

.sidebar-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.5rem;
  font-size: 0.8125rem;
  border: none;
  background: transparent;
  border-radius: 4px;
  color: var(--foreground);
  cursor: pointer;
  font-family: inherit;
}

.sidebar-menu-item:hover {
  background-color: var(--background);
  text-decoration: none;
}

.sidebar-menu-item.danger {
  color: var(--danger);
}

.sidebar-empty {
  color: var(--muted);
  font-size: 0.8125rem;
  padding: 0.75rem;
}

/* ===== 푸터 ===== */
.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-user {
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-foot-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-settings-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.sidebar-settings-btn:hover {
  color: var(--foreground);
  background-color: var(--background);
  text-decoration: none;
}

/* ===== 메인 영역 ===== */
.app-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

.app-main-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.empty-state {
  text-align: center;
  color: var(--muted);
}

.empty-state h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--foreground);
}

.empty-state p {
  margin: 0 0 1.25rem;
}

/* ===== 모바일: 오프캔버스 사이드바 ===== */
@media (max-width: 768px) {
  .sidebar-toggle {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    left: 12px;
    z-index: 70;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    background-color: #fff;
    border: 2px solid #000;
    border-radius: 8px;
    color: var(--foreground);
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    transition: left 0.25s ease;
  }

  /* 사이드바가 열리면 토글 버튼도 그 폭만큼 우측으로 밀려 가리지 않게 함 */
  .app-sidebar-wrap.is-open .sidebar-toggle {
    left: calc(min(280px, 82vw) + 12px);
  }

  .app-sidebar {
    width: min(280px, 82vw);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.18);
  }

  .app-sidebar-wrap.is-open .app-sidebar {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background-color: rgba(0, 0, 0, 0.4);
  }

  .sidebar-overlay[hidden] {
    display: none;
  }
}

/* ===== 터치 기기: hover 의존 메뉴 상시 노출 ===== */
@media (pointer: coarse) {
  .sidebar-cell-more {
    opacity: 1;
  }
}
