/* Moart 어패럴 프로 스튜디오 확장 스타일
   - 페이지 탭(제작 스튜디오 / 작업내역)
   - Before / After 샘플 비교 카드
   - 표준 작업내역 2줄 검색/날짜/보기전환 툴바 · 7컬럼 테이블(리스트) · 5x5 갤러리 · 페이지네이션
   - 100% Moart 디자인 토큰 준수 (하드코딩 색상 0건) */

.ap-tabs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  margin: 0;
  width: fit-content;
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
}

.ap-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.ap-tab:hover { color: var(--text-primary); background: var(--bg-subtle); }
.ap-tab.is-active { background: var(--accent); color: var(--text-inverse, var(--bg-surface)); }

.ap-tab__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.ap-tab.is-active .ap-tab__count {
  background: var(--bg-surface);
  border-color: transparent;
  color: var(--accent);
}

/* Before / After 샘플 비교 섹션 */
.ap-compare-card {
  margin: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 16px;
  padding: 20px 22px;
}

.ap-compare-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.ap-compare-title { margin: 0; font-size: 16px; font-weight: 800; color: var(--text-primary); }
.ap-compare-sub { margin: 4px 0 0; font-size: 12.5px; color: var(--text-secondary); }

.ap-compare-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1.35fr);
  gap: 14px;
  align-items: stretch;
}

.ap-compare-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  min-width: 0;
}

.ap-compare-pane--after { border-color: var(--accent); background: var(--bg-surface); }
.ap-compare-pane__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.ap-compare-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
}

.ap-compare-pill--after {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inverse, var(--bg-surface));
}

.ap-compare-media {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  cursor: zoom-in;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  max-height: 360px;
}

.ap-compare-media img {
  width: 100%;
  height: 100%;
  max-height: 360px;
  object-fit: contain;
  display: block;
}

.ap-compare-zoom-hint {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  opacity: 0.92;
}

.ap-compare-rawbox {
  border-radius: 10px;
  border: 1px dashed var(--border-default);
  background: var(--bg-surface);
  padding: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.ap-compare-arrow { display: flex; align-items: center; justify-content: center; }

.ap-compare-arrow__circle {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--text-inverse, var(--bg-surface));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
}

.ap-compare-caption { margin: 0; font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }

.ap-compare-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-default);
}

.ap-compare-metric {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  font-size: 12px;
  color: var(--text-primary);
}

.ap-compare-metric strong { color: var(--accent); font-weight: 800; }

/* 표준 작업내역 패널 (HTML 변환 / 이미지 번역 작업내역과 동일 구조) */
.ap-v2-hist-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 20px;
  border-radius: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
}

.ap-v2-hist-toolbar {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
}

.ap-v2-hist-row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ap-v2-hist-search {
  flex: 1 1 240px;
  min-width: 200px;
  height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  box-sizing: border-box;
}

.ap-v2-hist-search input {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
}

.ap-v2-hist-ctrl {
  height: 38px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  box-sizing: border-box;
}

.ap-v2-hist-ctrl.is-sm {
  height: 32px;
  padding: 0 9px;
  font-size: 12px;
}

.ap-v2-hist-dates {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.ap-v2-hist-btns { display: inline-flex; align-items: center; gap: 6px; }
.ap-v2-hist-btn { height: 38px; padding: 0 16px; border-radius: 9px; font-size: 13px; white-space: nowrap; }

.ap-v2-hist-row2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--border-default);
}

.ap-hist-quick-dates { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ap-v2-hist-right { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ap-hist-count-info { font-size: 12.5px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.ap-hist-count-info b { color: var(--text-primary); }

.ap-v2-view-switch {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border-radius: 9px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  gap: 3px;
}

.ap-v2-view-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.ap-v2-view-btn.is-active {
  background: var(--accent);
  color: var(--text-inverse, var(--bg-surface));
}

.ap-dummy-pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  background: var(--bg-surface);
  border: 1px dashed var(--accent);
  color: var(--accent);
  white-space: nowrap;
}

/* 리스트형 정식 7컬럼 데이터 테이블 */
.ap-history-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-default);
  border-radius: 12px;
  background: var(--bg-surface);
}

.ap-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.ap-history-table thead th {
  padding: 11px 12px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-default);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ap-history-table tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-default);
  color: var(--text-primary);
  vertical-align: middle;
}

.ap-history-table tbody tr:last-child td { border-bottom: 0; }
.ap-history-table tbody tr:hover td { background: var(--bg-subtle); }

.ap-tbl-thumb-btn {
  display: block;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-subtle);
  cursor: zoom-in;
}

.ap-tbl-thumb { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }

.ap-tbl-name { display: flex; flex-direction: column; gap: 5px; min-width: 180px; }
.ap-tbl-name strong { font-size: 13.5px; font-weight: 800; color: var(--text-primary); cursor: pointer; }
.ap-tbl-name strong:hover { color: var(--accent); }
.ap-tbl-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.ap-tbl-detail { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); }
.ap-tbl-detail-text { font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; }
.ap-tbl-nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ap-tbl-date { white-space: nowrap; font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.ap-tbl-actions { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.ap-history-dots { display: inline-flex; align-items: center; gap: 4px; }

/* 갤러리 5x5 그리드 */
.ap-v2-gallery-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.ap-v2-gal-card {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.12s ease;
}

.ap-v2-gal-card:hover { border-color: var(--accent); transform: translateY(-2px); }

.ap-v2-gal-thumb-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--bg-subtle);
  overflow: hidden;
}

.ap-v2-gal-thumb-btn {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.ap-v2-gal-thumb-btn img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }

.ap-v2-gal-mode {
  position: absolute;
  left: 7px;
  top: 7px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  font-size: 10px;
  font-weight: 800;
}

.ap-v2-gal-pts {
  position: absolute;
  right: 7px;
  top: 7px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--text-inverse, var(--bg-surface));
  font-size: 10.5px;
  font-weight: 800;
}

.ap-v2-gal-body { padding: 10px; display: grid; gap: 5px; }

.ap-v2-gal-title {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ap-v2-gal-meta { display: flex; align-items: center; justify-content: space-between; gap: 4px; font-size: 11px; color: var(--text-secondary); }
.ap-v2-gal-date { font-size: 10.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ap-v2-gal-actions { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 4px; margin-top: 3px; }
.ap-v2-gal-actions .ap-btn { padding: 0 6px; font-size: 11.5px; justify-content: center; }

/* 페이지네이션 */
.ap-hist-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 14px;
}

.ap-page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}

.ap-page-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inverse, var(--bg-surface));
}

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

.ap-history-empty {
  padding: 48px 24px;
  text-align: center;
  border-radius: 14px;
  border: 1px dashed var(--border-default);
  background: var(--bg-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.ap-history-empty h3 { margin: 0; font-size: 15.5px; font-weight: 800; color: var(--text-primary); }
.ap-history-empty p { margin: 0; font-size: 13px; color: var(--text-secondary); max-width: 420px; }

/* 확대/작업상세 모달 */
.ap-detail-dialog {
  width: min(920px, 94vw);
  max-height: 90vh;
  padding: 0;
  border: 1px solid var(--border-default);
  border-radius: 16px;
  background: var(--bg-surface);
  color: var(--text-primary);
  overflow: hidden;
}

.ap-detail-dialog--compare { width: min(1160px, 96vw); }
.ap-compare-media--tall { min-height: 240px; max-height: 540px; padding: 8px; box-sizing: border-box; }
.ap-compare-media--tall img { max-height: 520px; width: 100%; height: auto; object-fit: contain; }
.ap-compare-media--tall svg { width: 100%; height: auto; max-height: 520px; display: block; }

.ap-detail-dialog::backdrop { background: var(--overlay-backdrop, rgba(0, 0, 0, 0.55)); }

.ap-detail-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-default);
}

.ap-detail-dialog__body {
  padding: 18px;
  max-height: calc(90vh - 64px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ap-detail-dialog__hero {
  width: 100%;
  max-height: 560px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
}

@media (max-width: 1240px) { .ap-v2-gallery-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 960px) {
  .ap-compare-grid { grid-template-columns: minmax(0, 1fr); }
  .ap-compare-arrow { transform: rotate(90deg); }
  .ap-v2-gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 600px) { .ap-v2-gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
