/* Live PDF text editor workspace */
.pdf-text-editor {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.pdf-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid rgba(79, 70, 229, 0.12);
    border-radius: 12px;
    background: linear-gradient(180deg, #fafbff 0%, #fff 100%);
}

.pdf-editor-toolbar-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.pdf-editor-toolbar-secondary {
    gap: 0.5rem;
}

.pdf-editor-tool {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.pdf-editor-tool:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #eef2ff;
}

.pdf-editor-tool.active {
    border-color: var(--primary);
    background: #eef2ff;
    color: #3730a3;
    box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.15);
}

.pdf-editor-tool:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.pdf-editor-tool:disabled:hover {
    border-color: var(--border);
    color: var(--text);
    background: #fff;
}

.pdf-editor-tool span {
    display: none;
}

.pdf-editor-color-label {
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 500;
}

.pdf-editor-color-input {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
}

.pdf-editor-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
}

.pdf-editor-nav,
.pdf-editor-zoom {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.pdf-editor-page-label,
#pdf-editor-zoom-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    min-width: 5.5rem;
    text-align: center;
}

.pdf-editor-filename-label {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e293b;
    flex: 1;
    min-width: 10rem;
}

.pdf-editor-filename-label .input {
    width: 100%;
    max-width: 16rem;
    min-height: 2.75rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.pdf-editor-filename-label .input:hover {
    border-color: #94a3b8;
}

.pdf-editor-filename-label .input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
    outline: none;
}

.pdf-editor-viewport {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 12px;
    background: #e2e8f0;
    padding: 12px;
    max-height: min(72vh, 820px);
}

.pdf-editor-stage {
    position: relative;
    margin: 0 auto;
    box-shadow: 0 8px 32px rgba(15, 23, 42, 0.12);
    background: #fff;
}

.pdf-editor-page-canvas {
    display: block;
}

.pdf-editor-text-layer {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none;
    z-index: 2;
}

.pdf-editor-text-layer.pdf-editor-text-active {
    pointer-events: auto;
}

.pdf-editor-text-layer.pdf-editor-text-active .pdf-text-item {
    cursor: text;
}

.pdf-editor-text-layer.pdf-editor-text-remove .pdf-text-item:not(.pdf-text-item--removed) {
    cursor: crosshair;
}

.pdf-editor-text-layer.pdf-editor-text-remove .pdf-text-item:not(.pdf-text-item--removed):hover {
    color: transparent;
    border-color: rgba(220, 38, 38, 0.45);
    background: rgba(254, 226, 226, 0.55);
}

.pdf-editor-overlay-canvas {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    z-index: 3;
}

.pdf-editor-stage .canvas-container {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    z-index: 3;
}

.pdf-text-item {
    position: absolute;
    display: block;
    overflow: visible;
    white-space: nowrap;
    line-height: normal;
    border: 1px solid transparent;
    border-radius: 2px;
    padding: 0;
    box-sizing: border-box;
    color: transparent;
    user-select: none;
}

.pdf-editor-text-active .pdf-text-item:not(.pdf-text-item--edited):not(.pdf-text-item--removed):hover {
    color: #111827;
    border-color: rgba(79, 70, 229, 0.45);
    background: rgba(238, 242, 255, 0.65);
}

.pdf-text-item--edited {
    /* color and background come from sampled PDF values via inline styles */
}

.pdf-text-item--removed {
    color: transparent !important;
    border-color: transparent;
    box-shadow: none;
    outline: none;
    cursor: default;
    padding: 0;
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

.pdf-editor-text-active .pdf-text-item--removed:hover {
    border-color: transparent;
}

.pdf-editor-text-remove .pdf-text-item--removed:hover {
    border-color: rgba(148, 163, 184, 0.2);
}

.pdf-editor-text-active .pdf-text-item--edited:hover {
    border-color: rgba(79, 70, 229, 0.45);
}

.pdf-text-item:has(.pdf-text-edit-input) {
    overflow: visible;
}

.pdf-text-edit-input {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0 2px;
    border: none;
    outline: 1px solid var(--primary);
    outline-offset: 0;
    border-radius: 3px;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
    background: transparent;
    box-sizing: border-box;
    line-height: 1;
    vertical-align: top;
    -webkit-appearance: none;
    appearance: none;
}

.pdf-editor-hint {
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.45;
}

@media (min-width: 640px) {
    .pdf-editor-tool span {
        display: inline;
    }
}

@media (max-width: 480px) {
    .pdf-editor-toolbar {
        padding: 0.55rem;
    }

    .pdf-editor-tool {
        padding: 0.5rem;
        min-width: var(--touch-min, 2.75rem);
        min-height: var(--touch-min, 2.75rem);
        justify-content: center;
    }

    .pdf-editor-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .pdf-editor-nav,
    .pdf-editor-zoom {
        justify-content: center;
    }

    .pdf-editor-filename-label {
        min-width: 0;
        width: 100%;
    }

    .pdf-editor-filename-label .input {
        max-width: 100%;
    }

    .pdf-editor-viewport {
        max-height: 58vh;
        padding: 8px;
    }
}
