/* ============================================================
   PDF Editor — Shapes tool (dropdown, overlays, float chrome)
   ============================================================ */

/* Shapes layer sits above preview; own pointer events */
.pedit-shapes-layer {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 25;
    pointer-events: none;
    overflow: visible;
}

.pedit-shapes-layer.is-drawing,
.pedit-shapes-layer.has-selection {
    pointer-events: auto;
}

.pedit-shape {
    position: absolute;
    box-sizing: border-box;
    pointer-events: auto;
    cursor: move;
    touch-action: none;
}

.pedit-shape.is-selected {
    outline: 1px dashed rgba(74, 144, 226, 0.85);
    outline-offset: 2px;
}

.pedit-shape[data-type="ellipse"] {
    border-radius: 50%;
}

.pedit-shape[data-type="line"],
.pedit-shape[data-type="arrow"] {
    background: transparent !important;
    border: none !important;
    outline-offset: 4px;
}

.pedit-shape-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}

.pedit-shape-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    background: #fff;
    border: 2px solid #4a90e2;
    border-radius: 2px;
    box-sizing: border-box;
    pointer-events: auto;
    z-index: 2;
    touch-action: none;
}

.pedit-shape-handle[data-handle="n"],
.pedit-shape-handle[data-handle="s"] { cursor: ns-resize; }
.pedit-shape-handle[data-handle="e"],
.pedit-shape-handle[data-handle="w"] { cursor: ew-resize; }
.pedit-shape-handle[data-handle="nw"],
.pedit-shape-handle[data-handle="se"] { cursor: nwse-resize; }
.pedit-shape-handle[data-handle="ne"],
.pedit-shape-handle[data-handle="sw"] { cursor: nesw-resize; }
.pedit-shape-handle[data-handle="a"],
.pedit-shape-handle[data-handle="b"] { cursor: grab; border-radius: 50%; }

/* Dropdown under Shapes toolbar button — always below the button */
.pedit-shapes-menu {
    position: fixed;
    z-index: 950;
    min-width: 168px;
    padding: 6px;
    background: rgba(20, 28, 40, 0.98);
    border: 2px solid var(--primary-light);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
    display: none;
}

.pedit-shapes-menu.is-open {
    display: block;
}

.pedit-shapes-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin: 0;
    padding: 9px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
}

.pedit-shapes-menu-item i {
    width: 1.1em;
    color: #f79112;
    text-align: center;
}

.pedit-shapes-menu-item:hover,
.pedit-shapes-menu-item.is-active {
    background: rgba(247, 145, 18, 0.14);
    color: var(--text-primary);
}

/* Floating shape property bar — 5 clean segments */
.pedit-shape-float-toolbar {
    position: absolute;
    z-index: 65;
    display: none;
    align-items: stretch;
    gap: 0;
    padding: 0;
    background: #ffffff;
    border: 1px solid #f79112;
    border-radius: 10px;
    box-shadow: 0 4px 18px rgba(45, 55, 82, 0.22);
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
    white-space: nowrap;
    overflow: visible;
}

.pedit-shape-float-toolbar.is-visible {
    display: flex;
}

/* During shape drag/resize, toolbar must not steal pointer events */
.pedit-shape-float-toolbar.is-dragging {
    pointer-events: none;
}

.pedit-shape-float-toolbar::after {
    content: '';
    position: absolute;
    left: var(--sft-arrow-x, 18px);
    bottom: -6px;
    width: 11px;
    height: 11px;
    background: #ffffff;
    border-right: 1px solid #f79112;
    border-bottom: 1px solid #f79112;
    transform: rotate(45deg);
}

.pedit-shape-float-toolbar.sft-below::after {
    bottom: auto;
    top: -6px;
    transform: rotate(225deg);
}

.sft-group {
    position: relative;
    display: flex;
    align-items: stretch;
}

.sft-seg {
    position: relative;
    min-width: 44px;
    height: 38px;
    margin: 0;
    padding: 0 12px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: #4a90e2;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font-family: inherit;
}

.sft-group:first-child .sft-seg {
    border-radius: 9px 0 0 9px;
}

.pedit-shape-float-toolbar > .sft-seg:last-child {
    border-radius: 0 9px 9px 0;
}

.sft-seg:hover,
.sft-seg.is-open {
    background: rgba(74, 144, 226, 0.12);
}

.sft-seg--icon {
    min-width: 40px;
    padding: 0 11px;
}

.sft-seg.sft-danger:hover {
    background: rgba(231, 76, 60, 0.12);
    color: #e74c3c;
}

.sft-sep {
    width: 1px;
    align-self: stretch;
    background: rgba(247, 145, 18, 0.45);
    flex-shrink: 0;
}

/* Line / Arrow: hide Border color; keep fill control as "Color" */
.pedit-shape-float-toolbar.sft-line-like [data-role="border"],
.pedit-shape-float-toolbar.sft-line-like [data-role="border-sep"] {
    display: none;
}

.sft-stroke-preview {
    display: block;
    width: 22px;
    background: #4a90e2;
    border-radius: 1px;
}

.sft-seg .fa-caret-down {
    font-size: 0.65rem;
    opacity: 0.85;
}

.sft-icon-border {
    width: 16px;
    height: 16px;
    border: 2px solid #4a90e2;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.sft-icon-fill {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 16px;
}

.sft-icon-fill > i {
    font-size: 0.95rem;
}

.sft-color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4a90e2;
    border: 1px solid rgba(20, 30, 50, 0.25);
    box-sizing: border-box;
}

.sft-icon-border .sft-color-dot {
    width: 8px;
    height: 8px;
}

.sft-icon-fill .sft-color-dot {
    position: absolute;
    right: -2px;
    bottom: -1px;
    width: 8px;
    height: 8px;
}

.sft-color-dot--none {
    background:
        linear-gradient(45deg, transparent 46%, #e74c3c 46%, #e74c3c 54%, transparent 54%),
        #fff !important;
}

.sft-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 80;
    display: none;
    padding: 6px;
    background: #fff;
    border: 1px solid #f79112;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    min-width: 56px;
}

.sft-menu.is-open {
    display: block;
}

.sft-menu--stroke {
    min-width: 64px;
    padding: 4px;
}

.sft-menu--swatches {
    min-width: 160px;
}

.sft-stroke-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
}

.sft-stroke-item:hover,
.sft-stroke-item.is-active {
    background: rgba(74, 144, 226, 0.12);
}

.sft-stroke-item-line {
    display: block;
    width: 36px;
    background: #2a3344;
    border-radius: 1px;
}

.sft-swatch-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 4px;
}

.sft-swatch {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(20, 30, 50, 0.18);
    padding: 0;
    cursor: pointer;
    box-sizing: border-box;
}

.sft-swatch.is-active {
    border-color: #f79112;
    box-shadow: 0 0 0 2px rgba(247, 145, 18, 0.35);
}

.sft-swatch.sft-none {
    background:
        linear-gradient(45deg, transparent 46%, #e74c3c 46%, #e74c3c 54%, transparent 54%),
        #fff;
}

.sft-custom-color {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 4px 6px;
    border-top: 1px solid rgba(20, 30, 50, 0.1);
    color: #4a90e2;
    font-size: 0.8rem;
    cursor: pointer;
}

.sft-custom-color input[type="color"] {
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
}

.sft-custom-color input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.sft-custom-color input[type="color"]::-webkit-color-swatch {
    border: 1px solid rgba(20, 30, 50, 0.2);
    border-radius: 4px;
}

.pdf-canvas-wrap.shapes-draw-mode {
    cursor: crosshair;
}
