@import url('/pdf-tools-design.css');

/* tool-only short names → common theme vars (auto light/dark, no extra rules) */
:root { --surface2: var(--card-bg); --text: var(--text-dark); --text2: var(--dim); --preview-w: 540px; }

/* ===== LAYOUT : LEFT = empty AdSense slot · RIGHT = all boxes (matches other tools) ===== */
.editor-wrap { max-width: 1200px; margin: 24px auto 0; }
.fs-layout { display: grid; grid-template-columns: 220px minmax(0,1fr); gap: 20px; align-items: start; }
.fs-ad-left { min-height: 250px; }
.fs-right { min-width: 0; display: flex; flex-direction: column; }

@media (max-width: 980px) {
  .fs-layout { grid-template-columns: minmax(0,1fr); }
  .fs-ad-left { display: none; }
}

/* ===== TOOLBAR — chhota + right side aligned ===== */
.editor-toolbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px; padding: 7px 10px; margin-bottom: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.et-btn { display: inline-flex; align-items: center; gap: 4px; padding: 5px 8px; border-radius: 7px; border: 1.5px solid var(--border); background: var(--surface2); color: var(--text); font-size: .68rem; font-weight: 600; cursor: pointer; transition: all .18s ease; white-space: nowrap; }
.et-btn:hover { border-color: var(--primary); color: var(--primary); }
.et-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.et-btn:disabled { opacity: .4; cursor: not-allowed; }
.et-spacer { flex: 0 0 auto; width: 8px; }
.et-nav { padding: 6px 9px; }
.et-page-indicator { font-size: .72rem; color: var(--dim); font-weight: 600; white-space: nowrap; }
.et-divider { width: 1px; height: 22px; background: var(--border); margin: 0 3px; flex-shrink: 0; }
.zoom-level { font-size: .65rem; color: var(--dim); font-weight: 600; min-width: 34px; text-align: center; }
.et-dropdown { position: relative; }

/* table picker */
.table-picker { position: absolute; top: calc(100% + 6px); left: 0; background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.16); padding: 12px; z-index: 60; }
.table-picker-grid { display: grid; grid-template-columns: repeat(8,22px); grid-template-rows: repeat(8,22px); gap: 3px; }
.tp-cell { width: 22px; height: 22px; border: 1.5px solid var(--border); border-radius: 4px; background: var(--surface2); cursor: pointer; transition: background .08s, border-color .08s; }
.tp-cell.active { background: var(--primary); border-color: var(--primary); }
.table-picker-label { margin-top: 9px; text-align: center; font-size: .75rem; font-weight: 700; color: var(--text2); }

/* ===== TOOL OPTIONS ===== */
.tool-options { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: var(--primary-glow); border: 1.5px solid var(--primary); border-radius: 12px; padding: 9px 14px; margin-bottom: 14px; font-size: .8rem; font-weight: 600; color: var(--text2); }
.tool-options label { display: inline-flex; align-items: center; gap: 6px; }
.tool-options input[type="color"] { width: 30px; height: 26px; padding: 1px; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; background: none; }
.tool-options input[type="range"] { width: 90px; accent-color: var(--primary); cursor: pointer; }
.shortcut-hint { text-align: center; font-size: .68rem; color: var(--dim); margin: 12px 0 0; }

/* ===== CANVAS + OVERLAY (untouched) ===== */
.canvas-stage { display: flex; justify-content: center; background: var(--card-bg); border-radius: 14px; padding: 16px 10px; margin-bottom: 14px; overflow-x: auto; min-width: 0; }
.page-wrap { position: relative; display: inline-block; box-shadow: 0 6px 24px rgba(0,0,0,.14); border-radius: 4px; overflow: hidden; background: #fff; }
.page-wrap canvas { display: block; }
.overlay-layer { position: absolute; top: 0; left: 0; touch-action: pan-x pan-y; }
.ov-el { position: absolute; box-sizing: border-box; display: flex; align-items: center; justify-content: center; cursor: move; user-select: none; touch-action: none; border: 1.5px dashed transparent; }
.ov-el.selected { border-color: var(--primary); }
.ov-el.ov-text, .ov-el.ov-date { justify-content: flex-start; overflow: visible; }
.ov-el.ov-image { padding: 0; }
.ov-content { width: 100%; height: 100%; display: flex; align-items: center; }
.ov-el.ov-text .ov-content, .ov-el.ov-date .ov-content { padding: 2px 4px; white-space: nowrap; justify-content: flex-start; outline: none; }
.ov-el.ov-image .ov-content { justify-content: center; }
.ov-el.ov-image img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.ov-el.ov-checkbox { border: 1.5px solid #000; background: rgba(255,255,255,.6); }
.ov-el.ov-checkbox .ov-content { justify-content: center; font-size: .9em; font-weight: 900; color: #000; }
.ov-el.ov-checkbox.selected { border-color: var(--primary); }
.ov-el.ov-table .ov-content { padding: 2px; }
.ov-el.ov-table .ov-content table { width: 100%; border-collapse: collapse; }
.ov-el.ov-table .ov-content td { min-width: 20px; }
.ov-resize-handle { position: absolute; right: -9px; bottom: -9px; width: 18px; height: 18px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; cursor: nwse-resize; display: none; touch-action: none; }
.ov-rotate-handle { position: absolute; top: -30px; left: 50%; transform: translateX(-50%); width: 18px; height: 18px; border-radius: 50%; background: #10b981; border: 2px solid #fff; cursor: grab; display: none; touch-action: none; }
.ov-delete-btn { position: absolute; top: -13px; right: -13px; width: 24px; height: 24px; border-radius: 50%; background: #ef4444; color: #fff; font-size: .7rem; display: none; align-items: center; justify-content: center; cursor: pointer; touch-action: none; }
.ov-el.selected .ov-resize-handle, .ov-el.selected .ov-rotate-handle, .ov-el.selected .ov-delete-btn { display: flex; }
.overlay-layer.tool-mode { cursor: crosshair; }
.overlay-layer.tool-mode .ov-el { pointer-events: none; }
.pen-canvas { position: absolute; top: 0; left: 0; z-index: 15; cursor: crosshair; touch-action: none; }
.ov-ghost { position: absolute; border: 2px dashed var(--primary); background: var(--primary-glow); pointer-events: none; z-index: 20; }
.ov-ghost.ghost-highlight { background: rgba(250,204,21,.35); border-color: #eab308; }
.ov-ghost.ghost-whiteout { background: rgba(255,255,255,.92); border-color: #94a3b8; }
.snap-guide { position: absolute; background: #f43f5e; z-index: 25; pointer-events: none; }
.snap-guide-v { width: 1px; top: 0; bottom: 0; }
.snap-guide-h { height: 1px; left: 0; right: 0; }
.ov-el.ov-formfield { cursor: default; border: 1.5px dashed rgba(37,99,235,.55); background: rgba(37,99,235,.07); border-radius: 3px; }
.ov-el.ov-formfield input[type="text"] { width: 100%; height: 100%; border: none; background: transparent; font-size: 13px; padding: 2px 5px; color: #1d4ed8; font-weight: 600; outline: none; }
.ov-el.ov-formfield select { width: 100%; height: 100%; border: none; background: rgba(255,255,255,.85); font-size: 11px; color: #1d4ed8; outline: none; }
.ov-el.ov-formfield input[type="checkbox"] { width: 18px; height: 18px; accent-color: #2563eb; }
.ff-sig-note { font-size: 10px; color: #7c3aed; font-weight: 700; white-space: nowrap; }

/* ===== THUMBNAILS ===== */
.thumb-strip-wrap { margin-bottom: 12px; min-width: 0; }
.thumb-strip { display: flex; gap: 10px; overflow-x: auto; padding: 10px 4px; background: var(--card-bg); border: 1.5px solid var(--border); border-radius: 12px; }
.thumb { position: relative; flex: 0 0 auto; cursor: pointer; border-radius: 6px; border: 2px solid transparent; overflow: hidden; background: #fff; transition: border-color .15s, transform .15s; }
.thumb canvas { display: block; height: 72px; width: auto; }
.thumb:hover { transform: translateY(-2px); }
.thumb.active { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.thumb-num { position: absolute; bottom: 2px; right: 4px; font-size: .6rem; font-weight: 700; color: #fff; background: rgba(0,0,0,.55); padding: 1px 5px; border-radius: 4px; }
.thumb-badge { position: absolute; top: 3px; left: 3px; background: var(--primary); color: #fff; font-size: .58rem; font-weight: 700; min-width: 15px; height: 15px; border-radius: 99px; display: flex; align-items: center; justify-content: center; padding: 0 3px; }

/* ===== FORMAT PANEL ===== */
.format-panel { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; padding: 10px 14px; margin-bottom: 16px; box-shadow: 0 2px 10px rgba(0,0,0,.05); }
.fmt-select, .fmt-number { padding: 7px 9px; border-radius: 7px; border: 1.5px solid var(--border); font-size: .8rem; background: var(--surface2); color: var(--text); }
.fmt-number { width: 62px; }
.fmt-color, #fmtBgColor { width: 34px; height: 32px; padding: 2px; border-radius: 7px; border: 1.5px solid var(--border); cursor: pointer; background: none; }
.fmt-toggle-btn { width: 32px; height: 32px; border-radius: 7px; border: 1.5px solid var(--border); background: var(--surface2); color: var(--text); cursor: pointer; font-size: .85rem; }
.fmt-toggle-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.fmt-delete-btn { margin-left: auto; padding: 8px 14px; border-radius: 8px; border: 1.5px solid rgba(239,68,68,.3); background: rgba(239,68,68,.08); color: #ef4444; font-size: .8rem; font-weight: 700; cursor: pointer; }
#fmtTextAlign { padding: 7px 9px; border-radius: 7px; border: 1.5px solid var(--border); font-size: .8rem; background: var(--surface2); color: var(--text); }
#fmtOpacity { width: 70px; accent-color: var(--primary); cursor: pointer; }
.fmt-table-controls { display: inline-flex; gap: 6px; align-items: center; }
.tbl-ctrl { width: auto !important; padding: 0 10px !important; font-size: .72rem !important; font-weight: 700; }

/* ===== FORM FIELDS CARD ===== */
.form-fields-card { background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px; padding: 20px; margin-bottom: 16px; box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.form-fields-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.form-fields-icon { font-size: 1.4rem; }
.form-fields-head h3 { font-size: .94rem; font-weight: 700; color: var(--text); margin: 0 0 3px; }
.form-fields-head p { font-size: .78rem; color: var(--dim); margin: 0; }
.form-fields-list { display: flex; flex-direction: column; gap: 10px; }
.form-field-row { display: flex; align-items: center; gap: 12px; }
.form-field-row label { min-width: 140px; font-size: .8rem; font-weight: 600; color: var(--text); }
.ff-input { flex: 1; padding: 8px 12px; border-radius: 8px; border: 1.5px solid var(--border); font-size: .82rem; background: var(--surface2); color: var(--text); }
input.ff-input[type="checkbox"] { flex: none; width: 18px; height: 18px; }

/* ===== SAVE BAR — chhota + right side aligned (toolbar jaisi hi size) ===== */
.save-bar { display: flex; align-items: center; justify-content: flex-end; gap: 6px; flex-wrap: nowrap; background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px; padding: 7px 10px; box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.save-bar .btn { padding: 5px 10px; border-radius: 7px; border: none; font-size: .68rem; font-weight: 700; background: var(--primary); color: #fff; cursor: pointer; transition: all .18s ease; white-space: nowrap; }
.save-bar .btn:hover { background: var(--primary-dark); transform: scale(1.02); }
.save-bar .btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.flatten-check { display: flex; align-items: center; gap: 5px; font-size: .68rem; color: var(--text2); cursor: pointer; margin-right: auto; white-space: nowrap; }
.save-actions { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; flex-shrink: 0; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1.5px solid var(--border); padding: 5px 10px; border-radius: 7px; font-size: .68rem; font-weight: 600; cursor: pointer; transition: all .18s ease; white-space: nowrap; }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.save-progress { margin-top: 14px; background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px; padding: 18px 20px; text-align: center; }
.save-progress-text { font-size: .82rem; color: var(--dim); margin-bottom: 8px; }
.save-progress-track { height: 6px; border-radius: 99px; background: rgba(128,128,128,.2); overflow: hidden; }
.save-progress-fill { height: 100%; width: 30%; background: linear-gradient(90deg, var(--primary), var(--primary-dark)); border-radius: 99px; animation: saveInd 1.2s ease-in-out infinite; }
@keyframes saveInd { 0%{margin-left:0;width:20%} 50%{margin-left:60%;width:35%} 100%{margin-left:0;width:20%} }
.save-result { margin-top: 14px; padding: 12px 18px; border-radius: 12px; background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.3); color: #10b981; font-weight: 700; font-size: .85rem; text-align: center; }

/* ===== SIGNATURE MODAL — inner only (.modal-overlay common se aata hai) ===== */
.modal-box { background: var(--surface); border-radius: 18px; padding: 22px; max-width: 540px; width: 100%; box-shadow: 0 24px 60px rgba(0,0,0,.3); }
.modal-tabs { display: flex; gap: 6px; margin-bottom: 18px; background: var(--surface2); border-radius: 10px; padding: 5px; }
.modal-tab { flex: 1; border: none; background: transparent; padding: 9px; border-radius: 7px; font-size: .82rem; font-weight: 600; color: var(--text2); cursor: pointer; }
.modal-tab.active { background: var(--surface); color: var(--primary); box-shadow: 0 2px 6px rgba(0,0,0,.08); }
#sigDrawCanvas { width: 100%; height: 200px; border: 1.5px dashed var(--border); border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; }
.modal-clear-btn { margin-top: 10px; padding: 7px 14px; border-radius: 8px; border: 1.5px solid var(--border); background: var(--surface2); color: var(--text); font-size: .8rem; cursor: pointer; }
.modal-text-input { width: 100%; padding: 10px 14px; border-radius: 9px; border: 1.5px solid var(--border); font-size: .9rem; margin-bottom: 10px; background: var(--surface2); color: var(--text); }
.modal-font-select { width: 100%; padding: 9px 12px; border-radius: 9px; border: 1.5px solid var(--border); font-size: .85rem; margin-bottom: 14px; background: var(--surface2); color: var(--text); }
.sig-type-preview { border: 1.5px dashed var(--border); border-radius: 10px; height: 120px; display: flex; align-items: center; justify-content: center; font-size: 2.2rem; color: #000; background: #fff; overflow: hidden; padding: 0 12px; text-align: center; }
.modal-upload-drop { display: flex; align-items: center; justify-content: center; height: 140px; border: 1.5px dashed var(--border); border-radius: 10px; cursor: pointer; font-size: .86rem; color: var(--dim); text-align: center; padding: 12px; }
.modal-upload-preview { margin-top: 12px; max-width: 100%; max-height: 140px; border-radius: 8px; border: 1.5px solid var(--border); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-cancel-btn { padding: 10px 18px; border-radius: 9px; border: 1.5px solid var(--border); background: var(--surface2); color: var(--text); font-size: .84rem; font-weight: 600; cursor: pointer; }
.modal-insert-btn { padding: 12px 28px; border-radius: 10px; border: none; background: var(--primary); color: #fff; font-size: .92rem; font-weight: 700; cursor: pointer; box-shadow: 0 4px 14px var(--primary-glow); transition: all .18s ease; }
.modal-insert-btn:hover { background: var(--primary-dark); transform: translateY(-1px); }
.modal-hint { font-size: .75rem; color: var(--dim); text-align: center; margin-top: 14px; font-weight: 600; }
.sig-saved-banner { display: flex; align-items: center; gap: 10px; background: rgba(16,185,129,.08); border: 1.5px solid rgba(16,185,129,.3); border-radius: 10px; padding: 8px 12px; margin-bottom: 14px; font-size: .78rem; font-weight: 600; color: #059669; flex-wrap: wrap; }
.sig-saved-banner img { height: 34px; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; }

/* ===== TOAST ===== */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px); background: #0b0f1c; color: #fff; padding: 11px 20px; border-radius: 12px; font-size: .85rem; font-weight: 600; z-index: 99999; opacity: 0; transition: all .25s ease; box-shadow: 0 10px 30px rgba(0,0,0,.3); max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-error { background: #dc2626; }

/* ===== ALIGN + SIZE FIX (desktop) : parent (.fs-right) pe width — sab bachche (toolbar, thumbnails, canvas, save-bar) automatically ek hi width match karenge, koi box chhoot nahi sakta ===== */
.fs-right {
  max-width: var(--preview-w) !important;
  margin-left: auto !important;
  margin-right: 0 !important;
}
.shortcut-hint { text-align: right !important; }

/* ===== PRINT (sirf PDF page) ===== */
@media print {
    .editor-toolbar, .format-panel, .form-fields-card, .save-bar, .save-progress, .save-result, .modal-overlay, .thumb-strip-wrap, .tool-options, .shortcut-hint { display: none !important; }
    .canvas-stage { padding: 0 !important; background: #fff !important; }
    .page-wrap { box-shadow: none !important; }
    .ov-el .ov-resize-handle, .ov-el .ov-rotate-handle, .ov-el .ov-delete-btn { display: none !important; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 980px) {
    .fs-right { max-width: 100% !important; margin-left: 0 !important; }
    .save-result { text-align: center !important; }
    .shortcut-hint { text-align: center !important; }
    .canvas-stage { margin-left: auto !important; margin-right: auto !important; }
}
@media (max-width: 640px) {
    .editor-toolbar { gap: 3px; padding: 6px 8px; justify-content: flex-end; }
    .et-btn { padding: 4px 6px; font-size: .64rem; }
    .et-divider { height: 18px; margin: 0 2px; }
    .format-panel { gap: 4px; padding: 8px 10px; }
    .fmt-select { padding: 5px 7px; font-size: .7rem; }
    .fmt-number { width: 48px; padding: 5px 7px; font-size: .7rem; }
    .fmt-color, #fmtBgColor { width: 28px; height: 26px; }
    #fmtOpacity { width: 50px; }
    .save-bar { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; justify-content: flex-end; }
    .flatten-check { margin-right: 0; }
    .save-actions { width: 100%; justify-content: flex-end; } .save-actions > * { flex: 1 1 auto; }
    .save-bar .btn { padding: 6px 12px; font-size: .72rem; }
    .form-field-row { flex-direction: column; align-items: flex-start; }
    .form-field-row label { min-width: 0; }
    .tool-options { gap: 8px; font-size: .72rem; }
    .thumb canvas { height: 54px; }
    .shortcut-hint { display: none; }
}