/* 전체 기본 */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: clamp(13px, 2vw, 16px); }
body { min-width: 0 !important; overflow-x: hidden; }
img, video { max-width: 100%; }

/* 사이드바 & 레이아웃 */
.sidebar { transition: transform .25s cubic-bezier(.4,0,.2,1); }
.main-content { transition: margin-left .25s cubic-bezier(.4,0,.2,1); }

/* 모바일: 사이드바 숨김 */
@media (max-width: 767px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  #menuToggleBtn { display: flex !important; }
  #sidebarCloseBtn { display: flex !important; }
}
@media (min-width: 768px) {
  #sidebarOverlay { display: none !important; }
  #menuToggleBtn { display: none !important; }
  #sidebarCloseBtn { display: none !important; }
}

/* 내비게이션 아이템 */
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px; margin-bottom: 2px;
  color: #9CA3AF; font-size: 14px; font-weight: 500;
  cursor: pointer; text-decoration: none; transition: all .15s;
}
.nav-item:hover  { background: #374151; color: #F9FAFB; }
.nav-item.active { background: #F59E0B; color: #1F2937; font-weight: 600; }
.nav-item.active i { color: #1F2937; }
.nav-project-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 7px; margin-bottom: 2px;
  color: #9CA3AF; font-size: 13px; cursor: pointer; text-decoration: none; transition: all .15s;
  position: relative;
}
.nav-project-item a { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.nav-project-item:hover  { background: #374151; color: #F9FAFB; }
.nav-project-item.active { background: #1D4ED8; color: #fff; }

/* 카드 */
.stat-card {
  background: white; border-radius: 14px; padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1); }

/* 문서 행 */
.doc-row {
  display: grid; align-items: center;
  border-bottom: 1px solid #F3F4F6; transition: background .1s;
}
.doc-row:hover { background: #F9FAFB; }

/* 상태 뱃지 */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge-draft    { background:#F3F4F6; color:#6B7280; }
.badge-review   { background:#FEF3C7; color:#D97706; }
.badge-approved { background:#D1FAE5; color:#065F46; }
.badge-rejected { background:#FEE2E2; color:#B91C1C; }
.badge-archived { background:#EDE9FE; color:#5B21B6; }
.badge-planning   { background:#DBEAFE; color:#1D4ED8; }
.badge-active     { background:#D1FAE5; color:#065F46; }
.badge-completed  { background:#F3F4F6; color:#374151; }
.badge-suspended  { background:#FEE2E2; color:#B91C1C; }

/* 프로젝트 카드 */
.project-card {
  background: white; border-radius: 14px; padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07); cursor: pointer;
  transition: transform .15s, box-shadow .15s; border: 2px solid transparent;
}
.project-card:hover  { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.12); border-color: #F59E0B; }

/* 모바일 카드 터치 피드백 */
@media (max-width: 767px) {
  .project-card:active { transform: scale(0.98); box-shadow: 0 1px 4px rgba(0,0,0,.1); }
  .stat-card:active { transform: scale(0.98); }
}

/* 폼 */
.form-label  { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 4px; }
.form-input  {
  width: 100%; padding: 9px 13px; border: 1.5px solid #E5E7EB;
  border-radius: 8px; font-size: 14px; color: #111; outline: none; transition: border-color .15s;
}
.form-input:focus { border-color: #F59E0B; box-shadow: 0 0 0 3px rgba(245,158,11,.15); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }

/* 테이블 헤더 */
.table-header {
  display: grid; background: #F9FAFB;
  border-bottom: 2px solid #E5E7EB;
  padding: 10px 16px; font-size: 12px; font-weight: 700;
  color: #6B7280; text-transform: uppercase; letter-spacing: .05em;
}

/* 토스트 */
#toast { transition: opacity .2s; }
#toast.show { display: flex !important; }

/* 스크롤바 */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 99px; }

/* 카테고리 색 점 */
.cat-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* 빈 상태 */
.empty-state { text-align: center; padding: 48px 24px; color: #9CA3AF; }
.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: .4; }

/* 로딩 */
.spinner { border: 3px solid #E5E7EB; border-top-color: #F59E0B; border-radius: 50%; width: 32px; height: 32px; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 색상 선택 스와치 */
.color-swatch { width: 28px; height: 28px; border-radius: 6px; cursor: pointer; border: 2px solid transparent; transition: border-color .15s; }
.color-swatch:hover, .color-swatch.selected { border-color: #111; }

/* ── 모바일 반응형 ── */
@media (max-width: 767px) {
  /* 폼 그리드: 1열 */
  .grid.grid-cols-2 { grid-template-columns: 1fr !important; }
  .col-span-2 { grid-column: span 1 !important; }

  /* 모달 하단 시트 스타일 */
  #modalBox { border-radius: 20px 20px 0 0 !important; }
  #modalBody { padding: 16px !important; }
  #modalOverlay { align-items: flex-end !important; padding: 0 !important; }

  /* 공사 카드 그리드 1열 */
  .grid.grid-cols-1.md\\:grid-cols-2,
  .grid.grid-cols-2.lg\\:grid-cols-3,
  .grid.grid-cols-1.md\\:grid-cols-2.xl\\:grid-cols-3 {
    grid-template-columns: 1fr !important;
  }

  /* 통계 카드 */
  .grid.grid-cols-2.sm\\:grid-cols-4,
  .grid.grid-cols-2.lg\\:grid-cols-4 {
    grid-template-columns: 1fr 1fr !important;
  }

  /* 헤더 액션 버튼 텍스트 표시 */
  #headerActionLabel { display: inline !important; font-size: 13px; }

  /* 페이지 패딩 줄이기 */
  main { padding: 12px !important; }

  /* 카드 패딩 줄이기 */
  .project-card { padding: 14px !important; }
  .stat-card { padding: 14px !important; }

  /* 토스트 하단 중앙 */
  #toast {
    bottom: 80px !important;
    right: 12px !important;
    left: 12px !important;
    justify-content: center;
  }

  /* 공사 문서 헤더 버튼 wrap */
  .flex.flex-wrap.items-center.gap-4.justify-between { flex-direction: column; align-items: flex-start; gap: 12px; }

  /* 사용자 목록 행 */
  .flex.items-center.gap-4.px-5.py-3\\.5 { padding: 10px 12px !important; gap: 10px; }

  /* 검색바 full width */
  #userSearch, #coSearch, #docSearch { width: 100% !important; }

  /* 필터 바 wrap */
  .flex.flex-wrap.gap-3 { gap: 8px !important; }
  .flex.gap-3.items-center { flex-wrap: wrap; }

  /* 승인 결재 목록 */
  .grid.grid-cols-2.sm\\:grid-cols-4 { grid-template-columns: 1fr 1fr; }

  /* 긴 텍스트 줄바꿈 */
  .truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

  /* 테이블형 행 패딩 */
  .px-5 { padding-left: 12px !important; padding-right: 12px !important; }
  .px-6 { padding-left: 16px !important; padding-right: 16px !important; }

  /* 버튼 간격 */
  .gap-3 { gap: 8px !important; }
}
