/* 元素选中状态 */
/* 未选中状态 - 没有边框 */
.canvas-element:not(.selected) {
    border: none !important;
}

/* 选中状态 - 显示蓝色边框 */
.canvas-element.selected {
    border: 2px solid #4dabf7 !important;
    border-radius: 4px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5) inset, 0 0 8px rgba(77, 171, 247, 0.3);
}

/* 增强的元素控制控件 */
.canvas-element.selected {
    outline: 2px solid #4ad9ab !important;
    outline-offset: 2px;
}

/* 控制点容器 - 只在选中时显示 */
.element-controls {
    display: none;
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    pointer-events: none;
    z-index: 10;
}

.canvas-element.selected .element-controls {
    display: block;
}

/* 调整大小的控制点 */
.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #4dabf7;
    border: 2px solid white;
    border-radius: 50%;
    pointer-events: all;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.resize-handle:hover {
    background: #1c7ed6;
    transform: scale(1.2);
}

/* 文本元素 - 只显示左右调整点 */
.text-element .resize-handle {
    /* 只保留左右调整点 */
}

.text-element .resize-handle.nw,
.text-element .resize-handle.ne,
.text-element .resize-handle.sw,
.text-element .resize-handle.se,
.text-element .resize-handle.n,
.text-element .resize-handle.s {
    display: none !important;
}

/* 控制点位置 */
.resize-handle.nw {
    top: -6px;
    left: -6px;
    cursor: nw-resize;
}

.resize-handle.ne {
    top: -6px;
    right: -6px;
    cursor: ne-resize;
}

.resize-handle.sw {
    bottom: -6px;
    left: -6px;
    cursor: sw-resize;
}

.resize-handle.se {
    bottom: -6px;
    right: -6px;
    cursor: se-resize;
}

.resize-handle.n {
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: n-resize;
}

.resize-handle.s {
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: s-resize;
}

.resize-handle.w {
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: w-resize;
}

.resize-handle.e {
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: e-resize;
}

/* 旋转控制点 */
.rotate-handle {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    background: #4dabf7;
    border: 2px solid white;
    border-radius: 50%;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    pointer-events: all;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
}

.rotate-handle:hover {
    background: #1c7ed6;
    transform: translateX(-50%) scale(1.1);
}

.rotate-handle:active {
    cursor: grabbing;
}

/* 禁止文本元素垂直调整 */
.text-element .resize-handle.n,
.text-element .resize-handle.s,
.text-element .resize-handle.nw,
.text-element .resize-handle.ne,
.text-element .resize-handle.sw,
.text-element .resize-handle.se {
    display: none !important;
}

/* 只允许左右调整 */
.text-element .resize-handle.w,
.text-element .resize-handle.e {
    display: block;
}

/* 控制点统一样式 */
.element-control-point {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #4ad9ab;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    pointer-events: all;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 1001;
}

.element-control-point:hover {
    background: #18cfa1;
    transform: scale(1.2);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* 缩放控制点 */
.resize-point {
    background: #4ad9ab;
}

.resize-point.nw {
    top: -6px;
    left: -6px;
    cursor: nwse-resize;
}

.resize-point.ne {
    top: -6px;
    right: -6px;
    cursor: nesw-resize;
}

.resize-point.sw {
    bottom: -6px;
    left: -6px;
    cursor: nesw-resize;
}

.resize-point.se {
    bottom: -6px;
    right: -6px;
    cursor: nwse-resize;
}

.resize-point.n {
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: ns-resize;
}

.resize-point.s {
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: ns-resize;
}

.resize-point.w {
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: ew-resize;
}

.resize-point.e {
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: ew-resize;
}

/* 旋转控制点 */
.rotate-point {
    background: #1593ff;
    width: 24px;
    height: 24px;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: white;
}

.rotate-point:hover {
    background: #198ae7;
    transform: translateX(-50%) scale(1.2);
}

.rotate-point:active {
    cursor: grabbing;
}

.rotate-point::before {
    content: "↻";
    font-size: 14px;
}

/* 控制线 */
.resize-line {
    position: absolute;
    pointer-events: none;
}

.resize-line.horizontal {
    left: 12px;
    right: 12px;
    height: 1px;
    background: rgba(77, 171, 247, 0.3);
}

.resize-line.horizontal.top {
    top: -3px;
}

.resize-line.horizontal.bottom {
    bottom: -3px;
}

.resize-line.vertical {
    top: 12px;
    bottom: 12px;
    width: 1px;
    background: rgba(77, 171, 247, 0.3);
}

.resize-line.vertical.left {
    left: -3px;
}

.resize-line.vertical.right {
    right: -3px;
}

/* 旋转角度指示器 */
.rotation-indicator {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 2px;
    background: #1593ff;
    pointer-events: none;
}

.rotation-indicator::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 2px dashed rgba(21, 147, 255, 0.3);
    border-radius: 50%;
}