* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'Asliya', sans-serif;
    background-color: #f0f0f0;
    touch-action: manipulation;
    -webkit-touch-callout: none; /* 禁止iOS长按菜单 */
    -webkit-user-select: none; /* 禁止选择文本 */
    user-select: none; /* 标准语法 */
}

.editor-container {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* 导出期间图层锁定，防止位移与交互 */
.editor-container.locked-for-export {
    pointer-events: none;
    touch-action: none;
}

.editor-container.locked-for-export .text-box {
    cursor: default;
}

.editor-container.locked-for-export img,
.editor-container.locked-for-export .text-box {
    will-change: auto; /* 禁止不必要的合成层改变 */
}

/* 底层：用户照片层 */
.photo-layer {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
}

#userPhoto {
    max-width: 100%;
    max-height: 100%;
    transition: transform 0.2s ease-out;
}

.photo-placeholder {
    width: 80%;
    height: 60%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    cursor: pointer;
}

.photo-placeholder p {
    font-size: 18px;
    margin-bottom: 15px;
}

#photoInput {
    opacity: 0;
    position: absolute;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* 中层：模板图层 */
.template-layer {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 20;
    pointer-events: none;
}

.template-layer img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 顶层：文字编辑和控制界面 */
.control-layer {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: 30;
    pointer-events: none;
}

/* 文本框样式 - 修改版 */
.text-box {
    position: absolute;
    background-color: transparent;
    min-width: 100px;
    min-height: 40px;
    width: auto;
    color: white;
    font-size: 18px;
    text-align: right; /* 改为右对齐 */
    direction: rtl; /* 设置为从右往左 */
    padding: 10px;
    cursor: move;
    pointer-events: auto;
    z-index: 40;
    border: 2px dashed transparent; /* 默认隐藏边框 */
    border-radius: 5px;
    word-wrap: normal; /* 修改: 不允许长单词换行 */
    white-space: nowrap; /* 修改: 不允许文本换行 */
    max-width: none; /* 修改: 移除最大宽度限制 */
    overflow: visible; /* 修改: 允许文本溢出 */
    overflow-wrap: normal; /* 修改: 不允许长单词换行 */
    -webkit-user-select: text; /* 允许在文本框内选择文本 */
    user-select: text; /* 标准语法 */
    transform-origin: center center; /* 确保从中心缩放 */
    display: flex; /* 确保文本居中 */
    align-items: center; /* 垂直居中 */
    justify-content: flex-end; /* 改为右对齐 */
}

.text-box:focus {
    outline: none;
    border: 2px dashed rgba(255, 255, 255, 0.8);
}

.text-box.active {
    border: 2px dashed rgba(255, 255, 255, 0.8);
}

.text-box.hidden-border {
    border: 2px dashed transparent;
}

/* 文本框工具按钮 - 已移除，保留样式以备后用 */
.text-tools {
    display: none; /* 隐藏工具按钮 */
}

/* 修改控制面板样式 - 圆形按钮 */
.controls-container {
    position: fixed;
    bottom: 10px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: auto;
    z-index: 100;
}

.circular-button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    margin-bottom: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.circular-button:hover {
    background-color: rgba(0, 0, 0, 0.8);
    transform: scale(1.05);
}

.circular-button i {
    font-size: 24px;
}

#toggleControls {
    z-index: 101;
}

.controls {
    display: none;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    padding-bottom: 60px; /* 为主编辑按钮留出空间 */
}

.controls.visible {
    display: flex;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

/* 颜色选择器特殊处理 */
.color-picker-wrapper {
    position: relative;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

input[type="color"] {
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    border: none;
    cursor: pointer;
}

.hidden {
    display: none !important;
}

/* 拖动状态的光标 */
.dragging {
    cursor: grabbing !important;
}

/* 可拖动状态的光标 */
.draggable {
    cursor: grab;
}

/* 改进分享对话框样式 */
.share-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    z-index: 1000;
    max-width: 90%;
    width: 350px;
    text-align: center;
}

.share-dialog h3 {
    margin-bottom: 10px;
    color: #333;
}

.share-dialog p {
    margin-bottom: 15px;
    color: #666;
}

.share-dialog .image-container {
    margin: 10px 0;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    max-height: 50vh;
}

.share-dialog img {
    max-width: 100%;
    display: block;
}

.share-dialog .buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dialog-btn {
    padding: 12px;
    border-radius: 8px;
    background-color: #4a4a4a;
    color: white;
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.dialog-btn:hover {
    background-color: #5a5a5a;
}

.dialog-btn.close-btn {
    background-color: #999;
}

.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 999;
}

/* 图标样式 */
.icon {
    font-size: 24px;
    line-height: 1;
}

/* 响应式调整 */
@media (max-width: 600px) {
    .share-dialog {
        width: 90%;
        padding: 15px;
    }
    
    .dialog-btn {
        padding: 10px;
    }
    
    .text-box {
        font-size: 16px; /* 小屏幕上字体稍小 */
    }

    /* 在小屏幕上的按钮样式 */
    #copyDataUrlBtn, #downloadImageBtn {
        font-size: 14px;
        padding: 6px 8px;
    }
}

/* 对话框按钮样式 */
#copyDataUrlBtn, #downloadImageBtn {
    white-space: nowrap;
    padding: 8px 12px;
    border-radius: 4px;
    background-color: #4a4a4a;
    color: white;
    border: none;
    cursor: pointer;
}

/* 快速输入表单样式 */
.quick-form-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    max-width: 90%;
    width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    display: none;
}

.quick-form-dialog.show {
    display: block;
}

.quick-form-content {
    padding: 0;
}

.quick-form-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 24px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.quick-form-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.close-form-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.close-form-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

#invitationForm {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
    text-align: right;
    direction: rtl;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.generate-btn,
.clear-btn {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.generate-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.clear-btn {
    background-color: #f8f9fa;
    color: #6c757d;
    border: 2px solid #e1e5e9;
}

.clear-btn:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

.form-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
}

.form-overlay.show {
    display: block;
}

/* 响应式调整 */
@media (max-width: 600px) {
    .quick-form-dialog {
        width: 95%;
        margin: 0;
        left: 50%;
        transform: translate(-50%, -50%);
    }
    
    .quick-form-header {
        padding: 16px 20px;
    }
    
    .quick-form-header h3 {
        font-size: 18px;
    }
    
    #invitationForm {
        padding: 20px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .generate-btn,
    .clear-btn {
        width: 100%;
    }
}

/* 隐藏确认对话框的网址显示 */
.confirm-dialog {
    -webkit-appearance: none;
    appearance: none;
}

/* 隐藏浏览器默认的确认对话框样式 */
.confirm-dialog::-webkit-dialog {
    -webkit-appearance: none;
    appearance: none;
}

/* 全局隐藏确认对话框的网址栏 */
.confirm-dialog::before {
    display: none !important;
}

/* 使用JavaScript创建的确认对话框样式 */
.custom-confirm-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1002;
    padding: 20px;
    min-width: 280px;
    text-align: center;
}

.custom-confirm-dialog h3 {
    margin: 0 0 16px 0;
    color: #333;
    font-size: 18px;
}

.custom-confirm-dialog .buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 0;
}

.custom-confirm-dialog button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.custom-confirm-dialog .confirm-btn {
    background-color: #f44336;
    color: white;
}

.custom-confirm-dialog .confirm-btn:hover {
    background-color: #d32f2f;
}

.custom-confirm-dialog .cancel-btn {
    background-color: #9e9e9e;
    color: white;
}

.custom-confirm-dialog .cancel-btn:hover {
    background-color: #757575;
}

/* 自定义提示对话框样式 */
.custom-alert-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 1002;
    padding: 20px;
    min-width: 280px;
    text-align: center;
}

.custom-alert-dialog h3 {
    margin: 0 0 16px 0;
    color: #333;
    font-size: 16px;
}

.custom-alert-dialog .buttons {
    display: flex;
    justify-content: center;
    margin-top: 0;
}

.custom-alert-dialog .ok-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    background-color: #2196f3;
    color: white;
}

.custom-alert-dialog .ok-btn:hover {
    background-color: #1976d2;
}
