/*
 * style.css — 移动端样式
 *
 * 设计原则：
 * - 宽度适配 320px ~ 428px（主流手机屏幕）
 * - 使用原生系统字体栈，加载速度快
 * - 触控友好：最小点击区域 44px
 * - 品牌色 #1a73e8（Google Blue 风格）
 */

/* ===== 基础重置 ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #f5f7fa;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== 应用容器：居中显示，限制最大宽度 ===== */
.app-container {
    max-width: 428px;
    min-width: 320px;
    margin: 0 auto;
    background: #ffffff;
    min-height: 100vh;
    position: relative;
    /* 底部留出价格栏的高度，防止内容被遮挡 */
    padding-bottom: 160px;
}

/* ===== 顶部标题栏 ===== */
.app-header {
    background: linear-gradient(135deg, #1a73e8, #1557b0);
    color: white;
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.3);
}

.app-header h1 {
    font-size: 18px;
    font-weight: 600;
    text-align: center;
}

/* ===== 选择区 ===== */
.selection-area {
    padding: 16px;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
}

.form-group {
    margin-bottom: 12px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 14px;
    color: #666;
    margin-bottom: 4px;
    font-weight: 500;
}

select {
    width: 100%;
    height: 44px;           /* 触控友好最小高度 */
    font-size: 16px;        /* 防止 iOS 自动缩放 */
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0 12px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 12px center;
    appearance: none;
    -webkit-appearance: none;
    color: #333;
    cursor: pointer;
}

select:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

select:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.15);
}

/* ===== BOM 配置区 ===== */
.bom-area {
    padding: 0 16px;
}

/* 空状态提示 */
.empty-state {
    text-align: center;
    color: #999;
    font-size: 15px;
    padding: 40px 0;
}

/* 错误状态提示 */
.error-state {
    text-align: center;
    color: #e53935;
    font-size: 14px;
    padding: 20px 0;
    background: #fff5f5;
    border-radius: 8px;
    margin: 12px 0;
}

/* 分组 fieldset */
fieldset {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    background: #fafbfc;
}

fieldset legend {
    font-weight: 600;
    font-size: 15px;
    color: #333;
    padding: 0 8px;
}

/* 主产品信息卡片 */
.main-product-card {
    background: #f0f7ff;
    border: 1px solid #cce0ff;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

.main-product-card .product-name {
    font-size: 16px;
    font-weight: 600;
    color: #1a73e8;
    margin-bottom: 4px;
}

.main-product-card .product-code {
    font-size: 13px;
    color: #888;
    margin-bottom: 6px;
}

.main-product-card .price-info {
    font-size: 14px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 18px;
    font-weight: 600;
    color: #e74c3c;
}
.main-product-card .price-label {
    font-size: 13px;
    font-weight: 400;
    color: #888;
}

/* 单个选项行 */
.option-item {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
    min-height: 44px;
}

.option-item:last-child {
    border-bottom: none;
}

.option-item input[type="radio"],
.option-item input[type="checkbox"] {
    margin-right: 10px;
    margin-top: 2px;
    transform: scale(1.2);
    flex-shrink: 0;
    accent-color: #1a73e8;
}

.option-item label {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    min-width: 0;
}

/* BOM 描述文字：默认一行截断，点击展开 */
.item-desc {
    width: 100%;
    font-size: 12px;
    color: #888;
    line-height: 1.5;
    margin: 4px 0 0 26px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: pointer;
}
.item-desc.expanded {
    -webkit-line-clamp: unset;
}

.option-name {
    flex: 1;
    font-size: 16px;
    color: #333;
}

.option-detail {
    font-size: 12px;
    color: #999;
    display: block;
}

.option-price {
    font-size: 14px;
    color: #e65100;
    font-weight: 500;
    white-space: nowrap;
    margin-left: 8px;
}

/* 必选项标记 */
.required-badge {
    display: inline-block;
    background: #e53935;
    color: #fff;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 6px;
    vertical-align: middle;
}

/* ===== 加载动画 ===== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 0;
    color: #666;
    font-size: 14px;
    gap: 12px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e0e0;
    border-top: 3px solid #1a73e8;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== 底部价格栏（sticky 吸底） ===== */
.price-footer {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 428px;
    min-width: 320px;
    background: #ffffff;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    padding: 16px;
    z-index: 100;
}

.price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 16px;
}

.price-row span:first-child {
    color: #666;
}

.price-row span:last-child {
    font-weight: 700;
    font-size: 18px;
    color: #e65100;
}

/* 导出按钮 */
.btn-export {
    width: 100%;
    height: 48px;
    background: #1a73e8;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
    transition: background 0.2s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.btn-export:active:not(:disabled) {
    background: #1557b0;
    transform: scale(0.98);
}

.btn-export:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ===== 响应式微调 ===== */

/* 小屏手机 (320-359px)：适当缩小文字 */
@media (max-width: 359px) {
    .app-header h1 { font-size: 16px; }
    .app-header { padding: 12px 16px; }
    select { height: 40px; font-size: 14px; }
    .option-name { font-size: 14px; }
    .btn-export { height: 44px; font-size: 14px; }
}

/* 大屏手机 / 平板：居中留白 */
@media (min-width: 429px) {
    .app-container {
        border-left: 1px solid #e0e0e0;
        border-right: 1px solid #e0e0e0;
    }
}


/* 提示条 */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #323232;
    color: #fff;
    padding: 10px 24px;
    border-radius: 24px;
    font-size: 14px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
    white-space: nowrap;
}
.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 数量提示 */
.qty-hint {
    font-size: 12px;
    color: #999;
    margin-left: 4px;
}

/* ===== 购物车 — 加入清单按钮 ===== */
.cart-add-area {
    padding: 0 16px 12px;
}
.btn-add-cart {
    width: 100%;
    height: 48px;
    background: #34a853;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.btn-add-cart:active {
    background: #2d9249;
    transform: scale(0.98);
}

/* ===== 购物车 — 清单面板 ===== */
.cart-panel {
    margin: 0 16px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fafbfc;
    overflow: hidden;
}
.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f0f7ff;
    border-bottom: 1px solid #e0e0e0;
    font-weight: 600;
    font-size: 15px;
}
.btn-clear {
    background: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px 12px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
}
.cart-items {
    padding: 0;
}
.cart-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
}
.cart-item:last-child {
    border-bottom: none;
}
.cart-item-info {
    flex: 1;
}
.cart-item-code {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}
.cart-item-price {
    font-size: 14px;
    color: #e65100;
    margin-top: 2px;
}
.btn-remove-item {
    background: none;
    border: none;
    color: #999;
    font-size: 16px;
    padding: 4px 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.cart-total-row {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    border-top: 1px solid #e0e0e0;
    font-weight: 600;
    font-size: 16px;
}
.btn-export-all {
    width: 100%;
    height: 48px;
    background: #1a73e8;
    color: #fff;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}
.btn-export-all:disabled {
    background: #ccc;
    cursor: not-allowed;
}
.btn-export-all:active:not(:disabled) {
    background: #1557b0;
}

/* ===== 合同按钮 ===== */
.btn-contract {
    width: 100%;
    height: 44px;
    background: #ff6d00;
    color: #fff;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.btn-contract:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ===== 弹窗 ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-content {
    background: #fff;
    border-radius: 12px;
    width: 92%;
    max-width: 420px;
    max-height: 85vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
    font-weight: 600;
    font-size: 16px;
}
.btn-close-modal {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
}
.modal-body {
    padding: 16px;
}
.cust-input {
    width: 100%;
    height: 40px;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0 10px;
    font-size: 14px;
    margin-bottom: 8px;
    box-sizing: border-box;
}
.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}
.btn-secondary {
    flex: 1;
    height: 40px;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}
.btn-primary {
    flex: 1;
    height: 40px;
    border: none;
    background: #1a73e8;
    color: #fff;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}
.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}
.btn-full {
    width: 100%;
    margin-top: 12px;
}
.btn-link {
    background: none;
    border: none;
    color: #1a73e8;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 0;
}

/* 合同价格预览 */
.contract-price-area {
    background: #fafbfc;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px;
    margin: 12px 0;
}
.contract-price-header {
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
}
.contract-price-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}
.contract-price-item .price-input {
    width: 80px;
    text-align: right;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 14px;
}
.contract-total {
    text-align: right;
    font-weight: 600;
    margin-top: 8px;
    font-size: 15px;
}
