/* FitMax 3D Configurator - Public Styles */

/* ── "View in 3D" trigger button ─────────────────── */
.fitmax3d-entry {
    margin: 12px 0;
}

.fitmax3d-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #111;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.fitmax3d-open-btn:hover {
    background: #333;
}

.fitmax3d-open-btn:active {
    transform: scale(0.98);
}

/* ── Modal ───────────────────────────────────────── */
.fitmax3d-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    align-items: center;
    justify-content: center;
}

.fitmax3d-modal.is-open {
    display: flex;
}

.fitmax3d-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
}

.fitmax3d-modal-dialog {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: #fff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.fitmax3d-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    z-index: 20;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fitmax3d-modal-close:hover {
    background: rgba(0, 0, 0, 0.85);
    transform: rotate(90deg);
}

.fitmax3d-app {
    display: flex;
    gap: 24px;
    padding: 24px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    flex-wrap: nowrap;
    overflow: hidden;
    height: 100%;
    box-sizing: border-box;
}

.fitmax3d-viewer {
    flex: 1 1 75%;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.fitmax3d-canvas-wrap {
    position: relative;
    background: #f5f5f5;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    /* 尺寸由 JS 动态计算，始终保持 4:3 且填满模型区 */
}

.fitmax3d-canvas-wrap canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

.fitmax3d-loading {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(245,245,245,0.95);
    z-index: 10;
    color: #666;
    font-size: 14px;
    gap: 12px;
}

.fitmax3d-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e0e0e0;
    border-top-color: #ffcc00;
    border-radius: 50%;
    animation: fitmax3d-spin 0.8s linear infinite;
}

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

.fitmax3d-error {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,240,240,0.95);
    z-index: 10;
    color: #b20000;
    font-size: 14px;
}

.fitmax3d-views {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    z-index: 5;
}

.fitmax3d-views button {
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.2s;
}

.fitmax3d-views button:hover,
.fitmax3d-views button.active {
    background: rgba(0,0,0,0.8);
}

/* Panel */
.fitmax3d-panel {
    flex: 1 1 25%;
    min-width: 240px;
    max-width: 100%;
    overflow-y: auto;
}

/* Parts list (按材质分组) */
.fitmax3d-parts-section {
    margin-bottom: 20px;
}

.fitmax3d-parts-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 40vh;
    overflow-y: auto;
    padding-right: 4px;
}

.fitmax3d-parts-empty {
    color: #999;
    font-size: 13px;
}

.fitmax3d-part-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #f9f9f9;
    border: 1px solid #e8e8e8;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s, border-color 0.15s;
    user-select: none;
}

.fitmax3d-part-item:hover {
    background: #f0f0f0;
    border-color: #d5d5d5;
}

.fitmax3d-part-check {
    width: 16px;
    height: 16px;
    accent-color: #111;
    flex-shrink: 0;
}

.fitmax3d-part-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #333;
}

.fitmax3d-part-count {
    color: #999;
    font-size: 11px;
    flex-shrink: 0;
}

/* 主体板块（右侧单独展示，不可取消） */
.fitmax3d-main-section {
    margin-bottom: 20px;
}

.fitmax3d-main-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #fff8e1;
    border: 1px solid #ffcc00;
    border-radius: 6px;
    font-size: 13px;
}

.fitmax3d-main-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #ffcc00;
    color: #000;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.fitmax3d-main-name {
    font-weight: 600;
    color: #111;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.fitmax3d-group-title {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Color swatches */
.fitmax3d-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.fitmax3d-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 4px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 56px;
}

.fitmax3d-swatch:hover {
    border-color: #999;
}

.fitmax3d-swatch.swatch-selected {
    border-color: #ffcc00;
    box-shadow: 0 0 0 2px rgba(255,204,0,0.3);
}

.fitmax3d-swatch span {
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.1);
}

.fitmax3d-swatch img {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    border: 1px solid rgba(0,0,0,0.1);
}

.fitmax3d-swatch small {
    font-size: 10px;
    color: #666;
    text-align: center;
    word-break: break-word;
    max-width: 52px;
}

/* Toggles */
.fitmax3d-toggles {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fitmax3d-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s;
}

.fitmax3d-toggle:hover {
    background: #f0f0f0;
}

.fitmax3d-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #ffcc00;
}

.fitmax3d-toggle small {
    color: #999;
    margin-left: auto;
}

/* Summary */
.fitmax3d-summary {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}

.fitmax3d-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.fitmax3d-price-label {
    font-size: 16px;
    font-weight: 600;
}

.fitmax3d-price {
    font-size: 22px;
    font-weight: 700;
    color: #333;
}

.fitmax3d-add-to-cart {
    width: 100%;
    padding: 14px;
    background: #ffcc00;
    color: #000;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    text-transform: uppercase;
}

.fitmax3d-add-to-cart:hover {
    background: #e6b800;
}

.fitmax3d-add-to-cart:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.fitmax3d-cart-msg {
    margin-top: 10px;
    text-align: center;
    font-size: 13px;
    min-height: 20px;
}

.fitmax3d-cart-msg.success {
    color: #00a32a;
}

.fitmax3d-cart-msg.error {
    color: #b20000;
}

/* Mobile */
@media (max-width: 768px) {
    .fitmax3d-app {
        flex-direction: column;
        overflow-y: auto;
    }
    .fitmax3d-viewer,
    .fitmax3d-panel {
        max-width: 100%;
    }
    .fitmax3d-viewer {
        flex: 0 0 55%;
    }
}
