/* DocuTools — tool page styles (tools.css).
 * Loaded AFTER main.css. Defensive: main.css may not exist yet when a tool
 * page is first opened, so every variable has a fallback and the shared
 * classes (.btn, .dropzone, .file-list, .progress, .result-panel, .alert,
 * .badge, .container) are defined here too. Do NOT rename the shared
 * classes — other agents and pages rely on them.
 */
:root {
  --bg: #ffffff;
  --surface: #f6f7f9;
  --text: #17191c;
  --muted: #5b6470;
  --border: #d9dde3;
  --primary: #1a56db;
  --primary-hover: #1748b5;
  --success: #157347;
  --danger: #b42318;
  --warning: #854d0e;
  --radius: 10px;
}

.container { max-width: 860px; margin: 0 auto; padding: 0 16px; }
.tool-page { padding: 16px 0 64px; color: var(--text, #17191c); background: var(--bg, #fff); }

.breadcrumb { font-size: 0.9rem; color: var(--muted, #5b6470); margin: 8px 0 16px; }
.breadcrumb a { color: var(--primary, #1a56db); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.tool-page h1 { font-size: 1.9rem; line-height: 1.25; margin: 0 0 8px; }
.tool-page h2 { font-size: 1.25rem; margin: 32px 0 10px; }
.tool-page h3 { font-size: 1.05rem; margin: 20px 0 8px; }
.tool-page p, .tool-page li { line-height: 1.6; }
.lede { color: var(--muted, #5b6470); font-size: 1.05rem; margin: 0 0 16px; }

/* Buttons (shared classes) */
.btn {
  display: inline-block; font: inherit; font-weight: 600;
  padding: 10px 18px; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; text-align: center;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary, #1a56db); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover, #1748b5); }
.btn-secondary { background: var(--surface, #f6f7f9); color: var(--text, #17191c); border-color: var(--border, #d9dde3); }
.btn-secondary:hover:not(:disabled) { background: #eceef1; }
.btn-small { padding: 5px 10px; font-size: 0.85rem; border-radius: 6px; }
.btn-block { display: block; width: 100%; margin: 16px 0 8px; }

/* Dropzone + file list (shared classes) */
.dropzone {
  border: 2px dashed var(--border, #d9dde3);
  border-radius: var(--radius, 10px);
  background: var(--surface, #f6f7f9);
  padding: 32px 20px; text-align: center; cursor: pointer;
  margin: 16px 0 12px; outline: none;
}
.dropzone:focus-visible { outline: 3px solid var(--primary, #1a56db); outline-offset: 2px; }
.dropzone.drag-over { border-color: var(--primary, #1a56db); background: #e8eefc; }
.dropzone-hint { font-weight: 600; margin: 0 0 6px; }
.dropzone-sub { color: var(--muted, #5b6470); font-size: 0.9rem; margin: 0 0 12px; }
.file-list { margin: 0 0 12px; }
.file-item {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border: 1px solid var(--border, #d9dde3); border-radius: 8px;
  padding: 8px 12px; margin-bottom: 8px; background: var(--bg, #fff);
}
.file-item-name { flex: 1 1 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-count { color: var(--muted, #5b6470); font-size: 0.9rem; }

/* Progress + result (shared classes) */
.progress {
  height: 10px; border-radius: 999px; overflow: hidden;
  background: #e6e8ec; margin: 12px 0 4px;
}
.progress-bar {
  height: 100%; width: 0%; background: var(--primary, #1a56db);
  transition: width 0.2s ease; border-radius: 999px;
}
.progress-text { font-size: 0.9rem; color: var(--muted, #5b6470); min-height: 1.2em; }
.result-panel {
  border: 1px solid var(--border, #d9dde3); border-radius: var(--radius, 10px);
  background: var(--surface, #f6f7f9); padding: 16px; margin: 16px 0;
}
.result-panel h2 { margin-top: 0; }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.stat-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 0.95rem; }
.stat-table th, .stat-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border, #d9dde3); vertical-align: top; }
.stat-table th { width: 38%; color: var(--muted, #5b6470); font-weight: 600; }

/* Alerts + badges (shared classes) */
.alert { border-radius: 8px; padding: 12px 14px; margin: 12px 0; line-height: 1.55; }
.alert-success { background: #e6f4ea; color: #14532d; border: 1px solid #a3d9b1; }
.alert-error { background: #fdecea; color: #7a1f16; border: 1px solid #f5b5b0; }
.alert-warning { background: #fef6e0; color: #6b3d05; border: 1px solid #f0d48a; }
.alert-info { background: #e8eefc; color: #173a75; border: 1px solid #b3c6f5; }
.badge {
  display: inline-block; font-size: 0.8rem; font-weight: 600;
  background: #e6e8ec; color: var(--text, #17191c);
  border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}
.badge-green { background: #d9f0e0; color: #14532d; }
.badge-amber { background: #fdeec7; color: #6b3d05; }

/* Options form */
.options { border: 1px solid var(--border, #d9dde3); border-radius: var(--radius, 10px); padding: 16px; margin: 16px 0; }
.options legend, .options-label { font-weight: 700; margin-bottom: 8px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field input[type="text"], .field input[type="number"], .field select, .field textarea {
  font: inherit; width: 100%; max-width: 420px; padding: 9px 10px;
  border: 1px solid var(--border, #d9dde3); border-radius: 8px; background: var(--bg, #fff); color: var(--text, #17191c);
}
.field .hint { font-size: 0.88rem; color: var(--muted, #5b6470); margin-top: 4px; }
.radio-row, .check-row { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-row label, .check-row label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }

/* Page thumbnail grid (organize tools) */
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 16px 0; }
.page-card {
  border: 1px solid var(--border, #d9dde3); border-radius: 8px; padding: 8px;
  background: var(--bg, #fff); display: flex; flex-direction: column; gap: 6px; align-items: stretch;
}
.page-card.is-selected { border-color: var(--primary, #1a56db); box-shadow: 0 0 0 2px rgba(26, 86, 219, 0.25); }
.page-card.dragging { opacity: 0.5; }
.page-thumb { width: 100%; height: auto; border: 1px solid #eceef1; border-radius: 4px; background: #fff; }
.page-thumb-error { font-size: 0.85rem; color: var(--muted, #5b6470); }
.page-card-label { font-weight: 600; font-size: 0.9rem; }
.page-card-select { font-size: 0.9rem; display: flex; align-items: center; gap: 6px; }
.page-card .btn-small { align-self: flex-start; }

/* Misc */
.privacy-note { font-size: 0.9rem; color: var(--muted, #5b6470); border-top: 1px solid var(--border, #d9dde3); padding-top: 12px; margin-top: 24px; }
.how-to ol, .faq dl { margin: 8px 0; }
.how-to li { margin-bottom: 6px; }
.faq dt { font-weight: 700; margin-top: 10px; }
.faq dd { margin: 2px 0 0; }
.related-tools { margin-top: 28px; }
.related-tools ul { list-style: none; padding: 0; display: flex; gap: 10px; flex-wrap: wrap; }
.related-tools a { color: var(--primary, #1a56db); }
.tool-header { margin-bottom: 8px; }
.tool-header a { color: var(--text, #17191c); text-decoration: none; font-weight: 800; font-size: 1.2rem; }
.tool-header nav { float: right; font-size: 0.9rem; }
.tool-header nav a { color: var(--muted, #5b6470); font-weight: 500; margin-left: 14px; }
.preview-table-wrap { overflow-x: auto; margin: 12px 0; }
.preview-table-wrap table { border-collapse: collapse; min-width: 480px; }
.preview-table-wrap th, .preview-table-wrap td { border: 1px solid var(--border, #d9dde3); padding: 6px 9px; text-align: left; font-size: 0.9rem; }
.preview-table-wrap th { background: var(--surface, #f6f7f9); }
.thumb-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.thumb-row img { width: 110px; height: 110px; object-fit: contain; border: 1px solid var(--border, #d9dde3); border-radius: 8px; background: #fff; }

@media (max-width: 640px) {
  .tool-page h1 { font-size: 1.55rem; }
  .dropzone { padding: 24px 14px; }
  .tool-header nav { float: none; display: block; margin-top: 4px; }
  .tool-header nav a { margin-left: 0; margin-right: 12px; }
}
