/* === PDF Organize — Tool Styles === */

[hidden] { display: none !important; }

.po-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

/* Drop zone */
.po-dropzone {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  margin-bottom: 1.5rem;
  user-select: none;
}
.po-dropzone:hover,
.po-dropzone:focus,
.po-dropzone.po-dragover {
  border-color: var(--accent);
  background: var(--accent-light);
  outline: none;
}
.po-dropzone__inner { pointer-events: none; }
.po-dropzone__icon { font-size: 2.5rem; margin-bottom: 12px; display: block; }
.po-dropzone__text { font-size: 1rem; font-weight: 500; color: var(--text-primary); margin: 0 0 8px; }
.po-dropzone__sub  { font-size: 0.85rem; color: var(--text-secondary); margin: 0 0 12px; }
.po-dropzone__inner .po-btn { pointer-events: auto; }

/* Toolbar */
.po-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface, #fff);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  margin-bottom: 1rem;
}
.po-pages-count {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}
.po-toolbar__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Status messages */
.po-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  background: var(--surface-alt, #f5f5f5);
  color: var(--text-primary);
}
.po-status--error { background: #fff0f0; color: #c0392b; border: 1px solid #f5c6cb; }
.po-status--info  { background: #fff8e6; color: #7a5b00; border: 1px solid #f0d97a; }
.po-status--error:empty,
.po-status--info:empty { display: none !important; }
.po-spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: po-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes po-spin { to { transform: rotate(360deg); } }

.po-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 1rem;
}
.po-sr-status {
  position: absolute;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

/* Page grid */
.po-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 1.5rem;
}

/* Page card */
.po-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface, #fff);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px;
  gap: 8px;
  cursor: grab;
  transition: box-shadow var(--transition), border-color var(--transition);
  user-select: none;
  outline: none;
}
.po-card:hover {
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  border-color: var(--accent);
}
.po-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.po-card.sortable-ghost { opacity: 0.4; }
.po-card.sortable-chosen { box-shadow: 0 4px 14px rgba(0,0,0,0.15); }
.po-card.sortable-drag { cursor: grabbing; }

.po-card__thumb {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 4px;
  background: var(--surface-alt, #f9f9f9);
}
.po-card__thumb canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.2s ease;
}
.po-card[data-rotation="90"]  .po-card__thumb canvas { transform: rotate(90deg)  scale(var(--po-rot-scale, 1)); }
.po-card[data-rotation="180"] .po-card__thumb canvas { transform: rotate(180deg); }
.po-card[data-rotation="270"] .po-card__thumb canvas { transform: rotate(270deg) scale(var(--po-rot-scale, 1)); }

.po-card__num {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-alt, #f5f5f5);
  border-radius: 4px;
  padding: 2px 8px;
}

.po-card__btn {
  position: absolute;
  top: 6px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--surface, #fff);
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.po-card__btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.po-card__delete { left: 6px; }
.po-card__delete:hover { background: #c0392b; border-color: #c0392b; }
.po-card__rotate { right: 6px; }

/* Buttons (shared) */
.po-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
}
.po-btn--primary {
  background: var(--accent, #1a73e8);
  color: #fff;
  border-color: var(--accent, #1a73e8);
}
.po-btn--primary:hover:not(:disabled) {
  background: var(--accent-dark, #1558b0);
  border-color: var(--accent-dark, #1558b0);
}
.po-btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-color);
}
.po-btn--ghost:hover { background: var(--surface-alt, #f5f5f5); color: var(--text-primary); }
.po-btn--sm { padding: 6px 12px; font-size: 0.85rem; }
.po-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* "How it works" + FAQ */
.po-how, .po-faq { margin-top: 2.5rem; }
.po-how h2, .po-faq h2 {
  font-size: 1.25rem; font-weight: 700; color: var(--text-primary); margin: 0 0 1rem;
}
.po-how__list { padding-left: 1.25rem; color: var(--text-secondary); line-height: 1.7; }

/* FAQ */
.po-faq__item { border-bottom: 1px solid var(--border-color); }
.po-faq__item summary {
  padding: 14px 0; cursor: pointer; font-weight: 500;
  color: var(--text-primary); list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.po-faq__item summary::-webkit-details-marker { display: none; }
.po-faq__item summary::after { content: '+'; font-size: 1.2rem; color: var(--text-secondary); flex-shrink: 0; }
.po-faq__item[open] summary::after { content: '\2212'; }
.po-faq__item p { margin: 0 0 14px; color: var(--text-secondary); font-size: 0.9rem; line-height: 1.6; }

/* Responsive */
@media (max-width: 480px) {
  .po-grid { grid-template-columns: repeat(2, 1fr); }
  .po-card__thumb { width: 100%; height: 130px; }
  .po-toolbar { flex-direction: column; align-items: stretch; }
  .po-toolbar__actions .po-btn { flex: 1; justify-content: center; }
}
