/* Add Pages to PDF - #3d85c6 */
:root {
  --aptp-brand: #3d85c6;
  --aptp-brand-dark: #2c6396;
  --aptp-brand-light: #eaf4fb;
  --aptp-brand-border: #b6d5f2;
  --aptp-bg: #f4f8fc;
  --aptp-surface: rgba(255, 255, 255, 0.92);
  --aptp-solid: #ffffff;
  --aptp-text: #1a1a1a;
  --aptp-muted: #64748b;
  --aptp-accent: #15803d;
  --aptp-accent-bg: #dcfce7;
  --aptp-success: #15803d;
  --aptp-success-bg: #dcfce7;
  --aptp-shadow: 0 14px 40px rgba(61, 133, 198, 0.15);
  --aptp-radius: 18px;
  --aptp-font: 'DM Sans', system-ui, sans-serif;
}

#tool-main {
  font-family: var(--aptp-font);
  color: var(--aptp-text);
  background: var(--aptp-bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(61, 133, 198, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(91, 163, 224, 0.1), transparent);
  padding-bottom: 32px;
}

.aptp-wrap { max-width: 900px; margin: 0 auto; padding: 16px; }

.aptp-hero { text-align: center; margin-bottom: 18px; }
.aptp-hero h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  color: var(--aptp-brand);
  margin: 0 0 8px;
}
.aptp-hero p { color: var(--aptp-muted); font-size: 0.92rem; margin: 0 auto 10px; max-width: 520px; }
.aptp-trust {
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--aptp-brand-dark);
  background: var(--aptp-brand-light);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--aptp-brand-border);
}

.aptp-glass {
  background: var(--aptp-surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--aptp-brand-border);
  border-radius: var(--aptp-radius);
  box-shadow: var(--aptp-shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.aptp-options {
  padding: 14px 16px;
  margin-bottom: 12px;
}

.aptp-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--aptp-brand-dark);
  margin-bottom: 4px;
}

.aptp-field .form-select {
  border-color: var(--aptp-brand-border);
  font-size: 0.85rem;
}

.aptp-drop {
  text-align: center;
  padding: 28px 20px;
  cursor: pointer;
  border: 2px dashed var(--aptp-brand);
  transition: background 0.15s, border-color 0.15s;
}
.aptp-drop:hover, .aptp-drop:focus-visible, .aptp-drop.is-dragover {
  background: var(--aptp-brand-light);
  border-color: var(--aptp-brand-dark);
  outline: none;
}
.aptp-drop.has-file {
  padding: 16px;
  border-style: solid;
  cursor: default;
  text-align: left;
}
.aptp-drop.has-file .aptp-drop-icon,
.aptp-drop.has-file > h2,
.aptp-drop.has-file > p {
  display: none;
}
.aptp-workspace[hidden], .aptp-add-section[hidden], .aptp-add-panel[hidden] {
  display: none !important;
}
.aptp-drop-icon { font-size: 2.2rem; margin-bottom: 8px; }
.aptp-drop h2 { font-size: 1rem; font-weight: 700; margin: 0 0 4px; color: var(--aptp-brand-dark); }
.aptp-drop p { font-size: 0.85rem; color: var(--aptp-muted); margin: 0; }

.aptp-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.aptp-file-meta { font-size: 0.85rem; color: var(--aptp-muted); margin: 0; }
.aptp-file-meta strong { color: var(--aptp-brand-dark); }
.aptp-meta-sel { color: var(--aptp-accent); font-weight: 600; }
.aptp-meta-added { color: #7c3aed; font-weight: 600; }
.aptp-section-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--aptp-brand-dark);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0 0 10px;
}
.aptp-hint {
  font-weight: 600;
  text-transform: none;
  color: var(--aptp-muted);
  letter-spacing: 0;
}
.aptp-toolbar-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.aptp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.82rem;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.aptp-btn--primary {
  background: var(--aptp-brand);
  color: #fff;
  box-shadow: 0 4px 14px rgba(61, 133, 198, 0.28);
}
.aptp-btn--primary:hover:not(:disabled) { background: var(--aptp-brand-dark); }
.aptp-btn--ghost {
  background: var(--aptp-solid);
  border: 1px solid var(--aptp-brand-border);
  color: var(--aptp-brand-dark);
}
.aptp-btn--ghost:hover:not(:disabled) { background: var(--aptp-brand-light); }
.aptp-btn--lg { padding: 13px 22px; font-size: 0.95rem; width: 100%; }
.aptp-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.aptp-page-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  min-height: 80px;
}
.aptp-loading { width: 100%; text-align: center; color: var(--aptp-muted); font-size: 0.88rem; padding: 20px; }

.aptp-page-card {
  width: 132px;
  position: relative;
  border-radius: 12px;
  border: 1.5px solid var(--aptp-brand-border);
  background: var(--aptp-solid);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.aptp-page-card:hover {
  border-color: var(--aptp-brand);
  box-shadow: 0 6px 16px rgba(61, 133, 198, 0.15);
}
.aptp-page-card.is-selected {
  border-color: #86efac;
  box-shadow: 0 0 0 2px rgba(22, 101, 52, 0.15);
}
.aptp-page-card.is-added {
  border-color: #c4b5fd;
}
.aptp-page-card.is-draggable {
  cursor: grab;
}
.aptp-page-card.is-dragging {
  opacity: 0.55;
  cursor: grabbing;
}
.aptp-page-card.is-drop-target {
  border-color: var(--aptp-brand);
  box-shadow: 0 0 0 3px var(--aptp-brand-light);
}
.aptp-added-tag {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #7c3aed;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 999px;
}
.aptp-page-card.is-added .aptp-page-actions {
  display: flex;
  border-top: 1px solid #ddd6fe;
}
.aptp-page-card.is-added .aptp-page-actions button {
  flex: 1;
  width: auto;
  border: none;
  border-radius: 0;
  padding: 6px 4px;
  font-size: 0.72rem;
}
.aptp-page-card.is-draggable .aptp-page-actions {
  display: flex;
  padding: 0;
  border-top: 1px solid var(--aptp-brand-border);
}
.aptp-page-card.is-draggable .aptp-page-actions button {
  flex: 1;
  width: auto;
  border: none;
  border-radius: 0;
  padding: 6px 4px;
  font-size: 0.72rem;
}
.aptp-page-card.is-draggable .aptp-page-actions button.aptp-remove {
  color: #dc2626;
  border-left: 1px solid var(--aptp-brand-border);
}

.aptp-page-thumb {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  padding: 8px;
  background: #f1f5f9;
}
.aptp-page-thumb img {
  max-width: 100%;
  max-height: 140px;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.aptp-sel-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--aptp-accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.aptp-page-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--aptp-brand);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
}
.aptp-page-card.is-selected .aptp-page-badge {
  background: var(--aptp-accent);
}

.aptp-page-actions {
  padding: 6px;
  border-top: 1px solid var(--aptp-brand-border);
}
.aptp-page-actions button {
  width: 100%;
  padding: 6px 4px;
  border-radius: 8px;
  border: 1px solid var(--aptp-brand-border);
  background: var(--aptp-solid);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  color: var(--aptp-brand-dark);
}
.aptp-page-card.is-selected .aptp-page-actions button {
  color: var(--aptp-accent);
  border-color: #86efac;
  background: var(--aptp-accent-bg);
}
.aptp-page-actions button:hover { background: var(--aptp-brand-light); }

.aptp-progress { margin-top: 12px; }
.aptp-progress[hidden], .aptp-workspace[hidden], .aptp-result[hidden] { display: none !important; }
.aptp-progress-bar {
  height: 6px;
  background: var(--aptp-brand-light);
  border-radius: 999px;
  overflow: hidden;
}
.aptp-progress-fill {
  height: 100%;
  background: var(--aptp-brand);
  width: 0%;
  transition: width 0.2s;
}
.aptp-progress-label { font-size: 0.8rem; font-weight: 600; color: var(--aptp-brand-dark); margin: 6px 0 0; }

.aptp-result { text-align: center; scroll-margin-top: calc(var(--header-h, 72px) + 16px); }
.aptp-result-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--aptp-success);
  background: var(--aptp-success-bg);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}
.aptp-filename { margin: 12px 0; text-align: left; max-width: 320px; margin-left: auto; margin-right: auto; }
.aptp-filename label { font-size: 0.75rem; font-weight: 700; color: var(--aptp-brand-dark); display: block; margin-bottom: 4px; }
.aptp-filename input {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--aptp-brand-border);
  font-size: 0.88rem;
  font-family: inherit;
}

.aptp-related {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.aptp-related a {
  display: block;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--aptp-brand-border);
  background: var(--aptp-surface);
  text-decoration: none;
  color: inherit;
}
.aptp-related a:hover { background: var(--aptp-brand-light); }
.aptp-related strong { display: block; font-size: 0.82rem; color: var(--aptp-brand-dark); }
.aptp-related span { font-size: 0.72rem; color: var(--aptp-muted); }

.aptp-toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
}
.aptp-toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.aptp-toast--success { background: #166534; color: #fff; }
.aptp-toast--warning { background: #b45309; color: #fff; }
.aptp-toast--error { background: #b91c1c; color: #fff; }

.aptp-add-section { padding: 18px 20px; }
.aptp-add-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--aptp-brand-dark);
  margin: 0 0 6px;
}
.aptp-add-desc {
  font-size: 0.85rem;
  color: var(--aptp-muted);
  margin: 0 0 12px;
}
.aptp-add-panel {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--aptp-brand-border);
}
.aptp-add-source-meta {
  font-size: 0.85rem;
  color: var(--aptp-brand-dark);
  font-weight: 600;
  margin: 0 0 10px;
}
.aptp-add-toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.aptp-insert-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-top: 14px;
}
.aptp-insert-row .aptp-field {
  flex: 1;
  min-width: 200px;
}
.aptp-insert-row .aptp-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--aptp-brand-dark);
  margin-bottom: 4px;
}
.aptp-insert-row .form-select {
  border-color: var(--aptp-brand-border);
  font-size: 0.85rem;
}
