/* =============================================
   상당초등학교 업무 정보 대시보드 - 스타일 v2
   ============================================= */

/* ── 폰트 ── */
body {
  font-family: 'Noto Sans KR', 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f3f4f6;
  color: #1f2937;
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* ── 헤더 ── */
.app-header {
  background: #1e3a5f;
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(30,58,95,0.3);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  border-radius: 12px;
  padding: 4px 8px;
  transition: background 0.2s;
  user-select: none;
}
.header-logo:hover {
  background: rgba(255,255,255,0.12);
}
.header-logo:active {
  background: rgba(255,255,255,0.2);
  transform: scale(0.98);
}
.logo-icon {
  width: 38px; height: 38px;
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  transition: background 0.2s;
}
.header-logo:hover .logo-icon { background: rgba(255,255,255,0.25); }
.logo-title { font-size: 15px; font-weight: 700; line-height: 1.2; }
.logo-sub   { font-size: 11px; opacity: 0.7; line-height: 1.2; }

.header-search { flex: 1; max-width: 480px; }
.search-box    { position: relative; display: flex; align-items: center; }
.search-icon   { position: absolute; left: 14px; color: #9ca3af; font-size: 14px; pointer-events: none; }
.search-input {
  width: 100%; padding: 9px 38px;
  border-radius: 12px; border: none;
  background: rgba(255,255,255,0.12); color: white;
  font-size: 14px; outline: none; transition: background 0.2s;
}
.search-input::placeholder { color: rgba(255,255,255,0.5); }
.search-input:focus { background: rgba(255,255,255,0.2); }
.search-clear {
  position: absolute; right: 10px;
  background: none; border: none; color: rgba(255,255,255,0.6);
  cursor: pointer; padding: 4px; border-radius: 6px; transition: color 0.2s;
}
.search-clear:hover { color: white; }

.header-actions { flex-shrink: 0; display: flex; align-items: center; gap: 10px; }

/* 뷰 토글 버튼 */
.view-toggle { display: flex; gap: 2px; background: rgba(255,255,255,0.1); border-radius: 10px; padding: 3px; }
.view-btn {
  width: 32px; height: 32px; border-radius: 8px; border: none;
  background: none; color: rgba(255,255,255,0.7); font-size: 14px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.view-btn:hover  { background: rgba(255,255,255,0.15); color: white; }
.view-btn.active { background: white; color: #1e3a5f; }

.admin-btn {
  display: flex; align-items: center;
  padding: 7px 14px;
  background: rgba(255,255,255,0.12); color: white;
  border: 1px solid rgba(255,255,255,0.2); border-radius: 10px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all 0.2s; white-space: nowrap;
}
.admin-btn:hover { background: rgba(255,255,255,0.2); }
.admin-btn.active { background: #f59e0b; border-color: #f59e0b; color: #1f2937; }

/* ── 레이아웃 ── */
.main-container {
  max-width: 1400px; margin: 0 auto; padding: 24px 20px;
  display: flex; gap: 24px; align-items: flex-start;
}

/* ── 사이드바 ── */
.sidebar { width: 200px; flex-shrink: 0; position: sticky; top: 72px; }
.sidebar-section { background: white; border-radius: 16px; padding: 14px; box-shadow: 0 1px 6px rgba(0,0,0,0.06); }
.sidebar-label { font-size: 11px; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.filter-list { display: flex; flex-direction: column; gap: 2px; }
.filter-btn {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 9px; border-radius: 8px; font-size: 13px;
  color: #374151; background: none; border: none; cursor: pointer;
  text-align: left; transition: all 0.15s; width: 100%;
}
.filter-btn:hover  { background: #f3f4f6; }
.filter-btn.active { background: #dbeafe; color: #1d4ed8; font-weight: 600; }
.filter-count {
  font-size: 11px; background: #f3f4f6; color: #6b7280;
  padding: 1px 6px; border-radius: 20px; min-width: 22px; text-align: center;
}
.filter-btn.active .filter-count { background: #bfdbfe; color: #1d4ed8; }
.sort-btn {
  flex: 1; padding: 6px 0; border-radius: 8px; font-size: 12px;
  border: 1px solid #e5e7eb; background: white; color: #6b7280;
  cursor: pointer; transition: all 0.15s;
}
.sort-btn.active { background: #1e3a5f; border-color: #1e3a5f; color: white; }

/* ── 메인 콘텐츠 ── */
.main-content { flex: 1; min-width: 0; }
.result-bar { margin-bottom: 14px; padding: 0 2px; }
.empty-state { text-align: center; padding: 80px 20px; color: #9ca3af; }

/* ── 카드 그리드 (Masonry) ── */
.card-grid { columns: 4; column-gap: 18px; }
@media (max-width: 1200px) { .card-grid { columns: 3; } }
@media (max-width: 900px)  { .card-grid { columns: 2; } }
@media (max-width: 600px)  { .card-grid { columns: 1; } }

/* ── 카드 ── */
.card {
  background: white; border-radius: 16px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
  break-inside: avoid; margin-bottom: 18px;
  cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
  overflow: hidden; display: block;
}
.card:hover  { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.card:focus  { outline: 2px solid #3b82f6; outline-offset: 2px; }
.card-top-bar { height: 4px; width: 100%; }
.card-body  { padding: 14px; }
.card-title {
  font-size: 14px; font-weight: 700; color: #111827;
  margin: 5px 0 5px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-summary {
  font-size: 12px; color: #6b7280; line-height: 1.55; margin-bottom: 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-tags  { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 9px; }
.card-footer { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid #f3f4f6; padding-top: 9px; }
.card-views { font-size: 11px; color: #9ca3af; white-space: nowrap; }

/* ── 뱃지 ── */
.cat-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.tag-badge { display: inline-block; padding: 2px 7px; border-radius: 20px; font-size: 10px; background: #f3f4f6; color: #6b7280; white-space: nowrap; }
.file-type-label { font-size: 10px; font-weight: 700; color: #9ca3af; background: #f9fafb; padding: 2px 6px; border-radius: 6px; }

/* ── 모달 ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 20px; backdrop-filter: blur(4px);
}
.modal-box {
  background: white; border-radius: 20px;
  width: 100%; max-width: 620px; max-height: 88vh;
  overflow-y: auto; position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: modal-in 0.2s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.modal-top-bar  { height: 5px; border-radius: 20px 20px 0 0; }
.modal-header   { padding: 20px 24px 14px; border-bottom: 1px solid #f3f4f6; }
.modal-title    { font-size: 20px; font-weight: 800; color: #111827; margin: 8px 0 0; line-height: 1.35; }
.modal-body     { padding: 18px 24px 24px; }
.modal-close    {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px; border-radius: 50%;
  background: #f3f4f6; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #6b7280; font-size: 14px; transition: background 0.15s;
}
.modal-close:hover { background: #e5e7eb; color: #374151; }

/* 미리보기 */
.preview-box {
  width: 100%; height: 360px; border-radius: 12px; overflow: hidden;
  background: #f9fafb; border: 1px solid #e5e7eb; margin-top: 12px;
}
.text-preview {
  background: #f9fafb; border-radius: 12px; padding: 16px;
  border: 1px solid #e5e7eb; margin-top: 12px; position: relative;
}
.text-preview pre {
  font-family: 'Noto Sans KR', monospace; font-size: 13px; line-height: 1.7;
  color: #374151; white-space: pre-wrap; word-break: break-word; margin: 0 0 40px;
}
.copy-btn {
  position: absolute; bottom: 12px; right: 12px;
  padding: 6px 14px; background: #1e3a5f; color: white;
  border: none; border-radius: 8px; font-size: 12px; cursor: pointer; transition: background 0.15s;
}
.copy-btn:hover { background: #2d5a8e; }
.hwp-notice {
  display: flex; flex-direction: column; align-items: center;
  padding: 32px; background: #eff6ff; border-radius: 12px; margin-top: 12px; text-align: center;
}
/* PDF/이미지 로딩 플레이스홀더 */
.preview-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; height: 100%; padding: 32px; text-align: center; color: #9ca3af;
}

/* ── 관리자 로그인 ── */
.admin-login-box {
  background: white; border-radius: 20px; padding: 28px;
  width: 100%; max-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2); animation: modal-in 0.2s ease;
}
.admin-input {
  width: 100%; padding: 10px 14px; border: 1.5px solid #e5e7eb; border-radius: 10px;
  font-size: 14px; outline: none; transition: border-color 0.15s; box-sizing: border-box;
}
.admin-input:focus { border-color: #3b82f6; }

/* ── 공통 버튼 ── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 18px; background: #1e3a5f; color: white;
  border: none; border-radius: 10px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 0.15s; text-decoration: none;
}
.btn-primary:hover    { background: #2d5a8e; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 18px; background: #f3f4f6; color: #374151;
  border: none; border-radius: 10px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 0.15s;
}
.btn-secondary:hover { background: #e5e7eb; }
.btn-edit   { display: inline-flex; align-items: center; padding: 7px 14px; background: #eff6ff; color: #1d4ed8; border: none; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; transition: background 0.15s; }
.btn-edit:hover   { background: #dbeafe; }
.btn-delete { display: inline-flex; align-items: center; padding: 7px 14px; background: #fef2f2; color: #dc2626; border: none; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer; transition: background 0.15s; }
.btn-delete:hover { background: #fee2e2; }
.tbl-btn    { width: 30px; height: 30px; border-radius: 8px; border: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; transition: all 0.15s; }
.tbl-btn.edit-btn   { background: #eff6ff; color: #1d4ed8; }
.tbl-btn.edit-btn:hover   { background: #dbeafe; }
.tbl-btn.delete-btn { background: #fef2f2; color: #dc2626; }
.tbl-btn.delete-btn:hover { background: #fee2e2; }

/* ── 폼 ── */
.form-label { display: block; font-size: 12px; font-weight: 700; color: #374151; margin-bottom: 5px; }
.form-input {
  width: 100%; padding: 9px 12px; border: 1.5px solid #e5e7eb; border-radius: 10px;
  font-size: 13px; outline: none; transition: border-color 0.15s;
  box-sizing: border-box; background: white; color: #111827; font-family: inherit;
}
.form-input:focus { border-color: #3b82f6; }
.form-textarea { resize: vertical; min-height: 80px; }

/* ── 파일 업로드 영역 ── */
.upload-guide {
  display: flex; align-items: center; padding: 10px 16px;
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 12px;
  margin-bottom: 4px;
}
.upload-zone { background: #f9fafb; border-radius: 12px; padding: 12px; border: 1px solid #e5e7eb; }
.upload-input-label {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 20px; border: 2px dashed #d1d5db; border-radius: 10px;
  cursor: pointer; transition: all 0.2s; background: white;
}
.upload-input-label:hover { border-color: #3b82f6; background: #eff6ff; }

/* ── 미리보기 카드 ── */
.preview-card {
  cursor: default !important;
  transform: none !important;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06) !important;
}

/* ── 통계 대시보드 ── */
.stats-grid-4 {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 16px;
}
@media (max-width: 900px) { .stats-grid-4 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 500px) { .stats-grid-4 { grid-template-columns: 1fr; } }

.stat-summary-card {
  background: white; border-radius: 16px; padding: 18px 20px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
  display: flex; align-items: center; gap: 14px;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.stat-label { font-size: 12px; color: #6b7280; font-weight: 500; margin-bottom: 3px; }
.stat-value { font-size: 22px; font-weight: 800; color: #111827; line-height: 1; }

.stats-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .stats-grid-2 { grid-template-columns: 1fr; } }

.stats-card {
  background: white; border-radius: 16px; padding: 20px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}
.stats-card-title { font-size: 14px; font-weight: 700; color: #111827; }

.top-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; transition: background 0.15s;
}
.top-item:hover { background: #f9fafb; }
.top-rank {
  width: 24px; height: 24px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
}
.rank-1 { background: #fef9c3; color: #854d0e; }
.rank-2 { background: #f3f4f6; color: #374151; }
.rank-3 { background: #fef3c7; color: #92400e; }
.rank-4, .rank-5 { background: #f3f4f6; color: #6b7280; }

.progress-bar-bg { height: 6px; background: #f3f4f6; border-radius: 3px; overflow: hidden; }
.progress-bar    { height: 100%; border-radius: 3px; transition: width 0.5s ease; }

.cat-stat-label {
  min-width: 64px; padding: 4px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; text-align: center; flex-shrink: 0;
}
.recent-list { display: flex; flex-direction: column; gap: 4px; }
.recent-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; transition: background 0.15s;
}
.recent-item:hover { background: #f9fafb; }
.recent-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── 토스트 ── */
#toast-root {
  position: fixed; bottom: 24px; right: 24px; z-index: 500;
  display: flex; flex-direction: column; gap: 8px;
}
.toast-item {
  padding: 12px 18px; border-radius: 12px; font-size: 13px; font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15); animation: toast-in 0.25s ease; max-width: 320px;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.toast-success { background: #10b981; color: white; }
.toast-error   { background: #ef4444; color: white; }
.toast-info    { background: #1e3a5f; color: white; }

/* ── 스크롤바 ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ── 반응형 ── */
@media (max-width: 768px) {
  .header-inner { flex-wrap: wrap; }
  .header-search { order: 3; width: 100%; max-width: 100%; }
  .main-container { flex-direction: column; padding: 16px; }
  .sidebar { width: 100%; position: static; }
  .modal-box { max-height: 95vh; }
  .preview-box { height: 260px; }
  .view-toggle { display: none; }
}

/* ── highlight ── */
mark { background: #fef9c3; border-radius: 2px; padding: 0 2px; }

/* ── 카테고리 관리 모달 ── */
.cat-mgr-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 10px;
  transition: border-color 0.15s;
}
.cat-mgr-item:hover { border-color: #d1d5db; }
.cat-mgr-dot {
  width: 12px; height: 12px; border-radius: 50%;
  flex-shrink: 0; transition: background 0.2s;
}
.cat-mgr-input {
  flex: 1; border: none; background: transparent;
  font-size: 14px; color: #374151; font-weight: 500;
  outline: none; padding: 2px 4px;
  border-bottom: 1.5px solid transparent;
  transition: border-color 0.15s;
}
.cat-mgr-input:focus { border-bottom-color: #3b82f6; }
.cat-mgr-del {
  width: 28px; height: 28px; flex-shrink: 0;
  background: none; border: none; border-radius: 6px;
  color: #9ca3af; font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.cat-mgr-del:hover { background: #fee2e2; color: #ef4444; }

/* ── 미리보기 전체화면 토글 ── */
.preview-wrapper {
  position: relative;
  margin-top: 12px;
}
.preview-expand-btn {
  position: absolute;
  top: 8px; right: 8px; z-index: 10;
  width: 32px; height: 32px;
  background: rgba(0,0,0,0.45);
  border: none; border-radius: 8px;
  color: white; font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.15s;
  backdrop-filter: blur(4px);
}
.preview-expand-btn:hover {
  background: rgba(0,0,0,0.65);
  transform: scale(1.1);
}

/* 전체화면 상태의 미리보기 오버레이 */
.preview-fullscreen-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.92);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  animation: pfs-in 0.2s ease;
}
@keyframes pfs-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.preview-fullscreen-inner {
  position: relative;
  width: 96vw; height: 90vh;
  display: flex; align-items: center; justify-content: center;
}
.preview-fullscreen-close {
  position: fixed; top: 16px; right: 16px;
  width: 40px; height: 40px;
  background: rgba(255,255,255,0.15);
  border: none; border-radius: 50%;
  color: white; font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.15s;
  z-index: 10001;
  backdrop-filter: blur(4px);
}
.preview-fullscreen-close:hover {
  background: rgba(255,255,255,0.3);
  transform: scale(1.1);
}
.preview-fullscreen-hint {
  position: fixed; bottom: 16px;
  color: rgba(255,255,255,0.5);
  font-size: 12px; text-align: center;
  z-index: 10001;
  user-select: none;
}

/* PDF.js 캔버스 컨테이너 */
.pdf-canvas-container {
  width: 100%; height: 100%;
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
  align-items: center;
  gap: 8px;
  background: #525659;
  border-radius: 10px;
  padding: 12px 8px;
  box-sizing: border-box;
}
.pdf-canvas-container canvas {
  display: block;
  box-shadow: 0 2px 12px rgba(0,0,0,0.35);
  border-radius: 4px;
  max-width: 100%;
}
.pdf-toolbar {
  display: flex; align-items: center;
  justify-content: center; gap: 10px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.55);
  border-radius: 10px;
  margin-bottom: 6px;
  color: white; font-size: 13px;
  user-select: none;
}
.pdf-toolbar button {
  background: rgba(255,255,255,0.15);
  border: none; border-radius: 6px;
  color: white; padding: 5px 10px;
  font-size: 13px; cursor: pointer;
  transition: background 0.15s;
}
.pdf-toolbar button:hover { background: rgba(255,255,255,0.3); }
.pdf-toolbar button:disabled { opacity: 0.4; cursor: default; }
.pdf-toolbar input[type=number] {
  width: 44px; text-align: center;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3); border-radius: 6px;
  color: white; padding: 4px 6px; font-size: 13px;
  -moz-appearance: textfield;
}
.pdf-toolbar input[type=number]::-webkit-inner-spin-button,
.pdf-toolbar input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; }
.pdf-toolbar span { color: rgba(255,255,255,0.7); font-size: 12px; }
