/**
 * Custom Product Options - Frontend Styles
 */

/* 主容器 */
.cpo-custom-options-wrapper {
    margin: 20px 0;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

/* 区块样式 */
.cpo-section {
    margin-bottom: 25px;
    padding: 15px;
    background: #ffffff;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.cpo-section-title {
    margin: 0 0 15px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #2271b1;
    padding-bottom: 8px;
}

/* 变体选择 */
.cpo-variation-select {
    margin-bottom: 15px;
}

.cpo-variation-select label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.cpo-size-select {
    width: 100%;
    max-width: 300px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.cpo-stock-info {
    margin-top: 10px;
    padding: 8px;
    background: #e7f7e7;
    border-radius: 4px;
}

.cpo-stock-status {
    font-weight: 500;
    color: #2e7d32;
}

.cpo-stock-status.out-of-stock {
    background: #fdecea;
    color: #c62828;
}

/* 选项网格 */
.cpo-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 5px;
}

/* 滚动条样式优化 */
.cpo-options-grid::-webkit-scrollbar {
    width: 8px;
}

.cpo-options-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.cpo-options-grid::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.cpo-options-grid::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.cpo-option-item {
    position: relative;
}

.cpo-option-item input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.cpo-option-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fff;
    text-align: center;
}

.cpo-option-label:hover {
    border-color: #2271b1;
    box-shadow: 0 2px 8px rgba(34,113,177,0.2);
}

.cpo-option-item input[type="radio"]:checked + .cpo-option-label {
    border-color: #2271b1;
    background: #e7f3ff;
    box-shadow: 0 2px 8px rgba(34,113,177,0.3);
}

.cpo-option-icon {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin-bottom: 8px;
}

.cpo-option-icon-placeholder {
    width: 60px;
    height: 60px;
    margin-bottom: 8px;
    display: block;
}

.cpo-option-name {
    font-size: 13px;
    line-height: 1.6;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    min-height: calc(13px * 1.6 * 2);
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.cpo-option-price {
    font-size: 12px;
    line-height: 1.6;
    color: #2271b1;
    font-weight: 600;
    min-height: calc(12px * 1.6 * 2);
    display: block;
}

.cpo-tooltip {
    display: inline-block;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    background: #2271b1;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    cursor: help;
    margin-left: 5px;
    position: relative;
}

.cpo-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: #333;
    color: #fff;
    font-size: 12px;
    white-space: normal;
    width: 180px;
    text-align: center;
    border-radius: 4px;
    z-index: 1000;
    margin-bottom: 5px;
}

.cpo-preview-link {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    color: #2271b1;
    text-decoration: none;
}

.cpo-preview-link:hover {
    text-decoration: underline;
}

/* 动态字段 */
.cpo-dynamic-fields-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.cpo-field-group {
    display: flex;
    flex-direction: column;
}

.cpo-field-group label {
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.cpo-field-group input[type="text"],
.cpo-field-group textarea {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

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

/* 价格计算区域 */
.cpo-price-breakdown {
    background: #fff;
    padding: 15px;
    border-radius: 6px;
    border: 2px solid #2271b1;
}

.cpo-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.cpo-price-row:last-child {
    border-bottom: none;
}

.cpo-total-row {
    margin-top: 8px;
    padding-top: 12px;
    border-top: 2px solid #333;
}

.cpo-price-label {
    font-size: 14px;
    color: #666;
}

.cpo-price-value {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.cpo-total-row .cpo-price-label,
.cpo-total-row .cpo-price-value {
    font-size: 18px;
    color: #2271b1;
}

/* BUY NOW 按钮 */
.cpo-buy-now-wrapper {
    margin-top: 20px;
}

.cpo-buy-now-button {
    width: 100%;
    padding: 16px 32px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cpo-buy-now-button:hover {
    background: #1a5a8e;
    box-shadow: 0 4px 12px rgba(34,113,177,0.3);
}

.cpo-buy-now-button:disabled,
.cpo-buy-now-button.disabled {
    background: #ccc !important;
    cursor: not-allowed !important;
    opacity: 0.6;
}

.cpo-error-message {
    padding: 10px;
    background: #fdecea;
    color: #c62828;
    border-radius: 4px;
    font-size: 14px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .cpo-options-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
    
    .cpo-option-icon {
        width: 50px;
        height: 50px;
    }
    
    .cpo-section-title {
        font-size: 16px;
    }
    
    .cpo-buy-now-button {
        font-size: 16px;
        padding: 14px 24px;
    }
}

/* 订单详情页自定义数据显示 */
.cpo-order-custom-data {
    margin-top: 10px;
    padding: 10px;
    background: #f9f9f9;
    border-left: 3px solid #2271b1;
    font-size: 0.9em;
}

.cpo-order-custom-data > div {
    margin: 5px 0;
}

/* 结账页面自定义数据 */
.cpo-checkout-custom-data {
    margin-top: 8px;
    font-size: 0.85em;
    color: #666;
}

.cpo-checkout-custom-data .cpo-custom-item {
    margin: 3px 0;
}
