/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.header h1 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* 统计面板 */
.stats-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface-color);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-number {
    font-size: 32px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 14px;
}

/* 操作栏 */
.action-bar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.action-buttons-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.search-row {
    display: flex;
    gap: 12px;
    align-items: center;
    width: 100%;
}

.search-box {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 200px;
}

.search-box input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.filter-select {
    padding: 10px 30px 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface-color);
    font-size: 14px;
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* 按钮样式 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
    transform: translateY(-1px);
}

.btn-info {
    background: var(--info-color);
    color: white;
}

.btn-info:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.btn-search {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-search:hover {
    background: var(--bg-color);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-icon {
    font-size: 16px;
    line-height: 1;
}

.btn-large {
    padding: 15px 30px;
    font-size: 16px;
}

/* 零件列表 */
.parts-section {
    background: var(--surface-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.section-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.section-header h2 {
    font-size: 20px;
    color: var(--text-primary);
}

.table-container {
    overflow-x: auto;
}

.parts-table {
    width: 100%;
    border-collapse: collapse;
}

.parts-table th {
    background: var(--bg-color);
    padding: 16px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    border-right: 1px solid var(--border-color);
}

.parts-table th:last-child {
    border-right: none;
}

.parts-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    font-size: 14px;
}

.parts-table td:last-child {
    border-right: none;
}

/* 急件行样式 */
.parts-table tr.urgent-row {
    background-color: rgba(255, 82, 82, 0.1) !important;
}

.parts-table tr.urgent-row:hover {
    background-color: rgba(255, 82, 82, 0.2) !important;
}

.parts-table tr:hover {
    background: var(--bg-color);
}

.parts-table tr:last-child td {
    border-bottom: none;
}

/* 状态标签 */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-in_progress {
    background: #dbeafe;
    color: #1e40af;
}

.status-completed {
    background: #d1fae5;
    color: #065f46;
}

.status-rejected {
    background: #fee2e2;
    color: #991b1b;
}

.status-scheduled {
    background: #dbeafe;
    color: #1e40af;
}

.status-no_process {
    background: #f3f4f6;
    color: #4b5563;
}

.status-delivered {
    background: #6f42c1;
    color: white;
}

.status-not_started {
    background: #e9ecef;
    color: #495057;
}

/* 空状态 */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 16px;
}

/* 模态框 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 2vh 2vw;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface-color);
    border-radius: var(--radius);
    width: 90vw;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

.modal-large {
    max-width: 95vw;
    max-height: 90vh;
    resize: vertical;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* 批量添加窗口特别样式 */
#batchAddModal .modal-content.modal-large {
    width: 95vw;
    max-height: 85vh;
    max-width: 98vw;
    display: flex;
    flex-direction: column;
}

/* 详情模态框特别样式 */
#detailModal .modal-content.modal-large {
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

#detailModal .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

#detailModal .part-detail {
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* 质检历史记录区域滚动优化 */
#detailModal #qualityHistorySection {
    max-height: 30vh;
    overflow-y: auto;
}

#detailModal #qualityHistoryList {
    max-height: 25vh;
    overflow-y: auto;
    padding-right: 8px;
}

/* 生产流程节点区域滚动优化 */
#detailModal .process-nodes {
    max-height: 40vh;
    overflow-y: auto;
    padding-right: 8px;
}

#detailModal .modal-footer {
    flex-shrink: 0;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 18px;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

/* 表单样式 */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.required {
    color: var(--danger-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* 零件详情 */
.part-detail {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.detail-section {
    padding: 16px;
    background: var(--bg-color);
    border-radius: var(--radius);
}

.detail-section h4 {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-item label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.detail-item span {
    font-size: 14px;
    color: var(--text-primary);
}

.detail-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

/* 流程节点 */
.process-nodes {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.process-node {
    background: var(--surface-color);
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.process-node-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.process-node-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.process-node-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.process-node-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.node-completed {
    background: #d1fae5;
    color: #065f46;
}

.node-in_progress {
    background: #dbeafe;
    color: #1e40af;
}

.node-pending {
    background: #f3f4f6;
    color: #4b5563;
}

.node-qualified {
    background: #d1fae5;
    color: #065f46;
}

.node-disqualified {
    background: #fee2e2;
    color: #991b1b;
}

.node-disqualified_continue {
    background: #fef3c7;
    color: #92400e;
}

.process-node-note {
    margin-top: 8px;
    padding: 8px 12px;
    background: var(--bg-color);
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-secondary);
}

.node-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* 消息提示 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    background: var(--surface-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    z-index: 2000;
    transform: translateX(120%);
    transition: transform 0.3s ease;
}

.toast.active {
    transform: translateX(0);
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

.toast.info {
    border-left: 4px solid var(--info-color);
}

/* 工作记录样式 */
.work-record {
    border: 1px solid #dee2e6;
    padding: 8px;
    margin-bottom: 8px;
    border-radius: 4px;
    background: #f8f9fa;
}

/* 最终检验卡片样式 */
.final-inspection-card {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 6px 10px;
    background: #f8f9fa;
    margin: 6px 0;
    font-size: 12px;
}

.final-inspection-card .result {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 13px;
}

.final-inspection-card .detail {
    color: #495057;
    font-size: 11px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.final-inspection-card .detail span {
    white-space: nowrap;
}

.final-inspection-history-btn {
    margin-left: 8px;
    padding: 2px 8px;
    font-size: 11px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.final-inspection-history-btn:hover {
    background: #5a6268;
}

/* 质检结果徽章 */
.quality-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
}

.quality-qualified {
    background: #d4edda;
    color: #155724;
}

.quality-disqualified {
    background: #f8d7da;
    color: #721c24;
}

.quality-disqualified_continue {
    background: #fff3cd;
    color: #856404;
}

.quality-pending {
    background: #e2e3e5;
    color: #383d41;
}

.quality-in_progress {
    background: #cfe2ff;
    color: #084298;
}

/* 剩余天数样式 */
.remaining-normal {
    color: var(--success-color);
    font-weight: 500;
}

.remaining-warning {
    color: var(--warning-color);
    font-weight: 500;
}

.remaining-critical {
    color: var(--danger-color);
    font-weight: 600;
}

.remaining-overdue {
    color: #991b1b;
    font-weight: 700;
}

/* 部门卡片拖拽样式 */
.department-item {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.department-item.dragging {
    opacity: 0.3 !important;
    transform: scale(0.98);
    box-shadow: var(--shadow-md);
    transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.department-checkbox {
    cursor: pointer;
    pointer-events: auto;
}

.department-item .department-order-number {
    pointer-events: none;
}

/* 部门类型徽章 */
.dept-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
}

.badge-admin {
    background: #dc3545;
    color: white;
}

.badge-supervisor {
    background: #fd7e14;
    color: white;
}

.badge-clerk {
    background: #17a2b8;
    color: white;
}

.badge-worker {
    background: #28a745;
    color: white;
}

.badge-quality {
    background: #6f42c1;
    color: white;
}

/* 帮助按钮 */
#helpBtn {
    background: #17a2b8;
    border: none;
}

#helpBtn:hover {
    background: #138496;
}

/* 排序图标 */
.sort-icon {
    display: inline-block;
    font-size: 12px;
    margin-left: 4px;
    cursor: pointer;
}

/* 流转记录表格 */
#transferHistoryList td {
    padding: 8px;
    border: 1px solid #dee2e6;
}

/* 消息提醒区域紧凑样式 */
#transferAlertArea,
#supervisorPendingArea {
    margin-bottom: 8px !important;
    padding: 6px 10px !important;
}

#transferAlertArea > div:first-child,
#supervisorPendingArea > div:first-child {
    margin-bottom: 4px;
    font-size: 13px;
}

#transferAlertArea strong,
#supervisorPendingArea strong {
    font-size: 13px;
}

#refreshTransferBtn,
#refreshSupervisorPendingBtn {
    font-size: 11px;
    padding: 2px 6px !important;
}

#pendingTransferList,
#supervisorPendingList {
    margin-top: 4px !important;
    font-size: 12px;
}

#pendingTransferList > div,
#supervisorPendingList > div {
    margin-bottom: 4px !important;
    padding: 4px 0 !important;
    line-height: 1.3;
}

#pendingTransferList .btn-sm,
#supervisorPendingList .btn-sm {
    padding: 2px 6px;
    font-size: 11px;
}

#supervisorPendingList select.dept-select {
    width: 100px !important;
    margin: 0 4px !important;
    padding: 2px !important;
    font-size: 11px;
}

/* 响应式设计 */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .stats-panel {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .stat-number {
        font-size: 24px;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    .action-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .search-box {
        min-width: auto;
    }
    
    .parts-table {
        font-size: 11px;
    }
    
    .parts-table th,
    .parts-table td {
        padding: 8px 4px;
    }
    
    .modal-content {
        width: 98vw;
        max-width: none;
        padding: 12px;
    }
    
    .modal-large {
        max-width: 98vw;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 12px;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .stats-panel {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .action-bar {
        flex-wrap: wrap;
    }
    
    .parts-table {
        font-size: 12px;
    }
    
    .parts-table th,
    .parts-table td {
        padding: 10px 6px;
    }
    
    .modal-content {
        width: 95vw;
    }
    
    .modal-large {
        max-width: 95vw;
    }
    
    .detail-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    #detailModal #qualityHistorySection {
        max-height: 25vh;
    }
    
    #detailModal .process-nodes {
        max-height: 35vh;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .stats-panel {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .modal-content {
        width: 90vw;
    }
    
    .modal-large {
        max-width: 85vw;
    }
    
    #detailModal #qualityHistorySection {
        max-height: 28vh;
    }
    
    #detailModal .process-nodes {
        max-height: 40vh;
    }
}

@media (min-width: 1025px) and (max-width: 1440px) {
    .modal-content {
        width: 800px;
        max-width: 80vw;
    }
    
    .modal-large {
        max-width: 90vw;
    }
    
    #detailModal #qualityHistorySection {
        max-height: 30vh;
    }
    
    #detailModal .process-nodes {
        max-height: 45vh;
    }
}

@media (min-width: 1441px) {
    .modal-content {
        width: 900px;
        max-width: 70vw;
    }
    
    .modal-large {
        max-width: 85vw;
    }
    
    #detailModal #qualityHistorySection {
        max-height: 32vh;
    }
    
    #detailModal .process-nodes {
        max-height: 48vh;
    }
}

@media (max-height: 600px) {
    .header {
        margin-bottom: 12px;
        padding-bottom: 12px;
    }
    
    .header h1 {
        font-size: 22px;
    }
    
    .stats-panel {
        margin-bottom: 12px;
    }
    
    .stat-number {
        font-size: 24px;
    }
    
    .stat-label {
        font-size: 12px;
    }
    
    .modal-content {
        max-height: 95vh;
    }
    
    .modal-large {
        max-height: 95vh;
    }
    
    #detailModal #qualityHistorySection {
        max-height: 20vh;
    }
    
    #detailModal #qualityHistoryList {
        max-height: 18vh;
    }
    
    #detailModal .process-nodes {
        max-height: 30vh;
    }
}

/* 滚动条样式优化 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 4px;
    opacity: 0.5;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* 小屏幕下的滚动条更细 */
@media (max-width: 768px) {
    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }
}