/* text_editor.css - 文字编辑器样式（控制点紧凑版） */

/* ========== 文字元素基础样式 ========== */
.text-element {
    position: absolute;
    background: transparent;
    cursor: pointer;
    line-height: 1.4;
    word-break: break-word;
    white-space: pre-wrap;
    z-index: 10;
    box-sizing: border-box;
}

.text-element.has-bg {
    background-clip: padding-box;
}

.text-element.edit-mode-enabled {
    outline: 1px dashed rgba(255, 215, 0, 0.5);
    outline-offset: 1px;
}

.text-element.dragging {
    opacity: 0.95;
    filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.4));
}

.text-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    box-sizing: border-box;
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* 强制支持小字体 */
.text-content {
    font-size-adjust: none;
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
    -webkit-font-smoothing: antialiased;
}

.text-content * {
    font-size: inherit;
}

/* ========== 8方向缩放控制点 - 紧凑贴合边缘 ========== */
.text-resize-handle {
    position: absolute !important;
    background-color: #fff !important;
    border: 1.5px solid #ff6600 !important;
    border-radius: 50% !important;
    z-index: 10001 !important;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.3) !important;
    pointer-events: auto !important;
    box-sizing: border-box !important;
    transition: transform 0.1s ease, background 0.1s ease;
}

/* PC端控制点定位 - 紧贴边缘偏移2px */
.text-resize-nw { left: -2px !important; top: -2px !important; cursor: nw-resize !important; }
.text-resize-n { left: 50% !important; top: -2px !important; margin-left: -4px !important; cursor: n-resize !important; }
.text-resize-ne { right: -2px !important; top: -2px !important; cursor: ne-resize !important; }
.text-resize-e { right: -2px !important; top: 50% !important; margin-top: -4px !important; cursor: e-resize !important; }
.text-resize-se { right: -2px !important; bottom: -2px !important; cursor: se-resize !important; }
.text-resize-s { left: 50% !important; bottom: -2px !important; margin-left: -4px !important; cursor: s-resize !important; }
.text-resize-sw { left: -2px !important; bottom: -2px !important; cursor: sw-resize !important; }
.text-resize-w { left: -2px !important; top: 50% !important; margin-top: -4px !important; cursor: w-resize !important; }

/* ========== 旋转控制点 - 紧凑贴合上方边缘 ========== */
.text-rotate-handle {
    position: absolute !important;
    background-color: #fff !important;
    border: 1.5px solid #3399ff !important;
    border-radius: 50% !important;
    top: -10px !important;
    left: 50% !important;
    margin-left: -5px !important;
    width: 10px !important;
    height: 10px !important;
    z-index: 10001 !important;
    cursor: grab !important;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.3) !important;
    text-align: center !important;
    line-height: 7px !important;
    font-size: 7px !important;
    color: #3399ff !important;
    box-sizing: border-box !important;
    transition: transform 0.1s ease, background 0.1s ease;
}

.text-rotate-handle:active {
    cursor: grabbing !important;
}

/* ========== 控制点悬停效果 ========== */
.text-resize-handle:hover {
    transform: scale(1.15);
    background-color: #ff6600 !important;
    border-color: #fff !important;
}

.text-rotate-handle:hover {
    transform: scale(1.15);
    background-color: #3399ff !important;
    color: #fff !important;
}

/* ========== 手机端控制点 - 稍大但依然紧凑 ========== */
@media (max-width: 768px) {
    .text-resize-handle {
        width: 10px !important;
        height: 10px !important;
        border-width: 1.5px !important;
    }
    .text-resize-nw { left: -3px !important; top: -3px !important; }
    .text-resize-n { left: 50% !important; top: -3px !important; margin-left: -5px !important; }
    .text-resize-ne { right: -3px !important; top: -3px !important; }
    .text-resize-e { right: -3px !important; top: 50% !important; margin-top: -5px !important; }
    .text-resize-se { right: -3px !important; bottom: -3px !important; }
    .text-resize-s { left: 50% !important; bottom: -3px !important; margin-left: -5px !important; }
    .text-resize-sw { left: -3px !important; bottom: -3px !important; }
    .text-resize-w { left: -3px !important; top: 50% !important; margin-top: -5px !important; }
    
    .text-rotate-handle {
        width: 12px !important;
        height: 12px !important;
        top: -12px !important;
        margin-left: -6px !important;
        line-height: 9px !important;
        font-size: 8px !important;
    }
}

/* 拖拽时控制点半透明 */
.text-element.dragging .text-resize-handle,
.text-element.dragging .text-rotate-handle {
    opacity: 0.4;
    pointer-events: none;
}

/* ========== 工具栏样式 ========== */
.text-edit-toolbar {
    position: fixed !important;
    z-index: 999999 !important;
    background: linear-gradient(135deg, #2d2d2d 0%, #1a1a1a 100%) !important;
    border-radius: 40px !important;
    padding: 8px 16px !important;
    display: flex !important;
    gap: 12px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
    border: 1px solid #ff6600 !important;
    backdrop-filter: blur(12px) !important;
}

.text-edit-toolbar button {
    background: rgba(255, 255, 255, 0.2) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    color: #fff !important;
    padding: 6px 14px !important;
    border-radius: 30px !important;
    cursor: pointer !important;
    font-size: 13px !important;
    font-weight: bold !important;
    transition: all 0.2s ease;
}

.text-edit-toolbar button:hover {
    background: #ff6600 !important;
    transform: translateY(-1px);
}

.text-edit-toolbar button:active {
    transform: translateY(0);
}

@media (max-width: 768px) {
    .text-edit-toolbar { 
        padding: 6px 12px !important; 
        gap: 8px !important; 
    }
    .text-edit-toolbar button { 
        padding: 5px 12px !important; 
        font-size: 11px !important; 
    }
}

/* ========== 列表面板样式 ========== */
.text-list-panel {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 999998;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 12px;
    min-width: 180px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.text-list-panel.show { 
    display: block; 
}

.text-list-panel h4 { 
    color: #ffd700; 
    margin: 0 0 8px; 
    font-size: 13px; 
    text-align: center; 
}

.text-list-item { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 6px 8px; 
    margin: 4px 0; 
    background: rgba(255,255,255,0.1); 
    border-radius: 8px; 
    cursor: pointer; 
    transition: background 0.2s;
}

.text-list-item:hover { 
    background: rgba(255,102,0,0.5); 
}

.text-list-item .text-preview { 
    flex: 1; 
    font-size: 11px; 
    color: #fff; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    white-space: nowrap; 
}

.text-list-item .delete-text { 
    background: rgba(255,68,68,0.5); 
    border: none; 
    color: #fff; 
    border-radius: 50%; 
    width: 18px; 
    height: 18px; 
    cursor: pointer; 
    font-size: 11px; 
    margin-left: 6px;
    transition: background 0.2s;
}

.text-list-item .delete-text:hover {
    background: rgba(255,68,68,0.9);
}

@media (max-width: 768px) {
    .text-list-panel { 
        left: 10px; 
        right: 10px; 
        top: auto; 
        bottom: 80px; 
        transform: none; 
        min-width: auto; 
        max-height: 45vh; 
    }
}

/* ========== 编辑弹窗样式 ========== */
.text-edit-modal {
    background: linear-gradient(135deg, #1e1e2f, #2a2a3a);
    border-radius: 20px;
    padding: 18px;
    max-width: 580px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.text-edit-modal h3 { 
    color: #ffd700; 
    margin-bottom: 15px; 
    font-size: 16px; 
}

.text-edit-modal textarea { 
    width: 100%; 
    height: 100px; 
    padding: 10px; 
    background: rgba(0,0,0,0.6); 
    border: 1px solid rgba(255,255,255,0.2); 
    border-radius: 12px; 
    color: #fff; 
    font-size: 13px; 
    resize: vertical; 
    box-sizing: border-box; 
}

.text-edit-modal .preview-area { 
    background: rgba(0,0,0,0.4); 
    border-radius: 12px; 
    padding: 10px; 
    margin: 12px 0; 
    border: 1px dashed rgba(255,215,0,0.3); 
}

.text-edit-modal .preview-label { 
    color: #ffd700; 
    font-size: 11px; 
    margin-bottom: 6px; 
}

.text-edit-modal .preview-content { 
    min-height: 50px; 
    padding: 8px; 
    background: rgba(0,0,0,0.3); 
    border-radius: 8px; 
    white-space: pre-wrap; 
    word-wrap: break-word; 
}

.text-edit-modal .edit-row { 
    margin: 10px 0; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    flex-wrap: wrap; 
}

.text-edit-modal .edit-row label { 
    color: #ddd; 
    font-size: 11px; 
    min-width: 55px; 
}

.text-edit-modal .edit-row select, 
.text-edit-modal .edit-row input[type="number"] { 
    background: rgba(0,0,0,0.5); 
    border: 1px solid rgba(255,255,255,0.2); 
    border-radius: 20px; 
    padding: 5px 10px; 
    color: #fff; 
    font-size: 11px; 
    width: 70px; 
}

.text-edit-modal .edit-row input[type="color"] { 
    width: 35px; 
    height: 35px; 
    border-radius: 50%; 
    border: 2px solid #fff; 
    cursor: pointer; 
}

.text-edit-modal .btn-group { 
    display: flex; 
    gap: 8px; 
    margin-top: 15px; 
    justify-content: flex-end; 
}

.text-edit-modal .btn-group button { 
    padding: 6px 16px; 
    border: none; 
    border-radius: 30px; 
    cursor: pointer; 
    font-size: 11px; 
    transition: transform 0.1s;
}

.text-edit-modal .btn-group button:active {
    transform: scale(0.96);
}

.text-edit-modal .btn-save { 
    background: #ff6600; 
    color: #fff; 
}

.text-edit-modal .btn-cancel { 
    background: #555; 
    color: #fff; 
}

@media (max-width: 768px) {
    .text-edit-modal { 
        width: 95%; 
        padding: 12px; 
    }
    .text-edit-modal h3 { 
        font-size: 14px; 
    }
    .text-edit-modal .edit-row { 
        margin: 8px 0; 
    }
    .text-edit-modal .edit-row label { 
        min-width: 50px; 
        font-size: 10px; 
    }
    .text-edit-modal .edit-row select, 
    .text-edit-modal .edit-row input[type="number"] { 
        width: 65px; 
        padding: 4px 8px; 
        font-size: 10px; 
    }
}

/* ========== 按钮样式 ========== */
.text-add-btn { 
    background: linear-gradient(135deg, #6a3093, #a044ff) !important; 
}

.global-edit-toggle { 
    background: linear-gradient(135deg, #ff9800, #f44336) !important; 
}

.global-edit-toggle.active { 
    background: linear-gradient(135deg, #4caf50, #2e7d32) !important; 
}

/* ========== 游客模式文字点击提示 ========== */
.text-element:not(.edit-mode-enabled) {
    cursor: pointer;
    transition: filter 0.2s;
}

.text-element:not(.edit-mode-enabled):hover {
    filter: brightness(1.05);
}