* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

ul,li{
    list-style: none;
    cursor: pointer;
}

.controls-panel {
    display: flex;
    width: 325px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    border-right: 1px solid #ddd;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    z-index: 999;
    position: relative;
    transition: transform 0.3s ease;
}

.tab-list{
    width: 50px;
    height: inherit;
    border-right: 1px solid #ddd;
}

.tab-list-li{
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.tab-list-li.active{
    background: #1890FF;
    color: #fff;
    display: flex;
}

.tab-list-title{
    font-size: 12px;
    margin-top: 5px;
    font-weight: 400;
}

.tab-content{
    width: calc(100% - 50px);
    height: inherit;
}

.render-section {
    display: flex;
    justify-content: space-around;
    border-bottom: 1px solid #ddd;
    padding: 6px;
}

.panel-content {
    height: calc(100vh - 60px);
    overflow: auto;
    padding: 0 15px;
    display: none;
}

.panel-content.active {
    display: block;
}

.controls-panel.collapsed {
    transform: translateX(-100%);
}

.panel-section h4 {
    margin: 15px 0;
}

/* 图片库和模板库共用样式 */
.image-library,
.model-library {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.library-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.2s;
}

.library-image:hover {
    transform: scale(1.05);
}

.upload-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-button:hover {
    border-color: #1890FF;
    background: #f9f9f9;
}

.upload-icon {
    font-size: 24px;
    color: #666;
    margin-bottom: 8px;
}

#image-upload {
    display: none;
}

/* 上传图片容器样式 */
.uploaded-images {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.uploaded-image-container {
    position: relative;
    aspect-ratio: 1;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
}

.uploaded-image-container:hover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
}

.uploaded-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 删除按钮样式 */
.delete-button {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(255, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1;
}

.uploaded-image-container:hover .delete-button {
    opacity: 1;
}

.delete-button:hover {
    background: rgba(255, 0, 0, 0.9);
}

/* 折叠按钮样式 */
.collapse-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 60px;
    background: #1890FF;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1000;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.collapse-btn .arrow {
    color: white;
    font-size: 12px;
    transition: transform 0.3s;
}

.collapse-btn:hover {
    background: #1890FF;
}

.collapse-btn.right {
    left: -20px;
    border-radius: 4px 0 0 4px;
}

.controls-panel.collapsed .collapse-btn .arrow {
    transform: rotate(180deg);
}

#controls.collapsed .collapse-btn.right .arrow {
    transform: rotate(180deg);
}

body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    display: flex;
    overflow: hidden;
    background-color: #F2F3F5;
}

.main-content {
    width: calc(100% - 325px);
    position: relative;
    height: 100vh;
}

#controls {
    position: fixed;
    top: 0;
    right: 0;
    width: 250px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    padding: 0 15px 15px;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
    overflow: visible;
    transition: transform 0.3s ease;
}

#controls.collapsed {
    transform: translateX(100%);
}

canvas {
    outline: none;
    cursor: move;
}

#canvas2D {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border: 1px dashed #ccc;
    cursor: pointer;
    overflow: visible;
}
.canvas-container{
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    cursor: pointer;
    overflow: visible;
    z-index: -1;
}

/* Common styles for corner elements */
.lt, .rt, .lb, .rb {
    width: 25px;
    height: 25px;
    position: absolute;
}

/* Individual positioning */
.lt {
    left: -30px;
    top: -30px;
    border-bottom: 2px solid #ccc;
    border-right: 2px solid #ccc;
}

.rt {
    right: -30px;
    top: -30px;
    border-bottom: 2px solid #ccc;
    border-left: 2px solid #ccc;
}

.lb {
    left: -30px;
    bottom: -30px;
    border-top: 2px solid #ccc;
    border-right: 2px solid #ccc;
}

.rb {
    right: -30px;
    bottom: -30px;
    border-top: 2px solid #ccc;
    border-left: 2px solid #ccc;
}


.light-controls {
    display: none;
}

.light-controls.visible {
    display: block;
}

button {
    margin: 5px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    background: #1890FF;
    color: white;
    transition: background 0.3s;
}

button:hover {
    background: #1890FF;
}

input,select{
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    outline: none;
}

.size-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.size-group input{
    flex: 1;
}

.size-group select{
    flex: 1;
}

.opacity-control {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.opacity-control input {
    padding: 0;
}

.color-controls {
    margin: 15px 0;
}

.color-group {
    margin: 15px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.color-group input[type="color"],.color-group input[type="range"] {
    padding: 0;
    cursor: pointer;
}

.color-group input[type="range"] {
    width: 100%;
}

#reset-params,#return-canvas {
    background: #607D8B;
}

#reset-params:hover,#return-canvas:hover {
    background: #455A64;
}

/* 光源控制样式 */
.light-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 15px 0;
}

.light-group input{
    padding: 0;
}

.light-group button{
    margin: 0;
}

.light-switch {
    background: #2196F3;
    margin: 0 15px;
}

.light-switch:hover {
    background: #1976D2;
}

.light-switch.off {
    background: #9E9E9E;
}

.light-switch.off:hover {
    background: #757575;
}

/* 文字控制样式 */
.text-controls {
    margin: 15px 0;
}

.text-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.text-group input {
    padding: 0;
}

#text-color{
    padding: 0;
}

/* 添加禁用状态的样式 */
button:disabled {
    background: #cccccc;
    cursor: not-allowed;
    opacity: 0.7;
}

button:disabled:hover {
    background: #cccccc;
}

/* 其他输入控件的禁用样式 */
input:disabled,
select:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}

/* 添加loading相关样式 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-content {
    background: white;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 0 15px rgba(0,0,0,0.3);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    margin: 0 auto 15px;
    animation: spin 1s linear infinite;
}

.loading-text {
    color: #333;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 材质选择样式 */
.texture-group {
    margin: 15px 0;
}

.texture-options {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    margin: 15px 0;
}

.texture-item {
    margin-bottom: 10px;
    cursor: pointer;
    text-align: center;
    padding: 5px;
    border: 2px solid transparent;
    border-radius: 4px;
    transition: all 0.3s;
}

.texture-item:hover {
    background-color: #f0f0f0;
}

.texture-item.active {
    border-color: #1890FF;
    background-color: rgba(24, 143, 255, 0.1);
}

.texture-preview {
    width: 60px;
    height: 60px;
    border: 1px solid #ccc;
    border-radius: 4px;
    margin-bottom: 5px;
    background-color: #fff;
}

/* 材质预览背景 */
.texture-preview.none {
    background: #fff;
}

.texture-preview.cardboard {
    background: url('../textures/cardboard.png') center/cover;
}

.texture-preview.leather {
    background: url('../textures/leather.png') center/cover;
}

.texture-preview.fabric {
    background: url('../textures/fabric.png') center/cover;
}

.texture-preview.wood {
    background: url('../textures/cow.png') center/cover;
}

.texture-opacity {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.texture-opacity input {
    padding: 0;
}

.blend-mode-control {
    margin-top: 15px;
    display: flex;
    align-items: center;
}

.blend-mode-control label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.blend-mode-control input[type="checkbox"] {
    cursor: pointer;
}

.position-controls,
.size-controls {
    margin-bottom: 15px;
}

.size-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 15px;
}

.fine-tune {
    display: flex;
    gap: 5px;
}

/* 自定义滚动条样式 */
::-webkit-scrollbar {
    width: 0px;
    height: 0px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 添加删除按钮样式 */
.uploaded-image-container {
    position: relative;
    aspect-ratio: 1;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
}

.delete-button {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(255, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1;
}

.uploaded-image-container:hover .delete-button {
    opacity: 1;
}

.delete-button:hover {
    background: rgba(255, 0, 0, 0.9);
}

/* 修改折叠按钮样式 */
.collapse-btn {
    margin: 0;
    position: absolute;
    top: 50%;
    right: -20px;
    transform: translateY(-50%);
    width: 20px;
    height: 60px;
    background: #1890FF;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    padding: 0;
    z-index: 1000;
    transition: background-color 0.3s;
    display: none;
    align-items: center;
    justify-content: center;
}

.collapse-btn .arrow {
    color: white;
    font-size: 12px;
    display: block;
    transition: transform 0.3s;
}

.collapse-btn:hover {
    background: #1890FF;
}

.collapse-btn.right {
    left: -20px;
    border-radius: 4px 0 0 4px;
}

/* 修改箭头旋转逻辑 */
.controls-panel.collapsed .collapse-btn .arrow {
    transform: rotate(180deg);
}

#controls.collapsed .collapse-btn.right .arrow {
    transform: rotate(180deg);
}

.icon-search {
    margin-bottom: 15px;
}

.icon-search input {
    width: -webkit-fill-available;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    outline: none;
}

.icon-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

.icon-tag {
    padding: 4px 8px;
    background: #f0f0f0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
}

.icon-tag:hover {
    background: #e0e0e0;
}

.icon-tag.active {
    background: #1890FF;
    color: white;
}

.icon-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.icon-pagination button {
    padding: 4px 8px;
    margin: 0;
    font-size: 12px;
}

.icon-pagination button:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

#page-info {
    font-size: 12px;
    color: #666;
}

.image-library.loading {
    position: relative;
    min-height: 200px;
}

.image-library.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(0deg);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1890FF;
    border-radius: 50%;
    animation: spin_icon 1s linear infinite;
}

@keyframes spin_icon {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.search-input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.search-input-group input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.search-input-group button {
    font-size: 12px;
    padding: 8px;
    margin: 0;
    white-space: nowrap;
}

.layer-controls {
    margin: 15px 0;
}

.layer-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
    max-height: 200px;
    overflow-y: auto;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: #f5f5f5;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.layer-preview {
    width: 40px;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

.layer-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.layer-info {
    flex-grow: 1;
}

.layer-name {
    font-size: 12px;
    color: #333;
    margin: 0 5px;
}

.layer-controls-buttons {
    display: flex;
    justify-content: space-between;
}

.layer-button {
    padding: 4px 8px;
    font-size: 12px;
    background: #1890FF;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.layer-button:hover {
    background: #1890FF;
}

.layer-button.delete {
    background: #f44336;
}

.layer-button.delete:hover {
    background: #d32f2f;
}

/* 添加文字管理相关样式 */
.text-management {
    margin: 15px 0;
}

.text-management h4 {
    margin: 15px 0;
}

.text-list {
    max-height: 300px;
    overflow-y: auto;
}

.text-item {
    background: #f5f5f5;
    border-radius: 4px;
    padding: 5px;
    margin-bottom: 5px;
}

.text-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.text-item-area {
    font-size: 12px;
    color: #666;
}

.text-item-controls {
    display: flex;
    gap: 4px;
}

.text-item-content {
    margin: 5px 0;
}

.text-item input {
    width: -webkit-fill-available;
    padding: 4px 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.text-item input:focus {
    border-color: #1890FF;
    outline: none;
}

.text-item-button {
    padding: 4px 5px;
    font-size: 12px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.text-item-button.edit {
    background: #2196F3;
}

.text-item-button.delete {
    background: #f44336;
}

.text-item-button:hover {
    opacity: 0.9;
}

/* 添加文字方向选择的样式 */
#text-direction {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 12px;
    cursor: pointer;
}

#text-direction:focus {
    border-color: #0075FF;
    outline: none;
}

/* 添加单选框样式 */
.direction-radio-group {
    display: flex;
    gap: 15px;
}

.radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.radio-label input[type="radio"] {
    margin-right: 5px;
    cursor: pointer;
}

.radio-label span {
    font-size: 12px;
    color: #333;
}

/* 自定义单选框样式 */
.radio-label input[type="radio"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid #0075FF;
    border-radius: 50%;
    outline: none;
    position: relative;
}

.radio-label input[type="radio"]:checked::before {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: #0075FF;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.radio-label:hover input[type="radio"] {
    border-color: #0075FF;
}