/* ================================================================
   PDF連結 — アップロード・並び順・プレビュー
   ================================================================ */

.merge-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

@media screen and (max-width: 600px) {
  .merge-wrap {
    padding: 1.5rem 1rem 3rem;
  }
}

.merge-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--surface);
  margin-bottom: 1.5rem;
}

.merge-drop-zone:hover,
.merge-drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}

.merge-drop-title {
  font-size: 17px;
  font-weight: 500;
  margin-bottom: 8px;
}

.merge-drop-sub {
  font-size: 14px;
  color: var(--muted);
}

.merge-file-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 1.5rem;
}

.merge-file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.25s, background 0.25s;
}

.merge-file-item--ready {
  border-color: #34A853;
  background: #F0FAF3;
}

.merge-file-item--error {
  border-color: var(--danger);
  background: #FEF0EF;
}

.merge-file-status {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
}

.merge-file-item--ready .merge-file-status {
  background: #34A853;
  color: #fff;
}

.merge-file-item--loading .merge-file-status {
  background: var(--bg);
  border: 2px solid var(--border);
}

.merge-file-body {
  flex: 1;
  min-width: 0;
}

.merge-file-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.merge-file-meta {
  font-size: 12px;
  color: var(--muted);
}

.merge-progress-bar {
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}

.merge-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.15s ease;
}

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

.merge-actions .btn-confirm {
  flex: 1;
  min-width: 180px;
}

/* 並び順ページ */
.merge-order-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.merge-order-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 1.5rem;
}

.merge-order-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.merge-order-row--dragging {
  opacity: 0.45;
}

.merge-order-row--drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

.merge-order-name {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.merge-order-pages {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.merge-filename-field {
  margin-bottom: 1.5rem;
}

.merge-filename-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}

.merge-filename-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  background: var(--surface);
  box-sizing: border-box;
}

.merge-filename-input:focus {
  outline: none;
  border-color: var(--accent);
}

.merge-order-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.merge-order-actions .btn-confirm {
  flex: 1;
  min-width: 180px;
}

/* プレビューページ */
#page-merge-preview.active {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  max-height: calc(100vh - 60px);
  overflow: hidden;
}

.merge-preview-layout {
  display: grid;
  grid-template-columns: 1fr;
  flex: 1;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.merge-preview-layout > .merge-preview-side,
.merge-preview-layout > .merge-preview-panel {
  min-height: 0;
}

@media screen and (min-width: 900px) {
  .merge-preview-layout {
    grid-template-columns: 320px 1fr;
  }
}

@media screen and (max-width: 899px) {
  .merge-preview-layout {
    grid-template-rows: auto 1fr;
  }

  .merge-preview-side {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

.merge-preview-side {
  padding: 1.5rem;
  border-right: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  align-self: start;
  z-index: 20;
  max-height: calc(100vh - 60px);
  overflow-y: auto;
}

@media screen and (min-width: 900px) {
  .merge-preview-side {
    height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
  }

  .merge-preview-actions {
    margin-top: auto;
  }
}

.merge-preview-side .page-title {
  font-size: 20px;
  margin-bottom: 4px;
}

.merge-preview-side .page-sub {
  margin-bottom: 1.5rem;
}

.merge-preview-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.merge-preview-actions .btn-confirm,
.merge-preview-actions .btn-back {
  width: 100%;
}

.merge-preview-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: #2a2a28;
}

.merge-preview-panel .panel-header {
  position: sticky;
  top: 0;
  z-index: 15;
  flex-shrink: 0;
  background: #2a2a28;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.merge-preview-panel .pdf-viewport {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
