/* Herramientas web (las que corren en el navegador). Sólo se carga en esas páginas. */
.web-tool {
    background: #fff;
    border: 1px solid #d6e6f2;
    border-top: 4px solid var(--familia, var(--primary));
    border-radius: 18px;
    padding: 24px;
    margin-bottom: 26px;
    box-shadow: var(--shadow-md);
    scroll-margin-top: 90px;
}
.web-tool h2 { font-size: 1.35rem; margin-bottom: 4px; }
.wt-private { color: var(--light-text); font-size: .95rem; margin-bottom: 16px; }

.wt-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    clip-path: inset(50%);
}
.wt-input:focus-visible ~ .wt-drop .wt-primary { outline: 3px solid #0d47a1; outline-offset: 2px; }

.wt-drop {
    border: 2px dashed #a9cbe3;
    border-radius: 14px;
    padding: 34px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    transition: background .15s, border-color .15s;
}
.wt-drop[hidden] { display: none; }
.wt-drop.wt-over { background: #eaf5ff; border-color: var(--familia, var(--primary)); }
.wt-drop-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.wt-drop-text { color: var(--light-text); font-size: .9rem; }

.wt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 9px 18px;
    border: 1px solid #bcd3e4;
    border-radius: 999px;
    background: #fff;
    color: #0f4c81;
    font-size: .95rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s, box-shadow .15s;
}
.wt-btn:hover:not(:disabled) { background: #eaf5ff; }
.wt-btn:focus-visible { outline: 3px solid #0d47a1; outline-offset: 2px; }
.wt-btn:disabled { opacity: .5; cursor: default; }
.wt-primary { background: #1976d2; border-color: #1976d2; color: #fff; }
.wt-primary:hover:not(:disabled) { background: #1565c0; }
.wt-link { border-color: transparent; background: none; padding-inline: 8px; font-weight: 500; text-decoration: underline; }
.wt-camera { display: none; }
@media (pointer: coarse) { .wt-camera { display: inline-flex; } }

.wt-work[hidden], .wt-done[hidden], .wt-status:empty { display: none; }
.wt-file { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.wt-file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.wt-hint { color: var(--light-text); font-size: .95rem; margin-bottom: 12px; }
.wt-note { color: var(--light-text); font-size: .88rem; border-left: 3px solid var(--familia, var(--primary)); padding-left: 10px; margin-top: 12px; }
.wt-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.wt-tools { margin: 12px 0; }
.wt-label { font-weight: 600; font-size: .95rem; margin-right: 4px; }
.wt-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.wt-actions .wt-btn { min-width: 240px; }

.wt-status { margin-top: 14px; font-size: .95rem; color: var(--light-text); overflow-wrap: anywhere; }
.wt-status a { color: #0f4c81; font-weight: 600; }
.wt-error { color: #b42318; font-weight: 500; }
.wt-busy::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 8px;
    vertical-align: -2px;
    border: 2px solid #a9cbe3;
    border-top-color: #1976d2;
    border-radius: 50%;
    animation: wt-giro .8s linear infinite;
}
@keyframes wt-giro { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .wt-busy::before { animation: none; } .wt-sheet { transition: none; } }
.wt-is-busy .wt-work { opacity: .6; pointer-events: none; }

/* Rotar */
.wt-pages {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    max-height: 560px;
    overflow-y: auto;
    padding: 4px;
}
.wt-page {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    padding: 8px;
    border: 1px solid #d6e6f2;
    border-radius: 12px;
    background: #f4f9fd;
    cursor: pointer;
}
.wt-page:hover { border-color: var(--familia, var(--primary)); }
.wt-page:focus-visible { outline: 3px solid #0d47a1; outline-offset: 1px; }
.wt-sheet { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; transition: transform .2s; }
.wt-sheet canvas { max-width: 100%; max-height: 100%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.wt-page-n {
    position: absolute;
    left: 6px;
    bottom: 6px;
    min-width: 22px;
    padding: 0 6px;
    border-radius: 6px;
    background: rgba(0, 0, 0, .65);
    color: #fff;
    font-size: .75rem;
    text-align: center;
}

/* Numerar */
.wt-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 300px); gap: 24px; align-items: start; margin-top: 10px; }
.web-tool fieldset { border: 0; margin-bottom: 14px; min-width: 0; }
.web-tool legend, .wt-field { display: block; font-weight: 600; font-size: .95rem; margin-bottom: 6px; padding: 0; }
.wt-radio { display: flex; align-items: center; gap: 8px; min-height: 36px; cursor: pointer; }
.wt-radio input[type="radio"] { width: 18px; height: 18px; flex: none; accent-color: #1976d2; }
.wt-number { width: 110px; min-height: 44px; padding: 8px 12px; border: 1px solid #bcd3e4; border-radius: 10px; font-size: 1rem; }
.wt-inline .wt-radio { display: inline-flex; margin-right: 18px; }
.wt-preview-sheet { position: relative; container-type: inline-size; width: 100%; background: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, .3); }
.wt-preview-sheet canvas { display: block; width: 100%; height: auto; }
.wt-sample { position: absolute; color: #000; background: rgba(255, 235, 59, .85); line-height: 1; white-space: nowrap; font-family: Helvetica, Arial, sans-serif; }

/* Tachar */
.wt-nav { justify-content: space-between; flex-wrap: nowrap; margin-bottom: 10px; }
.wt-nav .wt-btn { padding-inline: 12px; flex: none; }
.wt-page-label { font-weight: 600; font-size: .9rem; text-align: center; min-width: 0; }
.wt-stage { position: relative; container-type: inline-size; width: 100%; max-width: 680px; margin: 0 auto; background: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, .3); overflow: hidden; }
.wt-stage canvas { display: block; width: 100%; height: 100%; }
.wt-marks { position: absolute; inset: 0; cursor: crosshair; touch-action: none; -webkit-user-select: none; user-select: none; }
.wt-mark { position: absolute; background: rgba(20, 20, 20, .75); }
.wt-live { outline: 2px solid #2196f3; }
.wt-count { font-weight: 600; font-size: .95rem; margin-right: auto; }

/* JPG a PDF y Escanear */
.wt-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.wt-image { position: relative; border: 1px solid #d6e6f2; border-radius: 12px; background: #f4f9fd; overflow: hidden; }
.wt-image img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; }
.wt-unreadable img { visibility: hidden; }
.wt-unreadable::after {
    content: attr(data-name);
    position: absolute;
    inset: 34px 8px auto;
    color: #b42318;
    font-size: .8rem;
    text-align: center;
    overflow-wrap: anywhere;
}
.wt-image .wt-page-n { top: 6px; bottom: auto; }
.wt-image-tools { display: flex; justify-content: space-between; border-top: 1px solid #d6e6f2; }
.wt-icon {
    flex: 1;
    min-height: 44px;
    border: 0;
    background: none;
    color: #0f4c81;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
}
.wt-icon:hover:not(:disabled) { background: #eaf5ff; }
.wt-icon:disabled { opacity: .3; cursor: default; }
.wt-icon:focus-visible { outline: 3px solid #0d47a1; outline-offset: -3px; }

/* Campos */
.wt-text, .wt-textarea, .wt-select {
    width: 100%;
    min-height: 44px;
    padding: 9px 12px;
    border: 1px solid #bcd3e4;
    border-radius: 10px;
    background: #fff;
    color: inherit;
    font: inherit;
    font-size: 1rem;
}
.wt-select { width: auto; }
.wt-textarea { resize: vertical; min-height: 64px; }
.wt-text:focus-visible, .wt-textarea:focus-visible, .wt-select:focus-visible, .wt-number:focus-visible { outline: 3px solid #0d47a1; outline-offset: 1px; }
.wt-invalid { border-color: #b42318; background: #fff5f4; }
.wt-number-sm { width: 84px; }
.wt-field-row { display: grid; gap: 4px; max-width: 420px; margin-bottom: 12px; }
.wt-stack .wt-radio { flex-wrap: wrap; margin-bottom: 4px; }
.wt-stack .wt-text { width: min(100%, 260px); }
.wt-inline-field { display: inline-flex; align-items: center; gap: 6px; }
.wt-check { display: flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }
.wt-check input { width: 18px; height: 18px; accent-color: #1976d2; }
.wt-box { padding: 14px; margin-bottom: 14px; border: 1px solid #d6e6f2; border-radius: 12px; background: #f8fbfe; }
.wt-box > * + * { margin-top: 8px; }
.wt-step { font-weight: 700; margin: 6px 0 8px; }
.wt-box .wt-step { margin-top: 0; }

/* Ordenar, eliminar, extraer y dividir */
.wt-thumb { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 1; padding: 8px; }
.wt-image-name { padding: 0 8px; font-size: .8rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wt-image-meta { padding: 0 8px 6px; font-size: .75rem; color: var(--light-text); }
.wt-sortable { cursor: grab; }
.wt-dragging { opacity: .4; }
.wt-off .wt-thumb { opacity: .3; filter: grayscale(1); }
.wt-static { cursor: default; }
.wt-page.wt-del::after, .wt-page.wt-sel::after {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    line-height: 28px;
    text-align: center;
}
.wt-page.wt-del { border-color: #b42318; background: #fdecea; }
.wt-page.wt-del::after { content: '\2715'; background: #b42318; }
.wt-page.wt-del .wt-sheet { opacity: .45; }
.wt-page.wt-sel { border-color: #1976d2; background: #e3f0fd; box-shadow: inset 0 0 0 2px #1976d2; }
.wt-page.wt-sel::after { content: '\2713'; background: #1976d2; }
.wt-badge:empty { display: none; }
.wt-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 1px 8px;
    border-radius: 6px;
    background: #0f4c81;
    color: #fff;
    font-size: .72rem;
    font-weight: 600;
}
.wt-page[data-grupo="0"] { background: #e3f0fd; border-color: #1976d2; }
.wt-page[data-grupo="1"] { background: #fff3e0; border-color: #ef6c00; }
.wt-page[data-grupo="2"] { background: #e8f5e9; border-color: #2e7d32; }
.wt-page[data-grupo="3"] { background: #f3e5f5; border-color: #8e24aa; }
.wt-page[data-grupo="1"] .wt-badge { background: #ef6c00; }
.wt-page[data-grupo="2"] .wt-badge { background: #2e7d32; }
.wt-page[data-grupo="3"] .wt-badge { background: #8e24aa; }

/* Recortar */
.wt-crop { position: absolute; outline: 2px solid #1976d2; box-shadow: 0 0 0 9999px rgba(15, 30, 45, .5); pointer-events: none; }
.wt-crop[hidden] { display: none; }

/* Firmar y agregar texto */
.wt-pad { display: block; width: 100%; height: 170px; border: 2px dashed #a9cbe3; border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; }
.wt-sign-panel[hidden] { display: none; }
.wt-sign-sample { max-height: 48px; max-width: 160px; background: #fff; border: 1px solid #d6e6f2; border-radius: 6px; padding: 2px 6px; }
.wt-sign-sample[hidden] { display: none; }
.wt-stamp, .wt-textbox { position: absolute; touch-action: none; cursor: move; }
.wt-stamp { outline: 1px dashed #1976d2; }
.wt-stamp img { display: block; width: 100%; height: 100%; -webkit-user-drag: none; pointer-events: none; }
.wt-handle { position: absolute; right: -7px; bottom: -7px; width: 16px; height: 16px; border-radius: 50%; background: #1976d2; border: 2px solid #fff; cursor: nwse-resize; }
.wt-x {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #b42318;
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}
.wt-textbox { white-space: pre; line-height: 1.2; font-family: Helvetica, Arial, sans-serif; outline: 1px dashed rgba(25, 118, 210, .5); }
.wt-textbox .wt-x { display: none; }
.wt-textbox.wt-chosen { outline: 2px solid #1976d2; }
.wt-textbox.wt-chosen .wt-x { display: block; }

/* Marca de agua */
.wt-wm-layer { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.wt-wm { position: absolute; font-family: Helvetica, Arial, sans-serif; font-weight: 700; line-height: 1; white-space: nowrap; }

/* Imágenes sin vista previa (HEIC en Chrome, por ejemplo) */
.wt-noprev-label { display: none; }
.wt-noprev img { visibility: hidden; }
.wt-noprev .wt-noprev-label {
    display: flex;
    position: absolute;
    inset: 0 0 auto;
    aspect-ratio: 1;
    align-items: center;
    justify-content: center;
    color: #0f4c81;
    font-size: 1.4rem;
    font-weight: 700;
}

/* OCR */
.wt-extra { margin-top: 10px; }
.wt-ocr-text { margin-top: 10px; font-size: .9rem; }

/* Web a PDF */
.wt-url { align-items: stretch; text-align: left; }
.wt-url-row { display: flex; gap: 10px; width: 100%; }
.wt-url-row .wt-text { flex: 1; min-width: 0; }
.wt-frame { display: block; width: 100%; height: 70vh; min-height: 360px; border: 1px solid #d6e6f2; border-radius: 10px; background: #fff; }

/* Cierre */
.wt-done { margin-top: 18px; padding-top: 18px; border-top: 1px solid #d6e6f2; }
.wt-done-title { font-weight: 700; font-size: 1.1rem; margin-bottom: 8px; overflow-wrap: anywhere; }
.wt-done-note { color: var(--light-text); font-size: .95rem; margin-bottom: 10px; }
.wt-app { margin-top: 18px; padding: 16px; border-radius: 12px; background: #eaf5ff; }
.wt-app-title { font-weight: 700; }
.wt-app .wt-btn { margin-top: 10px; }

/* Bloque de la app, debajo de la herramienta */
.tool-app-block { margin-bottom: 26px; }
.tool-app-block h2 { font-size: 1.1rem; margin-bottom: 10px; }

@media (max-width: 768px) {
    /* Que el botón para elegir el archivo entre en la primera pantalla. */
    .tool-hero .tool-icon-big { display: none; }
    .tool-hero { margin-bottom: 20px; }
    .web-tool { padding: 18px; }
    .wt-drop { padding: 24px 14px; }
    .wt-split { grid-template-columns: minmax(0, 1fr); }
    .wt-preview { max-width: 240px; margin: 0 auto; width: 100%; }
    .wt-actions .wt-btn, .wt-drop-buttons .wt-btn { width: 100%; min-width: 0; }
    .wt-drop-buttons { width: 100%; }
    .wt-pages { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); max-height: 460px; }
    .wt-images { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .wt-url-row { flex-direction: column; }
    .wt-frame { height: 60vh; }
    .wt-pad { height: 150px; }
}
