/* ─────────────────────────────────────────────────────────────
   기본 레이아웃
   ───────────────────────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic",
               "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-weight: 400;
  background-color: #f8f9fa;
  padding-top: 56px;
}

.container-card {
  background-color: #ffffff;
  padding: 20px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  margin-bottom: 20px;
}


/* ─────────────────────────────────────────────────────────────
   텍스트 및 제목 - 모두 일반 굵기
   ───────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  color: #343a40;
  font-weight: 400;
}

.card-header h6 {
  font-weight: 500;
}


/* ─────────────────────────────────────────────────────────────
   폼 요소 - 모두 일반 굵기
   ───────────────────────────────────────────────────────────── */
.form-label {
  color: #495057;
  font-weight: 400;
}

.form-control, .form-select {
  border-radius: 5px;
  border: 1px solid #ced4da;
  font-weight: 400;
  transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.form-control:focus, .form-select:focus {
  border-color: #80bdff;
  box-shadow: 0 0 0 0.25rem rgba(0, 123, 255, 0.25);
}


/* ─────────────────────────────────────────────────────────────
   버튼 - 일반 굵기
   ───────────────────────────────────────────────────────────── */
.btn {
  border-radius: 5px;
  font-weight: 400;
  transition: all 0.2s ease-in-out;
}

.badge {
  font-weight: 400;
}


/* ─────────────────────────────────────────────────────────────
   네비게이션 바
   ───────────────────────────────────────────────────────────── */
.navbar {
  background-color: #343a40 !important;
}

.navbar-brand {
  font-weight: 700;
  color: #ffffff !important;
}

.nav-link {
  color: rgba(255, 255, 255, 0.75) !important;
  font-weight: 400;
}

.nav-link:hover {
  color: #ffffff !important;
}


/* ─────────────────────────────────────────────────────────────
   카드 헤더 색상 (1번 이미지와 동일하게)
   ───────────────────────────────────────────────────────────── */
.card-header.bg-primary {
  background-color: #007bff !important;
  color: #ffffff !important;
}

.card-header.bg-success {
  background-color: #28a745 !important;
  color: #ffffff !important;
}

.card-header.bg-primary h6,
.card-header.bg-success h6 {
  color: #ffffff !important;
}

.card-header.bg-primary i,
.card-header.bg-success i {
  color: #ffffff !important;
}

/* 밝은 배경 헤더는 어두운 텍스트 */
.card-header.bg-light {
  background-color: #f8f9fa !important;
  color: #343a40 !important;
}

.card-header.bg-light h6 {
  color: #343a40 !important;
}

.card-header.bg-light i {
  color: #343a40 !important;
}


/* ─────────────────────────────────────────────────────────────
   버튼 색상 (2번 이미지와 동일하게)
   ───────────────────────────────────────────────────────────── */
.btn-warning {
  background-color: #ffc107 !important;
  border-color: #ffc107 !important;
  color: #000 !important;
}
.btn-warning:hover {
  background-color: #e0a800 !important;
  border-color: #d39e00 !important;
  color: #000 !important;
}

.btn-info {
  background-color: #17a2b8 !important;
  border-color: #17a2b8 !important;
  color: #fff !important;
}
.btn-info:hover {
  background-color: #138496 !important;
  border-color: #117a8b !important;
  color: #fff !important;
}


/* ─────────────────────────────────────────────────────────────
   진행바
   ───────────────────────────────────────────────────────────── */
.progress {
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar {
  transition: width 0.6s ease;
}


/* ─────────────────────────────────────────────────────────────
   파일 그리드 레이아웃 - 빈 공간 없이 채우기
   ───────────────────────────────────────────────────────────── */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
}


/* ─────────────────────────────────────────────────────────────
   파일 카드 (컴팩트)
   ───────────────────────────────────────────────────────────── */
.file-card-compact {
  transition: all 0.2s ease;
  background: #fff;
  width: 100%;
  max-width: 180px; /* 기본값 유지(카드가 너무 넓어지지 않도록) */
}
.file-card-compact:hover {
  box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}
.file-card-compact a {
  font-size: 0.85rem;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* 파일 카드 내 모든 텍스트 일반 굵기 */
.file-card-compact,
.file-card-compact * {
  font-weight: 400 !important;
}


/* ─────────────────────────────────────────────────────────────
   (공통) 파일 카드 버튼 컨테이너 기본값 (기존 유지)
   ───────────────────────────────────────────────────────────── */
.file-card-buttons { /* 처리된 목록(2버튼) 기본 레이아웃 */
  display: flex;
  gap: 0.15rem;
}
.file-card-buttons > button,
.file-card-buttons > form {
  width: calc(50% - 0.075rem);
}
.file-card-buttons form { margin: 0; padding: 0; }
.file-card-buttons .btn-sm {
  padding: 0.1rem 0.2rem !important;
  font-size: 0.65rem !important;
  width: 100%;
  text-align: center;
}

/* 1버튼(백업) 기본 레이아웃 */
.file-card-single-button {
  display: flex;
  justify-content: center;
}
.file-card-single-button .btn-sm {
  padding: 0.15rem 0.3rem !important;
  font-size: 0.7rem !important;
  min-width: 50px;
  text-align: center;
}


/* ─────────────────────────────────────────────────────────────
   (공통) Outline 기본값 (기존 유지)
   ───────────────────────────────────────────────────────────── */
.file-card-compact .btn-outline-primary {
  background-color: transparent !important;
  color: #0d6efd !important;
  border: 1px solid #0d6efd !important;
}
.file-card-compact .btn-outline-primary:hover {
  background-color: #0d6efd !important;
  color: #fff !important;
}
.file-card-compact .btn-outline-danger {
  background-color: transparent !important;
  color: #dc3545 !important;
  border: 1px solid #dc3545 !important;
}
.file-card-compact .btn-outline-danger:hover {
  background-color: #dc3545 !important;
  color: #fff !important;
}

/* 기존 d-flex gap-2 레거시 대응 */
.file-card-compact .d-flex.gap-2 { display: flex; gap: 0.2rem; }
.file-card-compact .d-flex.gap-2 > * { flex: 1; }
.file-card-compact .d-flex.gap-2 form { display: contents; }


/* ─────────────────────────────────────────────────────────────
   !!! 목록별 버튼 스타일 "분리" 규칙 (HTML에 클래스만 달아주면 적용)
   - processed-list 블록의 보기/삭제
   - backup-list 블록의 보기
   ───────────────────────────────────────────────────────────── */

/* 처리된 파일 목록(Processed) : 컨테이너 세부 튜닝 */
.processed-list .file-card-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;  /* 보기/삭제 2열 격자 */
  gap: 0.2rem;
}

/* 보기(처리된) — 전용 클래스 우선 */
.processed-list .btn-view-processed,
.processed-list .file-card-buttons .btn-outline-primary { /* (백워드 호환) */
  border-color: #3b82f6 !important;
  color: #1d4ed8 !important;
  background: transparent !important;
  padding: .35rem .55rem !important;
  font-size: .8rem !important;
  font-weight: 600 !important;
}
.processed-list .btn-view-processed:hover,
.processed-list .file-card-buttons .btn-outline-primary:hover {
  background: rgba(59,130,246,.10) !important;
  color: #1d4ed8 !important;
}

/* 삭제(처리된) — 전용 클래스 우선(더 작게) */
.processed-list .btn-delete-processed,
.processed-list .file-card-buttons .btn-outline-danger { /* (백워드 호환) */
  border-color: #ef4444 !important;
  color: #b91c1c !important;
  background: transparent !important;
  padding: .25rem .45rem !important;     /* 더 작게 */
  font-size: .72rem !important;          /* 더 작게 */
  font-weight: 600 !important;
}
.processed-list .btn-delete-processed:hover,
.processed-list .file-card-buttons .btn-outline-danger:hover {
  background: rgba(239,68,68,.10) !important;
  color: #b91c1c !important;
}

/* 백업 파일 목록(Backup) : 1버튼 컨테이너 */
.backup-list .file-card-single-button {
  display: flex;
  margin-top: .25rem;
}

/* 보기(백업) — 전용 클래스 우선(초록계열), 기존 .btn-outline-primary 사용 시에도 분리 적용 */
.backup-list .btn-view-backup,
.backup-list .file-card-single-button .btn-outline-primary { /* (백워드 호환) */
  width: 100%;
  border-color: #10b981 !important; /* emerald-500 */
  color: #047857 !important;        /* emerald-700 */
  background: transparent !important;
  padding: .42rem .7rem !important;
  font-size: .8rem !important;
  font-weight: 700 !important;      /* 백업은 강조 */
}
.backup-list .btn-view-backup:hover,
.backup-list .file-card-single-button .btn-outline-primary:hover {
  background: rgba(16,185,129,.12) !important;
  color: #047857 !important;
}


/* ─────────────────────────────────────────────────────────────
   [★ 보완] 버튼 크기 “완전 통일”(처리/백업 공통)
   - 폰트/라인하이트/패딩을 변수화해서 두 목록 크기 동일
   - 기존 개별 padding/font-size를 덮어써서 시각적 높이 통일
   ───────────────────────────────────────────────────────────── */
:root{
  --btn-font: .80rem;    /* 버튼 폰트 크기 통일 지점 */
  --btn-line: 1.2;       /* 버튼 라인하이트 통일 지점 */
  --btn-py: .32rem;      /* 수직 패딩 */
  --btn-px: .60rem;      /* 좌우 패딩 */
}

.processed-list .file-card-buttons .btn,
.backup-list    .file-card-single-button .btn {
  font-size: var(--btn-font) !important;
  line-height: var(--btn-line) !important;
  padding: var(--btn-py) var(--btn-px) !important;
  min-height: calc(1em * var(--btn-line) + (var(--btn-py) * 2)) !important;
}

/* 이전 규칙보다 더 구체적으로 동일 규격을 한 번 더 보장 */
.processed-list .file-card-buttons .btn.btn-outline,
.backup-list    .file-card-single-button .btn.btn-outline {
  font-size: var(--btn-font) !important;
  line-height: var(--btn-line) !important;
  padding: var(--btn-py) var(--btn-px) !important;
}


/* ─────────────────────────────────────────────────────────────
   [★ 보완] 카드 “자동 한줄 배치”
   - 기존 Bootstrap .row.g-3를 Grid로 오버라이드(HTML 수정 無)
   - 우측 여백 최소화, 화면 너비에 맞춰 자연스럽게 줄 수 변경
   ───────────────────────────────────────────────────────────── */
.processed-list .card-body > .row.g-3,
.backup-list    .card-body .row.g-3 {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .75rem;
}

/* 그리드 기준으로 카드 폭이 잘 늘어나도록 제한 완화 */
.processed-list .file-card-compact,
.backup-list    .file-card-compact {
  max-width: none !important;   /* 기존 180px 제한을 목록 구간에 한해 해제 */
  min-width: 160px;
  width: 100%;
}


/* ─────────────────────────────────────────────────────────────
   반응형 파일 그리드 (기존 유지)
   ───────────────────────────────────────────────────────────── */
@media (max-width: 1400px) {
  .file-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}
@media (max-width: 1200px) {
  .file-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}
@media (max-width: 992px) {
  .file-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}
@media (max-width: 768px) {
  .file-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
}
@media (max-width: 576px) {
  .file-grid { grid-template-columns: repeat(auto-fit, minmax(45%, 1fr)); }
}


/* ─────────────────────────────────────────────────────────────
   백업 파일 리스트
   ───────────────────────────────────────────────────────────── */
.list-group-item .bg-light {
  transition: background-color 0.2s ease;
}
.list-group-item:hover .bg-light {
  background-color: #e9ecef !important;
}


/* ─────────────────────────────────────────────────────────────
   모달 - 파일 내용 보기
   ───────────────────────────────────────────────────────────── */
#fileViewContent {
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
  padding: 1rem;
  border-radius: 5px;
  max-height: 60vh;
  overflow-y: auto;
  font-weight: 400;
}

.modal-body pre::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.modal-body pre::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}
.modal-body pre::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}
.modal-body pre::-webkit-scrollbar-thumb:hover {
  background: #555;
}


/* ─────────────────────────────────────────────────────────────
   접근성 - Skip to content
   ───────────────────────────────────────────────────────────── */
.visually-hidden-focusable:not(:focus):not(:focus-within) {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.visually-hidden-focusable:focus {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  padding: 1rem;
  background: #000;
  color: #fff;
}


/* ─────────────────────────────────────────────────────────────
   전역 폰트 굵기 강제 (Bootstrap 오버라이드)
   ───────────────────────────────────────────────────────────── */
* { font-weight: inherit; }
strong, b { font-weight: 600; }
label, .form-label, .card-title, .list-group-item strong {
  font-weight: 400 !important;
}


/* ─────────────────────────────────────────────────────────────
   반응형
   ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .card-body {
    padding: 1.5rem !important;
  }
  body {
    font-size: 0.95rem;
  }
}

/* === [FIX] 처리된 목록 보기/삭제 버튼 크기 완전 동일화 === */

/* 1) 그리드 두 칸을 꽉 채우게 강제 */
.processed-list .file-card-buttons {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: .2rem !important;
  align-items: stretch !important;   /* 높이도 칸 높이에 맞춰 늘림 */
}

/* 2) 그리드 아이템(버튼/폼) 자체를 칸 너비로 확장 */
.processed-list .file-card-buttons > * {
  width: 100% !important;
}

/* 3) 폼 안의 버튼도 100%로 확장 (폼이 그리드 아이템인 경우 대비) */
.processed-list .file-card-buttons > form { display: block !important; }
.processed-list .file-card-buttons > form > button {
  display: block !important;
  width: 100% !important;
}

/* 4) 예전 플렉스 기반 전역 규칙 덮어쓰기(폭 계산식 무력화) */
.processed-list .file-card-buttons > button,
.processed-list .file-card-buttons > form {
  width: 100% !important;
}

/* 5) 폰트/라인하이트/패딩 통일(높이 동일) — 필요 시 수치만 조정 */
:root{
  --btn-font: .80rem;
  --btn-line: 1.2;
  --btn-py: .32rem;
  --btn-px: .60rem;
}
.processed-list .file-card-buttons .btn {
  font-size: var(--btn-font) !important;
  line-height: var(--btn-line) !important;
  padding: var(--btn-py) var(--btn-px) !important;
  min-height: calc(1em * var(--btn-line) + (var(--btn-py) * 2)) !important;
  box-sizing: border-box;
}
