/* ============================================
   AURAGI STUDIO - 产品配置器样式
   ============================================ */

.customizer-container {
    display: grid;
    grid-template-columns: 3fr 2fr;
    min-height: calc(100vh - 60px);
    margin-top: 60px !important;
    background-color: #faf9f7;
    margin: auto;
    max-width: 1480px;
}

/* 左侧预览区 */
.customizer-preview {
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    background-color: white;
    display: flex;
    flex-direction: column;
    padding: 2rem;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.preview-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c2c2c;
}

.preview-fullscreen {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: #6b6b6b;
    transition: color 0.3s;
}

.preview-fullscreen:hover {
    color: #2c2c2c;
}

.preview-image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background-color: white;
    max-height: 620px;
}

/* 全屏模式样式 */
.preview-image-container:fullscreen {
    background-color: #000;
    max-height: 100vh;
    border-radius: 0;
}

.preview-image-container:-webkit-full-screen {
    background-color: #000;
    max-height: 100vh;
    border-radius: 0;
}

.preview-image-container:-moz-full-screen {
    background-color: #000;
    max-height: 100vh;
    border-radius: 0;
}

.preview-image-container:-ms-fullscreen {
    background-color: #000;
    max-height: 100vh;
    border-radius: 0;
}

/* 缩放控制按钮 */
.zoom-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: row;
    gap: 0.1rem;
    z-index: 20;
    background: rgba(255, 255, 255, 0.95);
    padding: 0.2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.zoom-btn {
    background: white;
    border: 1px solid white;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    transition: all 0.2s;
    width: 35px;
    height: 35px;
}

.zoom-btn:hover {
    background: #f5f5f5;
    color: #2c2c2c;
    border-color: #d0d0d0;
}

.zoom-btn:active {
    transform: scale(0.95);
}

.zoom-btn svg {
    width: 20px;
    height: 20px;
}

/* Canvas 预览层 */
#previewCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* SVG 交互层 */
#previewSVG {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: all;
    z-index: 10;
}

/* 移动端预览图片优化 */
@media (max-width: 768px) {
    #previewCanvas,
    #previewSVG {
        /* 确保预览图片充分利用空间 */
        max-width: 100%;
        max-height: 100%;
    }
    
    .preview-image-container {
        /* 减少最小高度限制，让图片可以更大 */
        min-height: 70vh;
        max-height: 90vh;
    }
}

.preview-overlay {
    pointer-events: all;
}

.preview-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: opacity 0.3s;
}

.preview-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e8e8e8;
    border-top-color: #2c2c2c;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.preview-info {
    margin-top: 1.5rem;
    text-align: center;
}

.color-swatch {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin: 0 auto 0.5rem;
    border: 2px solid #e8e8e8;
}

.preview-hint {
    font-size: 0.9rem;
    color: #6b6b6b;
    font-weight: 300;
}

/* 刺绣控制面板 */
.embroidery-controls {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #f8f8f8;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
    /* 在右侧面板中，让它看起来像是选项卡片的一部分 */
    margin-left: 0;
    margin-right: 0;
}

.embroidery-title {
    font-size: 1rem;
    font-weight: 600;
    color: #2c2c2c;
    margin-bottom: 0.5rem;
}

.embroidery-hint {
    font-size: 0.85rem;
    color: #6b6b6b;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.embroidery-buttons {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.btn-embroidery {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
    border: 1px solid #d0d0d0;
    background-color: white;
    color: #2c2c2c;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-embroidery:hover {
    background-color: #2c2c2c;
    color: white;
    border-color: #2c2c2c;
}

.btn-embroidery svg {
    flex-shrink: 0;
}

.btn-clear {
    background-color: #fee;
    border-color: #fcc;
    color: #c33;
}

.btn-clear:hover {
    background-color: #c33;
    color: white;
    border-color: #c33;
}

.embroidery-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.embroidery-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: white;
    border: 1px solid #e8e8e8;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    transition: background-color 0.2s;
}

.embroidery-item:hover {
    background-color: #f5f5f5;
}

.emb-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.emb-label {
    flex: 1;
    font-size: 0.9rem;
    color: #2c2c2c;
}

.btn-remove-emb {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
}

.btn-remove-emb:hover {
    color: #c33;
}

.empty-message {
    text-align: center;
    color: #999;
    font-size: 0.9rem;
    padding: 1rem;
}

/* 右侧配置面板 */
.customizer-panel {
    padding: 2rem;
    max-height: calc(100vh - 60px);
    background-color: white;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* 允许垂直滚动 */
    overflow-x: hidden; /* 禁止水平滚动 */
    padding-bottom: 200px; /* 为底部固定区域预留滚动空间 */
    -webkit-overflow-scrolling: touch; /* iOS平滑滚动 */
}

.panel-header {
    margin-bottom: 1.5rem;
    position: sticky;
    top: 0;
    z-index: 5;
    background: white;
    padding-bottom: 1rem;
}

.panel-title {
    font-size: 2rem;
    font-weight: 300;
    margin-bottom: 1.5rem;
    color: #2c2c2c;
}

/* 步骤指示器 */
.step-indicators {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.5rem;
    padding: 1rem 0;
    border-top: 1px solid #e8e8e8;
}

.step-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    transition: all 0.3s;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e8e8e8;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.step-dot.active .step-number {
    background: #2c2c2c;
    color: white;
    transform: scale(1.15);
}

.step-dot.completed .step-number {
    background: #4CAF50;
    color: white;
}

.step-label {
    font-size: 0.7rem;
    color: #999;
    text-align: center;
    transition: color 0.3s;
    white-space: nowrap;
}

.step-dot.active .step-label {
    color: #2c2c2c;
    font-weight: 600;
}

.step-connector {
    flex: 1;
    height: 2px;
    background: #e8e8e8;
    margin: 0 0.3rem;
    margin-bottom: 1.5rem;
}

/* 步骤容器 */
.step-container {
    padding: 0 0 1.5rem 0;
    min-height: 400px;
    flex: 1;
    overflow-y: auto;
}

.step-content {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.step-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2c2c2c;
    margin-bottom: 0.5rem;
}

.step-description {
    font-size: 0.9rem;
    color: #6b6b6b;
    margin-bottom: 2rem;
}

.step-options {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-bottom: 200px;
}

/* 最终确认页面 */
.final-summary {
    padding: 1rem 0;
}

.composite-preview {
    margin: 2rem 0;
    text-align: center;
    background: #f8f8f8;
    padding: 2rem;
    border-radius: 8px;
}

.configuration-details {
    margin: 2rem 0;
    padding: 1.5rem;
    background: #f8f8f8;
    border-radius: 8px;
}

.configuration-details h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.config-summary-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.summary-section {
    background: white;
    padding: 1rem;
    border-radius: 6px;
}

.summary-section h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #2c2c2c;
}

.summary-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.summary-section li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9rem;
}

.summary-section li:last-child {
    border-bottom: none;
}

.action-buttons-final {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.action-buttons-final .btn {
    flex: 1;
}

/* 配置选项 */
.customizer-options {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-bottom: 200px;
}

.option-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
}

.option-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.option-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c2c2c;
}

.option-required {
    color: #dc2626;
    font-size: 1rem;
}

.option-description {
    font-size: 0.85rem;
    color: #6b6b6b;
    margin-top: 0.5rem;
}

.option-choices {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
    gap: 0.75rem;
}

.choice-item {
    padding: 8px;
    border: 2px solid #e8e8e8;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.choice-item:hover:not(.disabled) {
    border-color: #2c2c2c;
    transform: translateY(-2px);
}

.choice-item.selected {
    border-color: #2c2c2c;
    background-color: #f5f5f5;
}

.choice-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.choice-name {
    display: block;
    font-weight: 500;
    color: #2c2c2c;
    margin-bottom: 0.25rem;
}

.choice-price {
    display: block;
    font-size: 0.9rem;
    color: #6b6b6b;
}

.choice-description {
    display: block;
    font-size: 0.8rem;
    color: #8b8b8b;
    margin-top: 0.25rem;
}

.color-swatch {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin: 0 auto 0.5rem;
    border: 2px solid #e8e8e8;
}

/* 数量选择器 */
.quantity-selector {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
    margin-top: 1rem;
}

.quantity-btn {
    width: 30px;
    height: 30px;
    border: 1.5px solid #2c2c2c;
    background: white;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.quantity-btn:hover {
    background: #2c2c2c;
    color: white;
}

.quantity-input {
    width: 60px;
    height: 40px;
    text-align: center;
    font-size: 1rem;
    font-weight: 500;
    border: 2px solid #e8e8e8;
    border-radius: 8px;
    background: #f5f5f5;
    /* 隐藏input内的上下按钮（spinner） */
    -moz-appearance: textfield;
    appearance: textfield;
}

.quantity-input::-webkit-outer-spin-button,
.quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.quantity-input:focus {
    outline: none;
    border-color: #2c2c2c;
}

/* 底部固定区域 */
.customizer-footer {
    position: fixed;
    bottom: 0;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1480px; /* 与页面内容宽度保持一致 */
    background: white;
    border-top: 1px solid #e8e8e8;
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: end;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
    z-index: 100;
}

/* 小屏幕下让底部条适配全宽 */
@media (max-width: 1280px) {
    .customizer-footer {
        left: 0;
        transform: none;
        width: 100%;
        max-width: 100%;
    }
}

.price-summary {
    display: flex;
    flex-direction: column;
}

.price-breakdown {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
}

.price-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.price-line .price-label {
    color: #6b6b6b;
    font-size: 0.9rem;
}

.price-line .price-amount {
    color: #2c2c2c;
    font-weight: 500;
}

.price-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.price-total .price-label {
    font-size: 1rem;
    color: #2c2c2c;
    font-weight: 600;
}

.price-value {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c2c2c;
}

.action-buttons {
    display: flex;
    gap: 1rem;
}

/* 配置摘要侧边栏 */
.summary-toggle {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: #2c2c2c;
    color: white;
    border: none;
    padding: 1rem 0.5rem;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    z-index: 99;
}

.summary-sidebar {
    position: fixed;
    right: -400px;
    top: 60px;
    width: 400px;
    height: calc(100vh - 60px);
    background: white;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    overflow-y: auto;
    z-index: 101;
}

.summary-sidebar.active {
    right: 0;
}

.summary-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #6b6b6b;
    line-height: 1;
}

.summary-content {
    padding: 1.5rem;
}

.summary-item {
    padding: 1rem 0;
    border-bottom: 1px solid #f5f5f5;
}

.summary-item-label {
    font-size: 0.9rem;
    color: #6b6b6b;
    margin-bottom: 0.25rem;
}

.summary-item-value {
    font-weight: 500;
    color: #2c2c2c;
}

.summary-item-price {
    font-size: 0.9rem;
    color: #2c2c2c;
    margin-top: 0.25rem;
}

.summary-total {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid #2c2c2c;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-total-label {
    font-size: 1.2rem;
    font-weight: 600;
}

.summary-total-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2c2c2c;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .customizer-container {
        grid-template-columns: 1fr;
        background-color: #faf9f7; /* 确保容器有背景 */
    }
    
    .customizer-preview {
        position: relative;
        height: 60vh;
        top: 0;
        background-color: #faf9f7; /* 添加背景色 */
    }
    
    .preview-image-container {
        background-color: #faf9f7; /* 确保预览区域有背景 */
    }
    
    .customizer-footer {
        width: 100%;
    }
    
    .summary-toggle {
        display: flex;
    }
    
    .embroidery-controls {
        margin-top: 1rem;
    }
    
    .embroidery-buttons {
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    /* 移动端：改变布局为垂直排列 */
    .customizer-container {
        display: flex;
        flex-direction: column;
        margin-top: 60px !important; /* page header 高度 */
        min-height: calc(100vh - 60px);
        max-height: calc(100vh - 60px); /* 限制最大高度，确保可以滚动 */
        position: relative;
        overflow-y: auto; /* 整个容器可滚动 */
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0; /* 移除padding，让footer自然显示 */
    }
    
    /* panel-header 固定在顶部（page header 下面） */
    .panel-header {
        position: fixed;
        top: 60px; /* page header 下面 */
        left: 0;
        right: 0;
        z-index: 100;
        margin: 0;
        padding: 1rem;
        background: white;
        width: 100%;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    /* 为固定的 panel-header 预留空间，让内容从它下面开始 */
    .customizer-panel::before {
        content: '';
        display: block;
        height: 140px; /* 为固定的 panel-header 预留空间 */
    }
    
    .customizer-panel {
        padding: 0;
        padding-bottom: 300px; /* 增加底部padding，确保footer不遮挡内容 */
        background-color: #faf9f7;
        overflow: visible; /* 移除独立滚动，让容器统一滚动 */
        position: relative; /* 确保正常文档流 */
    }
    
    .step-container {
        overflow: visible; /* 移除独立滚动 */
        padding-bottom: 3rem; /* 增加步骤容器的底部padding */
    }
    
    /* preview 显示在 panel 内容之前，一起滚动 */
    .customizer-preview {
        position: relative !important; /* 覆盖桌面端的 sticky 定位 */
        top: auto !important; /* 移除 sticky 的 top 值 */
        height: auto !important; /* 移除固定高度 */
        padding: 0.5rem;
        padding-top: 0.5rem;
        background-color: #faf9f7;
        order: -1; /* preview 显示在 panel 内容之前 */
        margin-top: 140px; /* 为固定的 panel-header 预留空间，避免被遮挡 */
        overflow: visible; /* 移除独立滚动 */
        display: flex;
        flex-direction: column;
    }
    
    .preview-header {
        display: none; /* 移动端隐藏预览头部 */
    }
    
    .preview-info {
        display: none; /* 移动端隐藏预览信息 */
    }
    
    .preview-image-container {
        padding: 0;
        margin-top: 52px;
        background-color: #faf9f7;
        min-height: 40vh;
        max-height: 50vh;
        flex-shrink: 0; /* 防止被压缩 */
    }
    
    .step-container {
        padding: 1rem;
        padding-bottom: 2rem;
    }
    
    .option-choices {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 0.5rem;
    }
    
    .customizer-footer {
        position: fixed; /* 确保footer固定在底部 */
        bottom: 0;
        left: 0;
        right: 0;
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
        z-index: 99; /* 确保在内容之上，但低于panel-header */
        background: white;
        box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .action-buttons {
        width: 100%;
    }
    
    .action-buttons .btn {
        flex: 1;
    }
    
    .embroidery-controls {
        padding: 0.75rem;
    }
    
    .embroidery-title {
        font-size: 0.9rem;
    }
    
    .embroidery-hint {
        font-size: 0.8rem;
    }
    
    .embroidery-buttons {
        flex-direction: column;
    }
    
    .btn-embroidery {
        width: 100%;
        justify-content: center;
    }
    
    .embroidery-list {
        max-height: 150px;
    }
    
    .summary-sidebar {
        width: 100%;
        right: -100%;
    }
}

/* 加载模态框样式 */
.loading-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.loading-modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 2.5rem 3rem;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-width: 90%;
    z-index: 10001;
}

.loader-spinner-large {
    width: 48px;
    height: 48px;
    border: 4px solid #e8e8e8;
    border-top-color: #2c2c2c;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

.loading-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c2c2c;
    margin: 0 0 0.5rem 0;
}

.loading-subtext {
    font-size: 0.9rem;
    color: #6b6b6b;
    margin: 0;
}

@media (max-width: 768px) {
    .loading-modal-content {
        padding: 2rem 1.5rem;
    }
    
    .loader-spinner-large {
        width: 40px;
        height: 40px;
        border-width: 3px;
    }
    
    .loading-text {
        font-size: 1rem;
    }
    
    .loading-subtext {
        font-size: 0.85rem;
    }
}

