/* =============================================
   증빙서 측면표지 제작 프로그램 - Stylesheet
   ============================================= */

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

:root {
  /* 라이트 모드 — 더 선명한 대비 */
  --color-bg: #eef2f9;
  --color-surface: #ffffff;
  --color-surface-2: #ffffff;   /* 흰색 배경으로 검정 글씨 대비 극대화 */
  --color-surface-3: #dde4f0;
  --color-surface-hover: #e8eef9;
  --color-header-bg: rgba(255, 255, 255, 0.95);
  --color-border: #b8ccee;
  --color-border-light: #d0dcf0;

  --color-primary: #3558e8;
  --color-primary-hover: #2144c8;
  --color-primary-glow: rgba(53, 88, 232, 0.15);
  --color-secondary: #0ea5e9;
  --color-accent: #d946ef;

  --color-text: #000000;        /* 완전한 블랙 */
  --color-text-muted: #222222;   /* 매우 진한 회색 */
  --color-text-subtle: #777777;  /* 플레이스홀더용 회색 */

  --color-success: #059669;
  --color-warning: #d97706;
  --color-error: #dc2626;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 4px rgba(30,60,120,0.10);
  --shadow-md: 0 4px 16px rgba(30,60,120,0.10);
  --shadow-lg: 0 10px 30px rgba(30,60,120,0.13);
  --shadow-glow: 0 0 18px var(--color-primary-glow);

  --transition: all 0.2s ease;
  --font: 'Pretendard', 'Noto Sans KR', sans-serif;
  color-scheme: light;
}

body.dark-theme {
  /* 다크 모드 — 더 진한 배경과 높은 대비 */
  --color-bg: #090c14;
  --color-surface: #111827;
  --color-surface-2: #1a2236;
  --color-surface-3: #232e45;
  --color-surface-hover: #2a3a58;
  --color-header-bg: rgba(9, 12, 20, 0.95);
  --color-border: #2a3f6a;
  --color-border-light: #1e3060;

  --color-primary: #5b7fff;
  --color-primary-hover: #7a99ff;
  --color-primary-glow: rgba(91, 127, 255, 0.3);
  --color-secondary: #38bdf8;
  --color-accent: #e879f9;

  --color-text: #f0f4ff;
  --color-text-muted: #a0b0d0;
  --color-text-subtle: #586a90;

  --color-success: #34d399;
  --color-warning: #fbbf24;
  --color-error: #f87171;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 24px var(--color-primary-glow);

  color-scheme: dark;
}

html {
  font-size: 16px; /* 14→16px: 프로그램 글시 크게 */
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(53,88,232,0.07) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 100%, rgba(14,165,233,0.06) 0%, transparent 55%);
}

body.dark-theme {
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(91,127,255,0.12) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 100%, rgba(56,189,248,0.08) 0%, transparent 55%);
}

/* ---- App Container ---- */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px 60px;
  min-height: 100vh;
}

/* ---- Header ---- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-header-bg);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);  /* 헤더에 연준감 */
  padding: 18px 0;
  margin: 0 -20px;
  padding-left: 20px;
  padding-right: 20px;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  font-size: 32px;
  filter: drop-shadow(0 0 12px rgba(79,110,247,0.5));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.app-title {
  font-size: 1.5rem; /* 타이틀 폰트 키우기 */
  font-weight: 800;
  background: linear-gradient(135deg, #3558e8 0%, #7c3aed 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.03em;
}

body.dark-theme .app-title {
  background: linear-gradient(135deg, #7a99ff 0%, #c084fc 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.app-subtitle {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 3px;
  font-weight: 400;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.font-select-wrapper {
  position: relative;
}

.font-select {
  padding: 9px 14px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  color: var(--color-text);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 500;           /* 글자 진하게 */
  cursor: pointer;
  outline: none;
  transition: var(--transition);
  -webkit-appearance: none;  /* 브라우저 기본 스타일 제거 */
  appearance: none;
}

.font-select option {
  background: var(--color-surface);
  color: var(--color-text);
}

.btn-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 1.2rem;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
}

.btn-theme-toggle:hover {
  background: var(--color-surface-2);
  border-color: var(--color-primary);
  transform: rotate(15deg);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px; /* 더 크게 */
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 1rem;    /* 0.875rem → 1rem */
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  transition: opacity 0.15s;
}

.btn:hover::after { opacity: 0.06; }
.btn:active::after { opacity: 0.12; }

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, #7c5fcc 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(79,110,247,0.35);
}

.btn-primary:hover {
  box-shadow: 0 6px 25px rgba(79,110,247,0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  border-color: var(--color-border-light);
  background: var(--color-surface-3);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.1);
  color: var(--color-error);
  border: 1px solid rgba(248,113,113,0.2);
  padding: 5px 10px;
  font-size: 0.8rem;
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.2);
  border-color: var(--color-error);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* ---- Main Content ---- */
.main-content {
  padding-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ---- Section ---- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.section-actions {
  display: flex;
  gap: 8px;
}

/* ---- Input Section ---- */
.input-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
}

/* ---- Table ---- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table thead tr {
  background: var(--color-surface-2);
  border-bottom: 2px solid var(--color-border);
}

.data-table th {
  padding: 12px 14px;
  text-align: left;
  font-size: 0.9rem;      /* 헤더 폰트 크게 */
  font-weight: 700;      /* 더 두께 */
  color: var(--color-text); /* 블랙 */
  letter-spacing: 0;
  white-space: nowrap;
}

.col-no     { width: 60px; }
.col-title  { width: auto; min-width: 180px; }
.col-year   { width: 100px; }
.col-quarter{ width: 160px; }
.col-serial { width: 100px; }
.col-org    { width: 180px; }
.col-width  { width: 100px; }
.col-action { width: 70px; text-align: center; }

.data-table tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background 0.15s;
}

.data-table tbody tr:last-child {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--color-surface-hover, rgba(53, 88, 232, 0.04));
}

.data-table tbody td {
  padding: 7px 10px;    /* 약간 더 컨 패딩 */
  vertical-align: middle;
  font-size: 0.95rem;   /* 셀 폰트 크게 */
}

.data-table tbody td.cell-no {
  text-align: center;
  color: var(--color-text); /* 블랙 */
  font-size: 0.95rem;
  font-weight: 600;
}

/* ---- Table Inputs ---- */
.cell-input {
  width: 100%;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border); /* 테두리를 더 선명하게 */
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 500;           /* 글자를 더 진하게 */
  padding: 8px 10px;
  transition: var(--transition);
  outline: none;
  opacity: 1;
}

.cell-input:focus {
  border-color: var(--color-primary);
  background: rgba(79, 110, 247, 0.08);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.cell-input::placeholder {
  color: var(--color-text-subtle);
}

select.cell-input {
  cursor: pointer;
  appearance: none;
  -webkit-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='%238b92b5' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

.cell-input option {
  background-color: var(--color-surface);
  color: var(--color-text);
}

/* ---- Preview Section ---- */
.preview-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
}

.preview-note {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.82rem;
  color: #e8c96c;
  margin-bottom: 20px;
}

.labels-container {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: flex-start;
  align-items: flex-start;
}

/* ---- Individual Label Card (screen preview) ---- */
.label-card-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.label-card-no {
  font-size: 0.72rem;
  color: var(--color-text-subtle);
  font-weight: 500;
}

.label-card {
  background: white;
  color: #111;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  height: 480px;
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: default;
  font-family: var(--label-font, 'Pretendard', sans-serif); /* 선택된 폰트 적용 */
}

.label-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.15);
}

.label-card-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  padding: 0;
  padding-bottom: 52px; /* 기관명 영역(50px) + 테두리(2px) 예약 */
  text-align: center;
  border: 1px solid #000;
  box-sizing: border-box;
}

.label-section {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-bottom: 1px solid #000;
  padding: 0; /* 패딩 제거 */
  height: 35px;
  flex-shrink: 0;
  overflow: hidden;
  box-sizing: border-box;
}

.label-section:last-child {
  border-bottom: none;
}

.label-header-item {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%; /* 부모 높이 전체 사용 */
}

.label-static-text {
  font-size: 0.6em;
  font-weight: 500;
  color: #000;
  margin-bottom: 0;
  line-height: 1;
  width: 100%;
  border-bottom: 1px solid #000;
  padding: 0;
  flex: 1; /* 높이 균등 분할 */
  display: flex;
  align-items: center;
  justify-content: center;
}

.label-value-text {
  font-size: 0.8em;
  font-weight: 700;
  color: #000;
  white-space: nowrap;
  overflow: hidden;
  line-height: 1;
  flex: 1; /* 높이 균등 분할 */
  display: flex;
  align-items: center;
  justify-content: center;
}

.label-body {
  flex: 1;
  display: grid;
  place-items: center;  /* vertical-rl 텍스트 중앙정렬에 grid가 더 안정적 */
  padding: 4px 2px;
  overflow: visible;
  box-sizing: border-box;
}

.label-main-title {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-weight: 900;
  color: #000;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.label-footer {
  position: absolute;  /* 항상 하단에 고정 — flex 계산에 의존 안 함 */
  bottom: 1px;         /* 카드 inner 테두리 1px 무시 */
  left: 1px;
  right: 1px;
  height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: white;   /* 본문이 비치지 않도록 */
  border-top: 1px solid #000;
  overflow: hidden;
  box-sizing: border-box;
}

.label-footer .label-static-text {
  width: 100%;
  text-align: center;
  border-bottom: 1px solid #000;
  border-bottom: 1px solid #000;
  box-sizing: border-box;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.label-org-value {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-weight: 700;
  color: #000;
  white-space: nowrap;
  overflow: hidden;
}

/* Top bar accent on label */
.label-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, #4f6ef7, #7c5fcc);
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-subtle);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ---- Toast Notification ---- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 0.875rem;
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  animation: slideInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 320px;
}

.toast.toast-success { border-left: 3px solid var(--color-success); }
.toast.toast-error   { border-left: 3px solid var(--color-error); }
.toast.toast-info    { border-left: 3px solid var(--color-primary); }

@keyframes slideInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =============================================
   PRINT STYLES
   ============================================= */
.print-area {
  display: none;
}

@media print {
  body {
    background: white !important;
    color: black !important;
  }

  .app-container, .app-header, .main-content, .toast {
    display: none !important;
  }

  .print-area {
    display: block !important;
    width: 210mm;
    margin: 0;
    padding: 0;
    background: white;
  }

  .print-page {
    display: flex;
    flex-wrap: wrap;
    gap: 5mm;
    justify-content: center; /* 가로 중앙 정렬 */
    align-items: center;     /* 세로 중앙 정렬 */
    width: 297mm;
    height: 210mm;
    padding: 10mm;
    box-sizing: border-box;
  }

  .print-page:not(:last-child) {
    page-break-after: always;
  }

  .print-label {
    border: 0.5pt solid #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    height: 190mm; 
    position: relative;
    overflow: hidden;
    background: white !important;
    color: black !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
    font-family: var(--label-font, 'Pretendard', sans-serif) !important;
  }

  .print-label-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    padding: 0;
    padding-bottom: 17mm; /* 기관명 영역(16mm) + 테두리(1mm) 예약 */
    text-align: center;
    box-sizing: border-box;
  }

  .print-label-section {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-bottom: 0.5pt solid #000;
    padding: 0; /* 패딩 제거 */
    box-sizing: border-box;
    flex-shrink: 0;
    height: 11mm;
    overflow: hidden;
  }



  .print-label-org-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    overflow: hidden;
  }

  .print-label-org-value {
    white-space: nowrap;
    font-weight: 700;
    display: inline-block;
    transform-origin: center;
  }

  .print-label-section:last-child {
    position: absolute;  /* 항상 하단에 고정 */
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-top: 0.5pt solid #000;
    border-bottom: none;
    height: 16mm;
    overflow: hidden;
    padding: 0;
    background: white;  /* 본문 텍스트가 밑에 찼위로 보이지 않도록 */
  }

  .print-label-section:last-child .print-label-static {
    width: 100%;
    border-bottom: 0.5pt solid #000;
    padding: 0.5mm 1mm;
    box-sizing: border-box;
  }

  .print-label-section:last-child .print-label-value {
    padding: 0.5mm 1mm;
  }



  .print-label-static {
    font-size: 0.6em;
    font-weight: 500;
    margin-bottom: 0;
    width: 100%;
    border-bottom: 0.5pt solid #000;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .print-label-value {
    font-size: 0.8em;
    font-weight: 700;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .print-label-body {
    flex: 1;
    display: grid;
    place-items: center;  /* 세로 텍스트 중앙정렬 */
    padding: 2mm 1mm;
    box-sizing: border-box;
  }

  .print-label-main-title {
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-weight: 900;
    letter-spacing: 0.1em;
    white-space: nowrap;
  }

  @page {
    size: A4 landscape;
    margin: 0;
  }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .app-title { font-size: 1rem; }
  .header-actions { flex-wrap: wrap; }
  .section-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .input-section, .preview-section { padding: 16px; }
}
