/* ============================================
   产品报价表样式
   ============================================ */

.quote-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    height: calc(100vh - 100px);
    overflow: hidden;
}

/* 左侧产品选择区 */
.quote-sidebar {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(to bottom, #f8f9fa, #fff);
}

.sidebar-title {
    font-weight: bold;
    font-size: 14px;
    color: var(--primary-color);
}

.product-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* 4列网格布局 - 改为自适应网格 */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 6px;
}

.product-item {
    padding: 10px 6px;
    background: #f8f9fa;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 1px solid #e0e0e0;
    min-height: 50px;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.product-item:hover {
    background: var(--accent-color);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(52, 152, 219, 0.3);
    border-color: var(--accent-color);
}

.product-item .product-name {
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    padding: 2px;
}

.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--border-color);
    background: linear-gradient(to bottom, #f8f9fa, #fff);
}

.footer-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

.footer-info span:first-child {
    font-weight: 600;
    color: var(--primary-color);
}

.footer-hint {
    font-size: 11px;
    color: #999;
}

/* 历史报价单区域 */
.history-section {
    border-top: 1px solid var(--border-color);
    background: #fff;
    max-height: 200px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.history-header {
    padding: 10px 12px;
    background: linear-gradient(to bottom, #f0f7ff, #fff);
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    font-weight: bold;
    color: var(--primary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.history-item {
    padding: 8px 10px;
    margin-bottom: 6px;
    background: #fafafa;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    border: 1px solid #e8e8e8;
}

.history-item:hover {
    background: #e8f4f8;
    border-color: var(--accent-color);
    transform: translateX(3px);
}

.history-item.active {
    background: #e3f2fd;
    border-color: var(--accent-color);
}

.history-customer {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.history-info {
    display: flex;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 11px;
}

.history-total {
    font-weight: bold;
    color: var(--danger-color);
}

.history-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 12px;
}

/* 快速添加产品区域 */
.quick-add-section {
    border-top: 1px solid var(--border-color);
    background: #fff;
    padding: 10px 12px;
}

.quick-add-header {
    font-size: 13px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.quick-add-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.quick-input {
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    transition: all 0.2s;
}

.quick-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
    outline: none;
}

.quick-input.small {
    flex: 1;
}

.quick-input.tiny {
    width: 50px;
    text-align: center;
}

.quick-add-row .btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* 右侧内容区 */
.quote-content {
    background: #f5f7fa;
    padding: 20px;
    overflow-y: auto;
    border-radius: 8px;
}

/* A4纸张样式 - 横版 */
.a4-paper {
    background: #fff;
    width: 297mm;
    min-height: 210mm;
    padding: 20mm;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    border-radius: 4px;
    margin: 0 auto;
}

.quote-title {
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--primary-color);
    color: var(--primary-color);
}

/* 报价信息区 */
.quote-info {
    margin-bottom: 25px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.info-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 12px;
}

.info-row-4 {
    grid-template-columns: repeat(4, 1fr);
}

.info-row:last-child {
    margin-bottom: 0;
}

.info-item {
    display: flex;
    align-items: center;
}

.info-item label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-right: 8px;
    white-space: nowrap;
    font-weight: 500;
}

.info-item input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 13px;
    transition: all 0.2s;
}

.info-item input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* 报价表格 */
.quote-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.quote-table thead {
    background: linear-gradient(to bottom, #2c3e50, #34495e);
    color: #fff;
}

.quote-table th {
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    border: 1px solid #3d566e;
    font-size: 12px;
}

.quote-table td {
    padding: 4px 6px;
    border: 1px solid var(--border-color);
    vertical-align: middle;
}

.quote-table input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid transparent;
    background: transparent;
    font-size: 12px;
    text-align: center;
    transition: all 0.2s;
}

/* 单位自定义下拉 - 紧凑行距 */
.unit-dropdown {
    position: absolute;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 200px;
    overflow-y: auto;
    z-index: 9999;
    min-width: 70px;
    font-size: 12px;
    padding: 2px 0;
}
.unit-dropdown-item {
    padding: 2px 8px;
    cursor: pointer;
    line-height: 1.3;
    white-space: nowrap;
    font-size: 12px;
}
.unit-dropdown-item:hover {
    background: var(--accent-color);
    color: #fff;
}

/* 隐藏 number 输入框的上下微调箭头（兼容） */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type=number] {
    -moz-appearance: textfield;
}

.quote-table input:focus {
    border-color: var(--accent-color);
    background: #fff;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

.quote-table td:nth-child(2) input,
.quote-table td:nth-child(3) input,
.quote-table td:nth-child(9) input {
    text-align: left;
}

.quote-table td:nth-child(6),
.quote-table td:nth-child(7),
.quote-table td:nth-child(8) {
    font-family: 'Consolas', 'Monaco', monospace;
}

.row-actions {
    display: flex;
    gap: 4px;
    justify-content: center;
    align-items: center;
}

.row-actions button {
    padding: 4px 8px;
    font-size: 11px;
    min-width: 24px;
}

/* 合计区域 */
.quote-totals {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-top: 20px;
    border-top: 2px solid var(--primary-color);
}

.quote-notes {
    flex: 1;
    font-size: 12px;
    color: var(--text-secondary);
}

.notes-title {
    font-weight: bold;
    margin-bottom: 8px;
    color: var(--primary-color);
}

.quote-notes ol {
    padding-left: 20px;
    line-height: 1.8;
}

.quote-notes li {
    margin-bottom: 4px;
}

.totals-section {
    min-width: 280px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.total-row {
    display: flex;
    padding: 8px 15px;
    font-size: 14px;
    align-items: center;
    gap: 6px;
}

.total-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.total-value {
    font-weight: bold;
    font-family: 'Consolas', 'Monaco', monospace;
    margin-left: auto;
}

.total-final {
    font-size: 16px;
    border-top: 2px solid var(--primary-color);
    margin-top: 8px;
    padding-top: 12px;
    background: linear-gradient(to right, #fff, #f0f7ff);
    border-radius: 4px;
}

.total-final .total-label {
    font-size: 18px;
    color: var(--primary-color);
}

.total-final .total-value {
    color: var(--danger-color);
    font-size: 20px;
}

.total-chinese {
    text-align: right;
    padding: 8px 15px;
    font-size: 14px;
    color: var(--success-color);
    font-weight: bold;
    background: #e8f5e9;
    padding: 10px 15px;
    border-radius: 4px;
    margin-top: 10px;
}



/* 添加产品弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: #fff;
    border-radius: 8px;
    width: 480px;
    max-width: 90%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    animation: slideDown 0.3s ease-out;
}

.modal-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to right, #f8f9fa, #fff);
    border-radius: 8px 8px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--primary-color);
}

.modal-header .close {
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
    line-height: 1;
}

.modal-header .close:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 20px;
}

.modal-body .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.modal-body .form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.modal-body input,
.modal-body select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
}

.modal-body input:focus,
.modal-body select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

/* 动画 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* 打印样式 */
@media print {
    header,
    .quote-sidebar,
    .sidebar-footer,
    .row-actions,
    .toolbar,
    .table-actions,
    .history-section,
    .quote-info {
        display: none !important;
    }

    .quote-layout {
        display: block;
        height: auto;
        overflow: visible;
    }

    .quote-content {
        padding: 0;
        background: #fff;
        overflow: visible;
    }

    .a4-paper {
        box-shadow: none;
        padding: 5mm 20mm 20mm 20mm;
        margin: 0;
        width: 297mm;
        min-height: auto !important;
        overflow: visible !important;
    }

    .quote-title {
        margin-top: -10mm;
        margin-bottom: 15px;
    }

    .quote-info {
        margin-bottom: 15px;
    }

    /* 保持公司信息原有结构 */
    .quote-info {
        display: block !important;
    }

    .info-row {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 15px !important;
    }

    .info-row-4 {
        grid-template-columns: repeat(4, 1fr) !important;
    }

    .info-item {
        display: flex !important;
    }

    /* 隐藏表格的操作列（最后一列） */
    .quote-table th:last-child,
    .quote-table td:last-child {
        display: none !important;
    }

    body {
        background: #fff;
        margin: 0;
    }

    @page {
        size: A4 landscape;
        margin: 0;
    }

    /* 减少整体上边距 */
    .quote-title {
        margin-top: -10mm;
        margin-bottom: 15px;
    }

    .quote-info {
        margin-bottom: 15px;
    }

    /* 打印时报价说明的样式 */
    .quote-totals {
        flex-direction: column !important;
        page-break-inside: avoid;
    }

    .totals-section {
        width: 100% !important;
        margin-bottom: 15px !important;
        order: 1 !important;
        page-break-inside: avoid;
    }

    .quote-notes {
        width: 100% !important;
        order: 2 !important;
        page-break-inside: avoid;
    }

    .quote-notes .notes-title {
        margin-bottom: 5px !important;
    }

    .quote-notes ol {
        display: none !important;
    }

    .quote-notes::after {
        content: "本报价单有效期为 7 天；活动前需支付 50% 预付款；如有特殊需求请提前告知；最终价格以实际配置为准。";
        display: block;
        line-height: 1.6;
    }

    /* 避免表格行被分页截断 */
    .quote-table {
        page-break-inside: auto;
    }

    .quote-table thead {
        page-break-after: avoid;
    }

    .quote-table tbody tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .quote-table td,
    .quote-table th {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .totals-section {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .quote-notes {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* PDF分页标记 - 使用div元素强制分页 */
    .pdf-page-break-marker {
        display: block;
        page-break-before: always !important;
        break-before: always !important;
        page-break-after: avoid !important;
        break-after: avoid !important;
        height: 0;
        overflow: hidden;
        width: 100%;
        visibility: hidden;
    }

    /* 表格行禁止截断 */
    .quote-table tbody tr {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
}

/* 响应式 */
@media (max-width: 1200px) {
    .quote-layout {
        grid-template-columns: 240px 1fr;
    }
}

@media (max-width: 768px) {
    .quote-layout {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }
    
    .quote-sidebar {
        display: none;
    }
    
    .info-row {
        grid-template-columns: 1fr;
    }
    
    .quote-totals {
        flex-direction: column;
    }
    
    .totals-section {
        width: 100%;
        margin-top: 20px;
    }
}

/* 空状态提示 */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 14px;
    margin-bottom: 10px;
}

.empty-state-hint {
    font-size: 12px;
    color: #999;
}

/* 下拉菜单样式 */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    z-index: 1000;
    margin-top: 4px;
}

.dropdown-menu.active {
    display: block;
    animation: slideDown 0.2s ease-out;
}

.dropdown-item {
    width: 100%;
    padding: 10px 16px;
    text-align: left;
    background: none;
    border: none;
    border-radius: 0;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    display: block;
    white-space: nowrap;
}

.dropdown-item:hover {
    background: var(--accent-color);
    color: #fff;
}

.dropdown-item:first-child {
    border-radius: 4px 4px 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 4px 4px;
}

.dropdown-arrow {
    margin-left: 4px;
    font-size: 10px;
    transition: transform 0.2s;
}

.dropdown.active .dropdown-arrow {
    transform: rotate(180deg);
}

/* 点击外部关闭下拉菜单 */
.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
}
