/**
 * PDF Editor styles.
 *
 * Uses the site's existing CSS variables (--bg-primary, --bg-secondary,
 * --bg-tertiary, --border-color, --text-primary, --text-secondary,
 * --text-muted, --accent-primary, --accent-secondary, --shadow,
 * --shadow-lg, --transition-fast) defined in common.css.
 */

/* ===========================================================
   Page shell
   =========================================================== */
.pdfne-shell [hidden] { display: none !important; }

.pdfne-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: calc(100vh - 64px);
    background: var(--bg-primary);
}

.pdfne-upload-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
}

.pdfne-drop {
    width: 100%;
    max-width: 640px;
    border: 2px dashed var(--border-color);
    border-radius: 14px;
    padding: 3.5rem 2rem;
    text-align: center;
    cursor: pointer;
    background: var(--bg-secondary);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}
.pdfne-drop:hover,
.pdfne-drop.dragover {
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
}
.pdfne-drop svg {
    width: 56px;
    height: 56px;
    color: var(--accent-primary);
    margin-bottom: 1rem;
}
.pdfne-drop h2 {
    font-size: 1.4rem;
    margin: 0 0 .25rem;
    color: var(--text-primary);
}
.pdfne-drop p {
    color: var(--text-muted);
    margin: 0;
    font-size: .95rem;
}
.pdfne-drop small {
    display: block;
    margin-top: .75rem;
    color: var(--text-muted);
    font-size: .8rem;
}

/* ===========================================================
   Workspace layout
   =========================================================== */
.pdfne-workspace {
    display: grid;
    grid-template-columns: 220px 1fr;
    grid-template-rows: auto 1fr;
    height: calc(100vh - 64px);
    overflow: hidden;
}

.pdfne-toolbar {
    grid-column: 1 / -1;
}

.pdfne-thumbs {
    grid-row: 2;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: .5rem;
    transition: width var(--transition-fast);
}
.pdfne-thumbs.collapsed {
    width: 0;
    padding: 0;
    overflow: hidden;
    border-right: 0;
}
.pdfne-thumbs.collapsed + .pdfne-canvas-area {
    grid-column: 1 / -1;
}

.pdfne-thumbs-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.pdfne-thumb {
    position: relative;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: .35rem;
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.pdfne-thumb:hover { border-color: var(--accent-primary); }
.pdfne-thumb canvas {
    width: 100%;
    height: auto;
    display: block;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
}
.pdfne-thumb-lbl {
    position: absolute;
    bottom: 4px;
    left: 6px;
    background: rgba(0, 0, 0, .55);
    color: white;
    font-size: 11px;
    padding: 1px 5px;
    border-radius: 3px;
}
.pdfne-thumb-acts {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}
.pdfne-thumb:hover .pdfne-thumb-acts { opacity: 1; }
.pdfne-thumb-acts button {
    background: rgba(0, 0, 0, .65);
    color: white;
    border: 0;
    border-radius: 3px;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.pdfne-thumb-acts button:hover { background: var(--accent-primary); }
.pdfne-thumb.drop-target {
    outline: 2px dashed var(--accent-primary);
    outline-offset: 2px;
}

/* ===========================================================
   Canvas area
   =========================================================== */
.pdfne-canvas-area {
    grid-row: 2;
    overflow: auto;
    background: var(--bg-primary);
    padding: 1.5rem;
    position: relative;
}

.pdfne-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.pdfne-page {
    position: relative;
    background: white;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
    border-radius: 2px;
}
.pdfne-page-canvas {
    display: block;
}
.pdfne-ann-layer {
    position: absolute;
    inset: 0;
    pointer-events: auto;
}
.pdfne-page-label {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 1px 8px;
    border-radius: 10px;
}

/* ===========================================================
   Annotation elements
   =========================================================== */
.ann-el {
    box-sizing: border-box;
    user-select: none;
}
.ann-el.selected {
    outline: 2px solid var(--accent-primary, #00cc6a);
    outline-offset: 2px;
}
.ann-text .ann-text-inner {
    outline: 1px dashed transparent;
}
.ann-text:hover .ann-text-inner {
    outline-color: rgba(0, 0, 0, .2);
}
.ann-text-inner[contenteditable="true"] {
    outline: 2px solid var(--accent-primary);
    background: rgba(255, 255, 255, .9);
    cursor: text;
}
.ann-stamp-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border: 3px solid currentColor;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(255, 255, 255, .7);
}
.ann-signature-inner {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    height: 100%;
    line-height: 1;
}

/* Resize handles */
.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--accent-primary);
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
    z-index: 5;
}
.handle-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.handle-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; }

/* Search highlight */
.pdfne-search-hit {
    position: absolute;
    background: rgba(255, 235, 59, .55);
    border: 1px solid #fbc02d;
    pointer-events: none;
    z-index: 4;
}

/* ===========================================================
   Find bar
   =========================================================== */
.pdfne-find-bar {
    position: fixed;
    top: 110px;
    right: 24px;
    z-index: 10000;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: .35rem .5rem;
    display: flex;
    align-items: center;
    gap: .35rem;
    box-shadow: var(--shadow-lg);
}
.pdfne-find-bar input {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    min-width: 200px;
}
.pdfne-find-bar button {
    background: transparent;
    border: 0;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.pdfne-find-bar button:hover {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
}
.pdfne-find-status {
    font-size: 12px;
    color: var(--text-muted);
    margin-right: .25rem;
    min-width: 60px;
    text-align: right;
}

/* ===========================================================
   Loading overlay
   =========================================================== */
.pdfne-loading {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
}
.pdfne-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, .35);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: pdfne-spin 0.8s linear infinite;
}
@keyframes pdfne-spin { to { transform: rotate(360deg); } }

/* ===========================================================
   Mobile
   =========================================================== */
@media (max-width: 768px) {
    .pdfne-workspace {
        grid-template-columns: 1fr;
    }
    .pdfne-thumbs {
        display: none;
    }
    .pdfne-thumbs:not(.collapsed) {
        display: block;
        position: fixed;
        left: 0; top: 64px; bottom: 0;
        width: 70vw;
        max-width: 280px;
        z-index: 100;
        box-shadow: 0 0 30px rgba(0, 0, 0, .25);
    }
    .pdfne-find-bar {
        right: 8px;
        left: 8px;
    }
    .pdfne-find-bar input { min-width: 0; flex: 1; }
}

/* ===========================================================
   Signature modal
   =========================================================== */
.pdfne-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 25000;
    padding: 1rem;
}
.pdfne-modal {
    background: var(--bg-secondary);
    border-radius: 12px;
    max-width: 640px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.pdfne-modal-head {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.pdfne-modal-head h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}
.pdfne-modal-close {
    background: transparent;
    border: 0;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}
.pdfne-modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}
.pdfne-tab {
    flex: 1;
    background: transparent;
    border: 0;
    padding: .75rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
}
.pdfne-tab.active {
    color: var(--accent-primary);
    border-bottom: 2px solid var(--accent-primary);
}
.pdfne-modal-body {
    padding: 1.25rem;
}
.pdfne-sig-canvas {
    width: 100%;
    height: 200px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: crosshair;
    touch-action: none;
}
.pdfne-sig-controls {
    margin-top: .75rem;
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    font-size: .9rem;
}
.pdfne-sig-controls label {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}
.pdfne-sig-text {
    width: 100%;
    padding: .6rem .75rem;
    font-size: 1.1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: .75rem;
}
.pdfne-sig-font {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 1rem;
}
.pdfne-sig-preview {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    min-height: 80px;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
}
.pdfne-modal-foot {
    padding: .75rem 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
}
.pdfne-btn-primary,
.pdfne-btn-secondary {
    padding: .5rem 1rem;
    border-radius: 6px;
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    border: 0;
    transition: opacity var(--transition-fast), background var(--transition-fast);
}
.pdfne-btn-primary {
    background: var(--accent-primary);
    color: white;
}
.pdfne-btn-primary:hover { opacity: .9; }
.pdfne-btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.pdfne-btn-secondary:hover { background: var(--border-color); }
