/* ==========================================================================
   버전관리 대시보드 - 미니멀 클린 스타일시트
   ========================================================================== */

:root {
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-light: #f5f3ff;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-code: #0f172a;
  
  --border-color: #e2e8f0;
  --border-dark: #cbd5e1;
  
  --success: #10b981;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
  --font-mono: Consolas, "SFMono-Regular", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}

.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   네비게이션 헤더
   ========================================================================== */
.navbar {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.auth-view {
  display: flex;
  align-items: center;
  gap: 10px;
}

.guest-indicator {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

.admin-badge {
  background-color: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}

/* ==========================================================================
   메인 컨테이너 & 툴바
   ========================================================================== */
.main-container {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #0f172a;
}

.count-tag {
  background-color: #e2e8f0;
  color: #475569;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.toolbar-right {
  display: flex;
  gap: 8px;
}

.permission-banner {
  background-color: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: 24px;
}

/* ==========================================================================
   버튼 스타일
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background-color: #0f172a;
  color: #ffffff;
}
.btn-primary:hover {
  background-color: #1e293b;
}

.btn-secondary {
  background-color: #ffffff;
  color: #334155;
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
}

.btn-outline {
  background-color: transparent;
  color: #0f172a;
  border-color: var(--border-color);
}
.btn-outline:hover {
  background-color: #f1f5f9;
}

.btn-subtle {
  background-color: transparent;
  color: var(--text-muted);
}
.btn-subtle:hover {
  background-color: #f1f5f9;
  color: var(--text-main);
}

.btn-sm {
  font-size: 0.875rem;
  padding: 5px 10px;
}

/* ==========================================================================
   버전별 리스트 & 카드 아코디언 토글
   ========================================================================== */
.version-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.version-item {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.version-item:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.version-item.is-open {
  border-color: #94a3b8;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.version-item.is-inactive {
  border-color: #e2e8f0;
  background: #f8fafc;
  opacity: 0.55;
  filter: grayscale(35%);
  transition: opacity 0.25s ease, filter 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.version-item.is-inactive:hover {
  opacity: 0.88;
  filter: grayscale(5%);
  border-color: #cbd5e1;
}

.version-item.is-inactive .version-badge {
  background-color: #f1f5f9;
  color: #64748b;
  border-color: #cbd5e1;
}

.version-item.is-active {
  border: 2px solid var(--primary);
  background: #ffffff;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  opacity: 1;
  filter: none;
}

.version-item.is-active .version-badge {
  background-color: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  font-weight: 700;
}

.badge-active-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* 행(헤더) 영역: 버전, 제목, 미리보기 버튼 */
.version-row {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  user-select: none;
  background-color: #ffffff;
  transition: background-color 0.15s ease;
}

.version-row:hover {
  background-color: #fafbfc;
}

/* 1) 버전 태그 */
.version-badge {
  background-color: #f1f5f9;
  color: #0f172a;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.version-item.is-active .version-badge {
  background-color: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

/* 2) 제목 */
.version-title-wrap {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.version-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.version-item.is-open .version-title {
  color: #2563eb;
}

.version-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* 3) 미리보기 버튼 (새창 열기 ↗) */
.version-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-preview {
  background-color: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  font-size: 0.875rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
}

.btn-restore {
  background: #ffffff;
  color: #334155;
  border-color: var(--border-color);
  font-size: 0.875rem;
  padding: 6px 12px;
}

.btn-restore:hover:not(:disabled) {
  border-color: #94a3b8;
  background: #f8fafc;
}

.btn-restore:disabled {
  background: #f0fdf4;
  color: #166534;
  border-color: #bbf7d0;
  cursor: default;
}
.btn-preview:hover {
  background-color: #dbeafe;
  color: #1e40af;
  border-color: #93c5fd;
}

.toggle-icon {
  font-size: 0.8rem;
  color: var(--text-light);
  transition: transform 0.2s ease;
  width: 16px;
  text-align: center;
}

.version-item.is-open .toggle-icon {
  transform: rotate(180deg);
  color: #2563eb;
}

/* ==========================================================================
   토글 상세 내용 영역 (변경된 내용 리스트 + 변경된 파일 목록)
   ========================================================================== */
.version-detail-body {
  display: none;
  padding: 0 20px 20px 20px;
  border-top: 1px solid var(--border-color);
  background-color: #fafafa;
}

.version-item.is-open .version-detail-body {
  display: block;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.detail-section {
  margin-top: 16px;
}

.detail-label {
  font-size: 0.875rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 변경된 내용 리스트 */
.change-summary-list {
  list-style: none;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.9375rem;
  color: #334155;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.change-summary-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.change-summary-list li::before {
  content: "•";
  color: #2563eb;
  font-weight: bold;
}

/* 변경된 파일 목록 리스트 (정확한 경로와 파일명) */
.file-list-box {
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.file-list-header {
  background-color: #f8fafc;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

.file-items-scroll {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.file-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.875rem;
  font-family: var(--font-mono);
  transition: background-color 0.1s ease;
}
.file-row-item:last-child {
  border-bottom: none;
}
.file-row-item:hover {
  background-color: #f8fafc;
}

.file-path-col {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-grow: 1;
}

.file-dir-path {
  color: #94a3b8;
}

.file-name-bold {
  color: #0f172a;
  font-weight: 600;
}

.file-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.file-open-link {
  font-size: 0.8125rem;
  color: #2563eb;
  text-decoration: none;
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 2px 7px;
  border-radius: 4px;
  transition: all 0.15s ease;
}
.file-open-link:hover {
  background-color: #dbeafe;
}

/* ==========================================================================
   페이지네이션 바 (Pagination)
   ========================================================================== */
.pagination-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 28px;
  padding-top: 14px;
}

.page-btn {
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  color: #334155;
  min-width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  padding: 0 6px;
}

.page-btn:hover:not(:disabled) {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

.page-btn.active {
  background-color: #0f172a;
  border-color: #0f172a;
  color: #ffffff;
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ==========================================================================
   모달 다이얼로그
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.modal-backdrop.hidden {
  display: none;
}

.modal-box, .modal-content-box {
  background-color: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 520px;
  overflow: hidden;
}

.modal-sm { max-width: 400px; }

.preview-modal-box {
  width: min(1440px, 96vw);
  height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.24);
}

.preview-modal-header {
  flex: 0 0 auto;
}

.preview-modal-meta {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.preview-modal-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #f8fafc;
}

.preview-modal-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--text-muted);
  text-align: center;
}

.preview-modal-status.is-error {
  color: var(--danger);
}

.version-preview-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
}

.close-modal-btn {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-light);
  cursor: pointer;
}
.close-modal-btn:hover { color: var(--text-main); }

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-tip {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #334155;
}

.form-group input, .form-group textarea {
  font-family: inherit;
  font-size: 1rem;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--text-main);
  transition: border-color 0.15s ease;
}

.form-group input:focus, .form-group textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.modal-footer {
  padding: 14px 20px;
  background-color: #fafbfc;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* 로딩 & 빈 상태 */
.loading-state, .empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e2e8f0;
  border-top-color: #0f172a;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 토스트 메시지 */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: #0f172a;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 2000;
}

.toast.hidden { display: none; }
.hidden { display: none !important; }

@media (max-width: 680px) {
  .navbar {
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
  }

  .auth-view {
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .guest-indicator,
  .admin-badge {
    display: none;
  }

  .main-container {
    padding: 22px 14px 48px;
  }

  .toolbar,
  .toolbar-left {
    align-items: flex-start;
  }

  .toolbar {
    flex-direction: column;
  }

  .toolbar-right {
    width: 100%;
  }

  .toolbar-right .btn {
    flex: 1;
  }

  .version-row {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px;
  }

  .version-title-wrap {
    width: calc(100% - 68px);
  }

  .version-title {
    white-space: normal;
  }

  .version-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .version-detail-body {
    padding: 0 14px 14px;
  }

  .file-row-item {
    align-items: flex-start;
    gap: 8px;
  }

  .file-path-col {
    flex-wrap: wrap;
    white-space: normal;
    word-break: break-all;
  }

  .file-row-actions {
    margin-left: auto;
  }
}
