/* PDF Editor specific styles */
.editor-workspace {
    position: relative; width: 100%; min-height: calc(100vh - var(--public-header-offset, 122px)); height: auto;
    background: #f1f5f9; overflow-x: hidden; font-family: 'Inter', system-ui, sans-serif;
}
.editor-page-head {
    border-bottom: 1px solid #e2e8f0;
}
.editor-hero-row {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap;
}
.editor-hero-main {
    flex: 1; min-width: 250px;
}
.editor-hero-badges {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.editor-hero-share {
    margin-top: 10px;
}
.editor-workspace:has(#editor-state[style*="flex"]) {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--public-header-offset, 122px));
    overflow: hidden;
}
.editor-workspace:has(#editor-state[style*="flex"]) .editor-page-head {
    padding: 6px 0;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.editor-workspace:has(#editor-state[style*="flex"]) .editor-page-head-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.editor-workspace:has(#editor-state[style*="flex"]) .editor-page-head .tool-crumb {
    margin-bottom: 0;
}
.editor-workspace:has(#editor-state[style*="flex"]) .editor-page-head h1 {
    font-size: 13px;
    margin: 0;
    line-height: 1.2;
    color: #0f172a;
}
.editor-workspace:has(#editor-state[style*="flex"]) .editor-hero-badges,
.editor-workspace:has(#editor-state[style*="flex"]) .editor-hero-summary,
.editor-workspace:has(#editor-state[style*="flex"]) .editor-hero-share {
    display: none !important;
}

/* Upload State */
.upload-state { width: 100%; min-height: 520px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 20px; padding: 36px 16px 48px; }

.editor-ad-wrapper { width: 100%; max-width: 728px; display: flex; justify-content: center; flex-shrink: 0; min-height: 90px; align-items: center; }
.editor-ad-wrapper:empty { display: none !important; min-height: 0 !important; }
.editor-ad-wrapper .ad-render { margin: 0; width: 100%; }
.upload-box { background: #fff; border: 2px dashed #cbd5e1; border-radius: 20px; padding: 52px 36px; text-align: center; max-width: 600px; width: 100%; box-shadow: 0 10px 30px rgba(7,24,49,0.05); transition: all 0.3s ease; }
.upload-box.dragover { border-color: #dc2626; background: #fef2f2; }
.upload-icon { font-size: 60px; color: #dc2626; margin-bottom: 20px; }
.upload-box h2 { font-size: 24px; color: #0f172a; margin: 0 0 8px; font-weight: 800; }
.upload-box p { color: #64748b; margin: 0 0 24px; }
.upload-box .btn { padding: 12px 30px; font-size: 16px; font-weight: 700; border-radius: 10px; }
.upload-privacy { margin: 26px auto 0 auto; display: flex; max-width: 100%; align-items: center; justify-content: center; gap: 8px; color: #059669; font-size: 13px; font-weight: 500; }
.upload-privacy i { margin: 0; padding: 0; flex-shrink: 0; position: static; transform: none; display: inline-block; }
.upload-privacy span { margin: 0; padding: 0; flex-shrink: 1; text-align: left; line-height: 1.45; }

/* Editor State */
.editor-state { display: flex; flex-direction: column; flex: 1; min-height: 0; height: 100%; }
.editor-header { height: 56px; background: #fff; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.02); z-index: 10; }
.toolbar-group { display: flex; align-items: center; gap: 4px; }
.toolbar-sep { width: 1px; height: 24px; background: #e2e8f0; margin: 0 8px; }
.tool-btn { width: 34px; height: 34px; border: none; background: transparent; border-radius: 6px; color: #475569; font-size: 15px; cursor: pointer; display: grid; place-items: center; transition: all 0.2s; }
.tool-btn:hover { background: #f1f5f9; color: #0f172a; }
.tool-btn.active { background: #fef2f2; color: #dc2626; }
.tool-btn.text-danger:hover { background: #fef2f2; color: #dc2626; }
.zoom-text { font-size: 13px; font-weight: 600; color: #475569; min-width: 45px; text-align: center; }
.btn-save { padding: 8px 16px; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; border-radius: 8px; }

.editor-body { display: flex; flex: 1; overflow: hidden; position: relative; }
.mobile-drawer-btn, .drawer-close-btn, .editor-drawer-backdrop { display: none !important; }
.drawer-close-btn { border: none; background: transparent; color: #64748b; width: 40px; cursor: pointer; font-size: 15px; align-items: center; justify-content: center; }
.drawer-close-btn:hover { color: #dc2626; background: #fef2f2; }

/* Sidebar */
.editor-sidebar { width: 200px; background: #f8fafc; border-right: 1px solid #e2e8f0; overflow-y: auto; padding: 16px 0; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.thumb-wrap { width: 140px; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.08); border: 2px solid transparent; cursor: pointer; transition: all 0.2s; position: relative; }
.thumb-wrap.active { border-color: #dc2626; }
.thumb-wrap canvas { width: 100%; height: auto; display: block; }
.thumb-page-num { position: absolute; bottom: -20px; left: 0; right: 0; text-align: center; font-size: 12px; color: #64748b; font-weight: 600; }

/* Main */
.editor-main { flex: 1; background: #cbd5e1; overflow: auto; padding: 40px; display: flex; flex-direction: column; align-items: center; }
.canvas-container-wrapper { display: flex; flex-direction: column; gap: 40px; transform-origin: top center; transition: transform 0.2s ease-out; }
.page-wrapper { background: #fff; box-shadow: 0 4px 20px rgba(0,0,0,0.1); position: relative; margin: 0 auto; }
.page-wrapper.replace-mode-active .textLayer {
    z-index: 10 !important;
    pointer-events: auto !important;
}
.page-wrapper.replace-mode-active .canvas-container {
    pointer-events: none !important;
}
.page-wrapper.replace-mode-active .textLayer span {
    background: rgba(220, 38, 38, 0.1);
    border: 1px dashed rgba(220, 38, 38, 0.4);
    cursor: pointer !important;
    pointer-events: auto !important;
}
.page-wrapper.replace-mode-active .textLayer span:hover {
    background: rgba(220, 38, 38, 0.3);
}

/* PDF.js Text Layer */
.textLayer { position: absolute; left: 0; top: 0; right: 0; bottom: 0; overflow: hidden; opacity: 1; line-height: 1.0; pointer-events: none; z-index: 1; }
.textLayer span { color: transparent; position: absolute; white-space: pre; cursor: text; transform-origin: 0% 0%; pointer-events: none; }
.textLayer ::selection { background: rgba(0,0,255,0.2); }
.canvas-container { position: absolute !important; top: 0; left: 0; z-index: 2; }

/* Right Panel (Tabs) */
.editor-right-panel { width: 300px; background: #fff; border-left: 1px solid #e2e8f0; display: flex; flex-direction: column; }
.panel-tabs { display: flex; border-bottom: 1px solid #e2e8f0; background: #f8fafc; }
.tab-btn { flex: 1; padding: 14px 12px; border: none; background: transparent; color: #64748b; font-size: 13px; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.2s ease; display: flex; align-items: center; justify-content: center; gap: 8px; }
.tab-btn:hover { color: #0f172a; background: #f1f5f9; }
.tab-btn.active { background: #fff; color: #dc2626; border-bottom-color: #dc2626; }
.panel-content { display: none; padding: 20px; overflow-y: auto; flex: 1; }
.panel-content.active { display: block; }

/* Properties */
.prop-panel-empty { color: #94a3b8; font-size: 13px; text-align: center; margin-top: 40px; }
.prop-panel-content h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; color: #64748b; letter-spacing: 0.05em; font-weight: 800; }
.prop-desc { font-size: 12px; color: #94a3b8; margin-bottom: 16px; }
.prop-group { margin-bottom: 16px; position: relative; }
.prop-group label { display: block; font-size: 12px; font-weight: 700; color: #475569; margin-bottom: 6px; }
.prop-group select, .prop-group input[type="number"] { width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 13px; color: #0f172a; outline: none; }
.prop-group select:focus, .prop-group input[type="number"]:focus { border-color: #dc2626; }
.color-group input[type="color"] { width: 100%; height: 36px; border: 1px solid #cbd5e1; border-radius: 6px; padding: 2px; cursor: pointer; }
.check-label { display:flex; align-items:center; gap:6px; margin-top:6px; font-weight:normal !important; font-size:12px; color:#64748b; }
.format-group { display: flex; gap: 8px; }
.prop-btn { flex: 1; height: 32px; border: 1px solid #cbd5e1; background: #fff; border-radius: 6px; cursor: pointer; color: #475569; font-size: 14px; font-weight:bold; }
.prop-btn.active { background: #fef2f2; color: #dc2626; border-color: #fca5a5; }
.val-badge { position: absolute; right: 0; top: 0; font-size: 11px; color: #94a3b8; }

/* Layers */
.layers-actions { display: flex; gap: 4px; margin-bottom: 12px; }
.layer-action-btn { background: #fff; border: 1px solid #e2e8f0; color: #64748b; cursor: pointer; padding: 6px; border-radius: 4px; font-size: 12px; font-weight: 600; transition: all 0.2s; flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.02); }
.layer-action-btn:hover { background: #f8fafc; color: #0f172a; border-color: #cbd5e1; }
.layer-action-btn:hover { background: #f1f5f9; }
.layer-action-btn.text-danger:hover { background: #fef2f2; color: #dc2626; border-color: #fca5a5; }

.layers-hint { font-size: 11px; color: #94a3b8; margin: 0 0 16px; line-height: 1.4; }
.layers-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.layer-item { display: flex; align-items: center; background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; padding: 6px 8px; gap: 6px; cursor: grab; transition: all 0.2s; user-select: none; box-sizing: border-box; width: 100%; overflow: hidden; margin-bottom: 6px; box-shadow: 0 1px 2px rgba(0,0,0,0.02); }
.layer-item:hover { border-color: #cbd5e1; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.layer-item:active { cursor: grabbing; }
.layer-item.active { border-color: #dc2626; background: #fef2f2; }
.layer-item.multi-active { border-color: #3b82f6; background: #eff6ff; }
.layer-drag { color: #cbd5e1; font-size: 12px; }
.layer-icon { color: #64748b; font-size: 13px; width: 16px; text-align: center; }
.layer-name { flex: 1; min-width: 0; font-size: 12px; color: #0f172a; font-weight: 500; border: none; background: transparent; outline: none; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; padding: 4px; border-radius: 4px; transition: background 0.2s; }
.layer-name:focus { background: #fff; box-shadow: inset 0 0 0 1px #3b82f6; }
.layer-btn { background: transparent; border: none; color: #94a3b8; cursor: pointer; font-size: 12px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 4px; transition: all 0.2s; flex-shrink: 0; }
.layer-actions-group { display: flex; align-items: center; gap: 2px; flex-shrink: 0; margin-left: auto; }
.layer-btn:hover { color: #0f172a; background: #f1f5f9; }
.layer-btn.locked { color: #dc2626; }
.layer-btn.hidden { color: #cbd5e1; }
.layer-btn.delete:hover { color: #fff; background: #dc2626; }

@media(max-width: 1000px) {
    #btn-toggle-props-drawer, .drawer-close-btn { display: inline-grid !important; }
    .editor-right-panel {
        display: none;
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(320px, 88vw);
        z-index: 45;
        box-shadow: -8px 0 28px rgba(15, 23, 42, 0.18);
    }
    .editor-right-panel.drawer-open {
        display: flex !important;
    }
    .editor-drawer-backdrop.open {
        display: block !important;
        position: absolute;
        inset: 0;
        background: rgba(15, 23, 42, 0.32);
        z-index: 38;
    }
    .editor-header { overflow-x: auto; gap: 12px; padding: 0 12px; }
    .toolbar-group { flex-shrink: 0; }
}
@media(max-width: 768px) {
    #btn-toggle-pages-drawer { display: inline-grid !important; }
    .editor-sidebar {
        display: none;
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(210px, 78vw);
        z-index: 45;
        box-shadow: 8px 0 28px rgba(15, 23, 42, 0.18);
    }
    .editor-sidebar.drawer-open {
        display: flex !important;
    }
    .editor-main { padding: 16px; }
    .upload-box { padding: 32px 20px; }
}

/* Modals */
.editor-modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(7, 24, 49, 0.4); backdrop-filter: blur(4px); z-index: 9999; display: flex; align-items: center; justify-content: center; }
.editor-modal { background: #fff; width: 100%; max-width: 440px; border-radius: 16px; padding: 32px; text-align: center; box-shadow: 0 20px 40px rgba(0,0,0,0.15); animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes modalIn { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
.editor-modal-icon { width: 56px; height: 56px; margin: 0 auto 16px; background: #fef2f2; color: #dc2626; font-size: 24px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.editor-modal h3 { margin: 0 0 12px; font-size: 20px; font-weight: 800; color: #0f172a; }
.editor-modal p { margin: 0 0 24px; font-size: 14px; color: #64748b; line-height: 1.5; }
.editor-modal-actions { display: flex; flex-direction: column; gap: 12px; }
.editor-modal-actions .btn { width: 100%; padding: 12px; justify-content: center; }

.prop-group input[type="range"] { width: 100%; margin: 10px 0; padding: 0; outline: none; border: none; }
/* Premium Toolbar Buttons */
.editor-header .toolbar-group .btn {
    height: 38px !important;
    padding: 0 16px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    transition: all 0.2s ease !important;
    margin: 0 !important;
}
.editor-header .toolbar-group .btn-primary {
    background: #059669 !important;
    color: #fff !important;
    border: 1px solid #059669 !important;
    box-shadow: 0 2px 4px rgba(5,150,105,0.2) !important;
}
.editor-header .toolbar-group .btn-primary:hover {
    background: #047857 !important;
    border-color: #047857 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 6px rgba(5,150,105,0.25) !important;
}
.editor-header .toolbar-group .btn-secondary {
    background: #fff !important;
    color: #0f172a !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
    margin-right: 12px !important;
}
.editor-header .toolbar-group .btn-secondary:hover {
    background: #f8fafc !important;
    border-color: #94a3b8 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08) !important;
}
.editor-header .toolbar-group #btn-toggle-edit {
    margin-right: 12px !important;
}
.editor-header .toolbar-group #btn-toggle-edit.btn-primary {
    background: #dc2626 !important;
    color: #fff !important;
    border: 1px solid #dc2626 !important;
    box-shadow: 0 2px 4px rgba(220,38,38,0.2) !important;
}
.editor-header .toolbar-group #btn-toggle-edit.btn-primary:hover {
    background: #b91c1c !important;
    border-color: #b91c1c !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 6px rgba(220,38,38,0.25) !important;
}


.btn-upload-premium {
    background: #f8fafc;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 14px 36px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.btn-upload-premium:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
}

/* Cross-Page Object Movement & Ghost Preview */
.page-wrapper.cross-page-drop-target {
    outline: 3px dashed #059669;
    outline-offset: 4px;
    box-shadow: 0 0 0 6px rgba(5, 150, 105, 0.14), 0 8px 25px rgba(0, 0, 0, 0.15);
}
.cross-page-drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 9998;
    border: 2px dashed #059669;
    background: rgba(5, 150, 105, 0.08);
    border-radius: 4px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.22);
    display: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.cross-page-drag-ghost img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    opacity: 0.85;
}
.cross-page-drag-ghost-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    background: #059669;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.move-page-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
}
.move-page-pill {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 9px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.move-page-pill:hover {
    border-color: #dc2626;
    color: #dc2626;
    background: #fef2f2;
}
.move-page-pill.active {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
    cursor: default;
}

/* Compact Annotate Dropdown & Annotation Swatches */
.annotate-dropdown-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.annotate-menu-trigger {
    width: auto !important;
    padding: 0 10px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    border: 1px solid #e2e8f0 !important;
    background: #f8fafc !important;
}
.annotate-menu-trigger:hover,
.annotate-menu-trigger.active {
    background: #fef2f2 !important;
    color: #dc2626 !important;
    border-color: #fca5a5 !important;
}
.annotate-trigger-label {
    font-size: 12px;
    font-weight: 700;
}
.annotate-caret {
    font-size: 10px;
    opacity: 0.75;
}
.annotate-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 195px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
    padding: 6px;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.annotate-dropdown-title {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    padding: 4px 8px 2px;
}
.annotate-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 10px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
}
.annotate-menu-item i {
    width: 16px;
    text-align: center;
    font-size: 14px;
}
.annotate-menu-item:hover,
.annotate-menu-item.active {
    background: #fef2f2;
    color: #dc2626;
}
.annotate-menu-divider {
    height: 1px;
    background: #f1f5f9;
    margin: 4px 2px;
}
.annot-color-swatches {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}
.annot-swatch {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 2px solid rgba(15, 23, 42, 0.15);
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.annot-swatch:hover,
.annot-swatch.active {
    transform: scale(1.12);
    border-color: #0f172a;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
}
