/* =========================================================
 * common.css — 通用样式（桌面端 & 移动端共用）
 * 包含：CSS 变量、重置、按钮、空状态、加载层、Toast、
 *       徽标、师傅/工单列表样式、滚动条、滚动优化
 * ========================================================= */

/* 1. 通用重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 2. CSS 变量 */
:root {
    --primary-color: #667eea;
    --primary-dark: #764ba2;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --primary-light: #f0f4ff;
    --success-color: #52c41a;
    --success-light: #f6ffed;
    --warning-color: #fa8c16;
    --warning-light: #fff7e6;
    --danger-color: #ff4d4f;
    --danger-light: #fff1f0;
    --text-primary: #1a1a1a;
    --text-secondary: #606266;
    --text-muted: #909399;
    --text-light: #c0c4cc;
    --bg-light: #f5f7fa;
    --bg-white: #ffffff;
    --border-color: #ebeef5;
    --border-light: #f2f3f5;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-primary: 0 8px 24px rgba(102, 126, 234, 0.3);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 999px;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* 3. body 基础样式 */
body {
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', sans-serif;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg-light);
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overscroll-behavior-y: contain;
    padding-top: env(safe-area-inset-top);
}

/* 4. 按钮基础样式 */
.btn {
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    min-height: 40px;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-success {
    background: #52c41a;
    color: white;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-outline {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-outline-danger {
    background: white;
    color: var(--danger-color);
    border: 2px solid var(--danger-color);
}

.btn-sm {
    padding: 6px 16px;
    min-height: 32px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 32px;
    min-height: 48px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

/* 5. 按钮 hover 样式（hover 设备） */
@media (hover: hover) {
    .btn:hover::before {
        left: 100%;
    }
    .btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }
}

/* 6. 按钮触摸态 */
.btn:active {
    transform: scale(0.96);
    opacity: 0.85;
}

/* 7. 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 14px;
}

/* 8. 加载层（loading-overlay） */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-normal);
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-content {
    background: white;
    padding: 40px 60px;
    border-radius: 12px;
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 9. Toast 提示 */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 24px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 10000;
    transform: translateX(400px);
    transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 220px;
}

.toast.show {
    transform: translateX(0);
}

.toast.success {
    border-left: 4px solid var(--success-color);
    background: linear-gradient(135deg, #f0fff4, #ffffff);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
    background: linear-gradient(135deg, #fff5f5, #ffffff);
}

.toast.warning {
    border-left: 4px solid var(--warning-color);
    background: linear-gradient(135deg, #fffaf0, #ffffff);
}

/* 10. 徽标（badge） */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
}

.badge-engineer {
    background: #e6f7ff;
    color: #1890ff;
}

.badge-brand {
    background: var(--primary-light);
    color: var(--primary-color);
}

.badge-status {
    background: var(--warning-light);
    color: var(--warning-color);
}

.badge-status.completed {
    background: var(--success-light);
    color: var(--success-color);
}

.badge-status.pending {
    background: var(--danger-light);
    color: var(--danger-color);
}

/* 11. 工单条目紧急度左边框 */
.workorder-item.overdue { border-left-color: #f44336 !important; }
.workorder-item.urgent  { border-left-color: #ff9800 !important; }
.workorder-item.warning { border-left-color: #ffc107 !important; }
.workorder-item.normal  { border-left-color: #4CAF50 !important; }

/* 12. 师傅表格行 */
.engineer-table-row:hover {
    background: #e3f2fd !important;
}

.engineer-table-row td:first-child {
    border-left: 3px solid transparent;
}

.engineer-table-row.overdue td:first-child { border-left-color: #f44336; }
.engineer-table-row.urgent  td:first-child { border-left-color: #ff9800; }
.engineer-table-row.warning td:first-child { border-left-color: #ffc107; }
.engineer-table-row.normal  td:first-child { border-left-color: #4CAF50; }

/* 13. 师傅工单列表（弹窗） */
.engineer-list-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.engineer-list-time {
    font-size: 13px;
}

.engineer-list-brand {
    background: #f3e5f5;
    color: #7b1fa2;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.engineer-list-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.engineer-list-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #666;
}

.engineer-list-label {
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

.engineer-list-value {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.engineer-list-value:hover {
    color: #667eea;
    text-decoration: underline;
}

/* 14. 师傅列表内容滚动条 */
#engineerListContent::-webkit-scrollbar {
    width: 6px;
}

#engineerListContent::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#engineerListContent::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 3px;
}

/* 15. 工单列表滚动条 */
.workorder-list::-webkit-scrollbar {
    width: 6px;
}

.workorder-list::-webkit-scrollbar-track {
    background: var(--bg-light);
}

.workorder-list::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

/* 16. 师傅列表遮罩层 */
.engineer-list-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
}

/* 17. 师傅列表表格：每行最小高度 */
.engineer-list-table tr {
    min-height: 48px;
}

/* 18. 移动端表格样式（文字更小，保持点击高度） */
@media (max-width: 768px) {
    .engineer-list-table {
        font-size: 12px !important;
    }
    .engineer-list-table th,
    .engineer-list-table td {
        padding: 10px 8px !important;
    }
    .engineer-list-table td,
    .engineer-list-table th {
        white-space: nowrap;
    }
}

/* 19. hover 设备卡片 hover 效果（避免触摸设备上"粘滞" hover） */
@media (hover: hover) {
    .engineer-stat-item:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-sm);
        background: linear-gradient(135deg, var(--primary-color), #3b82f6);
        border-color: var(--primary-color);
    }
    .engineer-stat-item:hover .engineer-stat-name,
    .engineer-stat-item:hover .engineer-stat-count {
        color: white;
    }
    .workorder-item:hover {
        transform: translateY(-3px);
        box-shadow: var(--shadow-md);
        border-left-color: var(--primary-color);
    }
    .stat-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }
    .file-upload:hover {
        background: rgba(255,255,255,0.3);
        transform: translateY(-2px);
    }
}

/* 20. 滚动优化（移动端平滑滚动） */
.workorder-list,
.sidebar,
#engineerListContent {
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: -ms-autohiding-scrollbar;
    scrollbar-width: thin;
}

/* 21. iPhone 底部安全区域补偿 */
.workorder-list {
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
}

/* 22. 页脚备案信息 */
.footer {
    padding: 10px 16px;
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

.footer-link {
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-link:hover {
    color: var(--primary-color);
}

/* 23. 卡片组件 */
.card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    transition: box-shadow var(--transition-normal);
}

.card-hover:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* 24. 表单输入框 */
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-white);
    transition: all var(--transition-fast);
    outline: none;
    font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

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

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* 25. 表格样式 */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-white);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.data-table th {
    background: #fafafa;
    padding: 14px 16px;
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-light);
}

.data-table td {
    padding: 14px 16px;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: var(--primary-light);
}

/* 26. 分页 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
}

.pagination button {
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.pagination button:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.pagination button.active {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
