#firma-pdf-app {
    /* Panel general (tarjetas normales) -> transparente */
    --fp-bg: transparent;
    --fp-panel: transparent;
    --fp-panel-border: rgba(255, 255, 255, 0.18);

    /* Fondos solidos propios (independientes del tema de WordPress) */
    --fp-modal-bg: #1c1c1f;
    --fp-modal-border: rgba(255, 255, 255, 0.12);

    --fp-btn-primary-bg: #ffffff;
    --fp-btn-primary-text: #0b0b0c;

    --fp-btn-ghost-bg: #2a2a2e;
    --fp-btn-ghost-text: #f2f2f2;
    --fp-btn-ghost-border: rgba(255, 255, 255, 0.18);

    --fp-text: #f2f2f2;
    --fp-text-dim: #a3a3a3;
    --fp-danger: #e5484d;

    max-width: 820px;
    margin: 0 auto;
    padding: 24px;
    background: var(--fp-bg);
    border-radius: 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--fp-text);
}

#firma-pdf-app * { box-sizing: border-box; }

#firma-pdf-app .fp-mobile-text { display: none; }

/* ---------- Header ---------- */
#firma-pdf-app .fp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}
#firma-pdf-app .fp-title-box {
    background: var(--fp-panel);
    border: 1px solid var(--fp-panel-border);
    border-radius: 10px;
    padding: 12px 18px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

/* ---------- Cards (siguen transparentes) ---------- */
#firma-pdf-app .fp-card {
    background: var(--fp-panel);
    border: 1px solid var(--fp-panel-border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
    backdrop-filter: blur(6px);
}
#firma-pdf-app .fp-card h3 {
    margin: 0 0 12px 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--fp-text);
    line-height: 1.3;
}
#firma-pdf-app .fp-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    border-radius: 50%;
    background: var(--fp-btn-primary-bg);
    color: var(--fp-btn-primary-text);
    font-size: 12px;
    font-weight: 800;
}
#firma-pdf-app .fp-hint {
    color: var(--fp-text-dim);
    font-size: 13px;
    margin: -4px 0 14px 0;
    line-height: 1.45;
}

/* ---------- Selector de documentos existentes ---------- */
#firma-pdf-app .fp-select-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}
#firma-pdf-app select#fp-select-pdf {
    flex: 1;
    min-width: 220px;
    background: var(--fp-btn-ghost-bg);
    color: var(--fp-text);
    border: 1px solid var(--fp-btn-ghost-border);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
}
#firma-pdf-app select#fp-select-pdf:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.4);
}

/* ---------- Dropzone ---------- */
#firma-pdf-app .fp-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 34px 18px;
    border: 1.5px dashed var(--fp-panel-border);
    border-radius: 10px;
    cursor: pointer;
    color: var(--fp-text-dim);
    font-size: 14px;
    text-align: center;
    transition: border-color .15s ease, color .15s ease, background .15s ease;
}
#firma-pdf-app .fp-dropzone:hover {
    border-color: rgba(255,255,255,0.35);
    color: var(--fp-text);
    background: rgba(255,255,255,0.02);
}
#firma-pdf-app .fp-dropzone-icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--fp-panel-border);
    font-size: 20px;
    line-height: 1;
}

/* ---------- Navegacion de paginas del PDF ---------- */
#firma-pdf-app .fp-page-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    padding: 8px 10px;
    background: var(--fp-btn-ghost-bg);
    border: 1px solid var(--fp-btn-ghost-border);
    border-radius: 8px;
}
#firma-pdf-app .fp-page-nav button {
    flex: 0 0 auto;
    width: auto;
    padding: 8px 14px;
}
#firma-pdf-app #fp-page-info {
    font-size: 12.5px;
    color: var(--fp-text-dim);
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    text-align: center;
    flex: 1;
}

/* ---------- PDF canvas ---------- */
#fp-canvas-wrapper {
    position: relative;
    display: block;
    width: 100%;
    height: 600px;
    max-width: 100%;
    border-radius: 8px;
    overflow: auto;
    border: 1px solid var(--fp-panel-border);
    background: rgba(0, 0, 0, 0.25);
}
#fp-pdf-canvas {
    display: block;
    width: 100%;
    height: auto;
    cursor: crosshair;
}
#firma-pdf-app.fp-zone-confirmed #fp-pdf-canvas {
    cursor: default;
}

/* ---------- Marcador de la zona de firma (rojo, intencional) ---------- */
#fp-marker {
    position: absolute;
    border: 2px dashed #ff0000;
    background: rgba(255, 0, 0, 0.25);
    border-radius: 4px;
    pointer-events: none;
}

/* ---------- Buttons ---------- */
#firma-pdf-app button {
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-radius: 8px;
    padding: 12px 18px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: opacity .15s ease, background .15s ease, border-color .15s ease, color .15s ease;
}

/* Boton principal: fondo solido blanco */
#firma-pdf-app .fp-btn-primary {
    background: var(--fp-btn-primary-bg) !important;
    color: var(--fp-btn-primary-text) !important;
    border-color: var(--fp-btn-primary-bg);
    width: 100%;
}
#firma-pdf-app .fp-btn-primary:hover { opacity: 0.85; }
#firma-pdf-app .fp-btn-primary:disabled {
    background: rgba(255,255,255,0.15) !important;
    color: rgba(255,255,255,0.4) !important;
    cursor: not-allowed;
    opacity: 1;
}

/* Boton secundario ("ghost"): fondo solido oscuro propio */
#firma-pdf-app .fp-btn-ghost {
    background: var(--fp-btn-ghost-bg) !important;
    color: var(--fp-btn-ghost-text) !important;
    border: 1px solid var(--fp-btn-ghost-border);
}
#firma-pdf-app .fp-btn-ghost:hover {
    border-color: var(--fp-danger);
    color: var(--fp-danger) !important;
    background: rgba(229, 72, 77, 0.12) !important;
}
#firma-pdf-app .fp-btn-ghost:disabled {
    color: rgba(255,255,255,0.4) !important;
    cursor: not-allowed;
    opacity: 1;
}
#firma-pdf-app .fp-btn-ghost:disabled:hover {
    border-color: var(--fp-btn-ghost-border);
    background: var(--fp-btn-ghost-bg) !important;
}

#firma-pdf-app .fp-mark-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 14px;
}
#firma-pdf-app .fp-mark-actions button {
    flex: 1;
}
#fp-btn-open-sign { margin-top: 0; }
#fp-btn-read-pdf { margin-top: 0; }

/* ---------- Modal firma ---------- */
.fp-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
}

/* El modal no hereda .fp-card transparente: tiene su propio fondo solido */
.fp-modal-content {
    max-width: 460px;
    width: 100%;
    text-align: center;
    margin-bottom: 0;
    background: var(--fp-modal-bg) !important;
    border: 1px solid var(--fp-modal-border) !important;
    border-radius: 12px;
    padding: 22px;
    backdrop-filter: none;
}
.fp-modal-content h3 {
    margin: 0 0 14px 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--fp-text);
}

#fp-signature-pad {
    width: 100%;
    max-width: 400px;
    height: 200px;
    border-radius: 8px;
    border: 1px solid var(--fp-panel-border);
    background: #ffffff;
    touch-action: none;
    margin-top: 8px;
}
.fp-modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}
.fp-modal-actions button { flex: 1; width: auto; }

/* ---------- Modal lectura PDF ---------- */
.fp-read-modal {
    align-items: stretch;
}

.fp-read-modal-content {
    width: min(980px, 100%);
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    background: var(--fp-modal-bg) !important;
    border: 1px solid var(--fp-modal-border) !important;
    border-radius: 12px;
    padding: 16px;
    color: var(--fp-text);
}

.fp-read-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--fp-modal-border);
}

.fp-read-modal-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.fp-read-modal-header button {
    width: auto;
    flex: 0 0 auto;
}

.fp-read-pages {
    flex: 1;
    overflow: auto;
    padding: 14px 6px 2px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.fp-reader-page {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.fp-reader-page-label,
.fp-reader-loading {
    color: var(--fp-text-dim);
    font-size: 12px;
    line-height: 1.4;
}

.fp-reader-page canvas {
    display: block;
    max-width: 100%;
    height: auto;
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid var(--fp-modal-border);
}

/* ---------- Status ---------- */
#fp-status {
    font-size: 12.5px;
    color: var(--fp-text-dim);
    margin-top: 4px;
    min-height: 16px;
    line-height: 1.35;
}

#fp-step-download a { text-decoration: none; }

#firma-pdf-app .fp-download-actions {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

#firma-pdf-app .fp-download-actions a,
#firma-pdf-app .fp-download-actions button {
    flex: 1;
}

@media (max-width: 640px) {
    #firma-pdf-app {
        max-width: 100%;
        padding: 10px;
        border-radius: 0;
    }

    #firma-pdf-app .fp-desktop-text { display: none; }
    #firma-pdf-app .fp-mobile-text { display: inline; }

    #firma-pdf-app .fp-header {
        gap: 8px;
        margin-bottom: 12px;
    }

    #firma-pdf-app .fp-title-box {
        flex: 1;
        padding: 10px 12px;
        font-size: 12.5px;
        letter-spacing: 0.7px;
        border-radius: 8px;
    }

    #firma-pdf-app .fp-card {
        padding: 14px;
        margin-bottom: 12px;
        border-radius: 10px;
    }

    #firma-pdf-app .fp-card h3 {
        font-size: 13px;
        letter-spacing: 0.35px;
        gap: 8px;
        margin-bottom: 10px;
    }

    #firma-pdf-app .fp-step-num {
        width: 21px;
        height: 21px;
        flex-basis: 21px;
        font-size: 11px;
    }

    #firma-pdf-app .fp-hint {
        font-size: 12.5px;
        margin: -2px 0 12px 0;
    }

    #firma-pdf-app .fp-select-row {
        display: block;
    }

    #firma-pdf-app select#fp-select-pdf {
        width: 100%;
        min-width: 0;
        padding: 11px 12px;
        font-size: 13px;
    }

    #firma-pdf-app .fp-dropzone {
        min-height: 92px;
        padding: 20px 12px;
        gap: 8px;
        font-size: 13px;
    }

    #firma-pdf-app .fp-dropzone-icon {
        width: 30px;
        height: 30px;
        font-size: 18px;
    }

    #firma-pdf-app .fp-page-nav {
        padding: 6px 8px;
    }

    #firma-pdf-app .fp-page-nav button {
        padding: 8px 10px;
        font-size: 11px;
    }

    #fp-canvas-wrapper {
        height: 420px;
    }

    #firma-pdf-app button {
        min-height: 42px;
        padding: 10px 12px;
        font-size: 12px;
        letter-spacing: 0.25px;
    }

    #firma-pdf-app .fp-mark-actions {
        flex-direction: column;
        gap: 8px;
        margin-top: 12px;
    }

    #firma-pdf-app .fp-mark-actions button {
        width: 100%;
    }

    #firma-pdf-app .fp-download-actions {
        flex-direction: column;
        gap: 8px;
    }

    #firma-pdf-app .fp-download-actions a,
    #firma-pdf-app .fp-download-actions button {
        width: 100%;
    }

    .fp-modal {
        align-items: flex-end;
        padding: 10px;
    }

    .fp-modal-content {
        padding: 16px;
        border-radius: 10px;
    }

    .fp-read-modal {
        align-items: stretch;
        padding: 8px;
    }

    .fp-read-modal-content {
        max-height: calc(100vh - 16px);
        padding: 12px;
        border-radius: 10px;
    }

    .fp-read-modal-header {
        gap: 8px;
        padding-bottom: 10px;
    }

    .fp-read-modal-header h3 {
        font-size: 13px;
    }

    .fp-read-pages {
        padding: 10px 0 0;
        gap: 12px;
    }

    .fp-modal-content h3 {
        font-size: 13px;
        margin-bottom: 10px;
    }

    #fp-signature-pad {
        height: 160px;
        max-width: none;
    }

    .fp-modal-actions {
        flex-direction: column;
        gap: 8px;
        margin-top: 12px;
    }

    .fp-modal-actions button {
        width: 100%;
    }

    #fp-status {
        font-size: 12px;
    }
}