/* --- 编辑器页面专属样式 --- */
body {
    /* 防止在编辑器页面出现主滚动条 */
    overflow: hidden;
}

.editor-header {
    position: static; /* 覆盖首页的 sticky 效果 */
}

.editor-actions {
    display: flex;
    gap: 1rem;
}

.editor-container {
    display: flex;
    height: calc(100vh - 71px); /* 减去header的高度和1px边框 */
    width: 100%;
}

/* --- 左右侧面板通用样式 --- */
.right-panel {
    width: 450px;
    background-color: var(--bg-color);
    border-left: 1px solid var(--border-color);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    display: none; /* 默认隐藏 */
}

.panel-header {
    font-size: 1.1rem;
    font-weight: 600;
    padding-bottom: 0.75rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

/* --- 中间画布区域 --- */
.canvas-container {
    flex-grow: 1;
    background-color: #f1f5f9; /* 画布外的背景色 */
    padding: 2rem; /* 在容器上添加内边距 */
    display: flex; /* 让容器成为flexbox */
    align-items: center; /* 垂直居中所有子元素 */
    gap: 2rem; /* 控制子元素之间的间距 */
    overflow-x: auto;
}

.artboard-strip {
    display: flex;
    align-items: center;
    gap: 2rem;
    /* 移除内边距和外边距，交给父容器控制 */
}

.artboard-strip > .canvas-container {
    border-radius: 16px; /* 保持圆角 */
    transition: all 0.2s ease-in-out;
    outline: 2px solid transparent; /* 使用outline代替border */
    outline-offset: 4px; /* 让描边和画板之间有一点距离 */
}

.artboard-strip > .canvas-container.is-active {
    outline-color: #4f46e5; /* 激活时只改变颜色，不影响布局 */
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2); /* 可以保留阴影效果 */
}

/* Fabric.js生成的canvas元素会有一个wrapper */
.canvas-wrapper {
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border-radius: 20px; /* 用户要求的圆角 */
    overflow: hidden; /* 关键：让圆角生效 */
}

/* --- 新增画板占位符 --- */
.add-artboard-placeholder {
    width: 350px;
    height: 760px;
    border: 2px dashed var(--border-color);
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0; /* 防止容器在 flex 布局中被压缩 */
}

.btn-add-artboard {
    height: 50px;
    width: 50px;
    border-radius: 50%;
    border: none;
    background-color: var(--secondary-color);
    color: var(--border-color);
    font-size: 2rem;
    cursor: pointer;
    box-shadow: none;
    transition: all 0.2s ease-in-out;
}

.add-artboard-placeholder:hover {
    border-color: var(--primary-color);
}

.add-artboard-placeholder:hover .btn-add-artboard {
    background-color: var(--primary-color);
    color: white;
    transform: scale(1.1);
}

.btn-full-width {
    width: 100%;
    text-align: center;
}

/* --- 右侧属性检查器 --- */
.property-group {
    margin-bottom: 1.5rem;
}

.property-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.property-group input,
.property-group select,
.property-group textarea {
    width: 100%;
    padding: 0.5rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    background-color: var(--bg-color); /* 确保背景色统一 */
    color: var(--text-color); /* 确保文字颜色统一 */
}

.property-group select {
    appearance: none; /* 移除默认下拉箭头 */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem; /* 为自定义箭头留出空间 */
}

.property-group textarea {
    resize: vertical;
}

.property-group hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1.5rem 0;
}

/* --- 美化原生颜色选择器 --- */
input[type="color"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    
    width: 100%;
    height: 38px; /* 与其他输入框高度保持一致 */
    padding: 0;
    border: none; /* 移除 input 本身的边框 */
    background-color: transparent;
    cursor: pointer;
}

/* For Webkit browsers (Chrome, Safari, Edge) */
input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0; /* 移除包裹元素的内边距 */
}

input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--border-color); /* 为颜色块添加边框 */
    border-radius: var(--border-radius); /* 为颜色块添加圆角 */
}

/* For Firefox */
input[type="color"]::-moz-color-swatch {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

/* --- 背景模式选择器样式 --- */
.background-mode-selector {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.background-mode-selector input[type="radio"] {
    margin-right: 0.3rem;
}

.background-mode-selector label {
    margin-bottom: 0;
    cursor: pointer;
    font-weight: normal;
}

/* --- 渐变预设样式 --- */
.gradient-presets {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.gradient-preset {
    height: 60px;
    border-radius: var(--border-radius);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.gradient-preset:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.gradient-preset.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* --- 图片预设样式 --- */
.image-presets {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.image-preset {
    height: 60px;
    border-radius: var(--border-radius);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.image-preset:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.image-preset.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* 手机边框选择器样式 */
.frame-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.frame-option {
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 12px 6px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    background-color: #f8f9fa;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 40px; /* Set a fixed height */
}

.frame-option .frame-name {
    font-size: 13px;
    font-weight: 500;
    color: #495057;
}

.frame-option:hover {
    background-color: #e9ecef;
    border-color: #adb5bd;
}

.frame-option.active {
    background-color: #4f46e5;
    border-color: #4f46e5;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.frame-option.active .frame-name {
    color: #ffffff;
    font-weight: 600;
}

/* 下载功能样式 */
.download-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.download-menu {
    background: white;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 500px;
    width: 90vw;
    max-height: 90vh;
    overflow: hidden;
}

.download-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

.download-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: #1f2937;
    font-weight: 600;
}

.download-content {
    padding: 2rem;
    max-height: 60vh;
    overflow-y: auto;
}

.download-section {
    margin-bottom: 2rem;
}

.download-section:last-child {
    margin-bottom: 0;
}

.download-section h4 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: #374151;
    font-weight: 600;
}

.download-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.download-option {
    display: flex;
    align-items: flex-start;
    padding: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.download-option:hover {
    border-color: #d1d5db;
    background: #f9fafb;
}

.download-option input[type="radio"] {
    margin: 0 0.75rem 0 0;
    flex-shrink: 0;
}

.download-option input[type="radio"]:checked + span {
    color: #6366f1;
    font-weight: 600;
}

.download-option span {
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.25rem;
}

.download-option small {
    display: block;
    color: #6b7280;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.quality-selector {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.quality-selector label {
    font-weight: 500;
    color: #374151;
}

#quality-value {
    color: #6366f1;
    font-weight: 600;
}

#quality-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
}

#quality-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #6366f1;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#quality-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #6366f1;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.download-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem 2rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.download-footer .btn {
    min-width: 100px;
}

/* 进度对话框样式 */
.progress-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
}

.progress-dialog {
    background: white;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 2rem;
    text-align: center;
    min-width: 300px;
}

.progress-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.progress-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.progress-message {
    margin: 0;
    color: #374151;
    font-weight: 500;
}

/* 成功提示样式 */
.download-toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: white;
    border: 1px solid #d1fae5;
    border-left: 4px solid #10b981;
    border-radius: 8px;
    box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.1);
    padding: 1rem 1.5rem;
    z-index: 10002;
    animation: slideInRight 0.3s ease-out;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.toast-icon {
    width: 24px;
    height: 24px;
    background: #10b981;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.download-toast span {
    color: #065f46;
    font-weight: 500;
}

.toast-fadeout {
    animation: fadeOut 0.3s ease-out forwards;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .download-menu {
        width: 95vw;
        margin: 1rem;
    }
    
    .download-header {
        padding: 1rem 1.5rem;
    }
    
    .download-content {
        padding: 1.5rem;
    }
    
    .download-footer {
        padding: 1rem 1.5rem;
        flex-direction: column;
    }
    
    .download-footer .btn {
        width: 100%;
    }
    
    .download-toast {
        top: 1rem;
        right: 1rem;
        left: 1rem;
        width: auto;
    }
}

/* Segmented Control for Background Mode */
.segmented-control {
    display: flex;
    background-color: #e9ecef; /* A light grey background for the container */
    border-radius: 8px;
    padding: 3px;
    border: 1px solid #dee2e6;
    /* margin-top: 8px; */ /* Removed to fix spacing issue */
}

.segmented-control label {
    flex: 1;
    position: relative;
    text-align: center;
    margin: 0; /* Reset any unwanted default or inherited margin */
}

.segmented-control input[type="radio"] {
    /* Hide the actual radio button */
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.segmented-control span {
    display: flex; /* Use Flexbox for perfect centering */
    align-items: center; /* Vertical centering */
    justify-content: center; /* Horizontal centering */
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 500;
    color: #495057; /* Standard text color */
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    user-select: none; /* Prevent text selection on click */
}

.segmented-control input[type="radio"]:checked + span {
    background-color: #ffffff; /* White background for selected item */
    color: #212529; /* Darker text for selected item */
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04); /* Subtle shadow for depth */
}

.property-group > label.group-label {
    font-weight: 600;
    color: #343a40;
    font-size: 14px;
    display: block; /* Ensure it's a block-level element for margin to apply correctly */
    margin-bottom: 8px; /* Added to create consistent spacing */
} 