/* =========================================================
 * desktop.css — 桌面端样式（PC & 大屏平板）
 * 包含：Header、筛选栏、控制按钮组、侧边栏、统计面板、
 *       工单列表、师傅统计条目、响应式断点
 * ========================================================= */

/* 1. Header 顶部栏 */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: relative;
    z-index: 1000;
}

/* 2. Header 内容容器 */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

/* 3. Header 左侧（标题 + 统计） */
.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

/* 4. 标题 */
.header h1 {
    font-size: 18px;
    margin: 0;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* 5. 统计徽章 */
.header-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.1);
    padding: 6px 12px;
    border-radius: 20px;
}

.header-stats .stat-value {
    font-size: 16px;
    font-weight: 600;
}

.header-stats .stat-value.highlight {
    color: #4ade80;
}

.stat-divider {
    font-size: 14px;
    opacity: 0.4;
    margin: 0 4px;
}

.stat-label {
    font-size: 11px;
    opacity: 0.7;
    margin-left: 4px;
}

/* 6. Header 右侧（筛选 + 按钮） */
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* 7. 筛选栏 */
.header-filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-select-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-select-label {
    font-size: 14px;
}

.filter-select {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.25);
    color: white;
    padding: 6px 12px;
    padding-right: 32px;
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: 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='white' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.filter-select:hover {
    background-color: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.4);
}

.filter-select:focus {
    outline: none;
    background-color: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.6);
}

.filter-select option {
    background: #2c3e50;
    color: white;
}

/* 8. 控制按钮组 */
.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group label {
    font-weight: 500;
    font-size: 14px;
}

/* 9. select / input[type="date"] / button 基础 */
select, input[type="date"], button {
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition-fast);
    touch-action: manipulation;
}

/* 10. select 样式（基础版，不含移动端） */
select {
    background: rgba(255,255,255,0.95);
    color: var(--text-primary);
    min-width: 140px;
    cursor: pointer;
}

select:hover {
    background: white;
    transform: translateY(-1px);
}

/* 11. input[type="date"] 基础样式 */
input[type="date"] {
    background: rgba(255,255,255,0.95);
    color: var(--text-primary);
}

/* 12. file-upload（文件上传按钮容器） */
.file-upload {
    background: rgba(255,255,255,0.2);
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.file-upload:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
}

.file-upload input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* 13. btn-primary / btn-outline（桌面版特定色） */
.btn-primary {
    background: var(--success-color);
    color: white;
}

.btn-primary:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.btn-outline {
    background: transparent;
    border: 2px solid rgba(255,255,255,0.5);
    color: white;
}

.btn-outline:hover {
    background: rgba(255,255,255,0.1);
    border-color: white;
}

/* 14. 主容器（地图 + 侧边栏） */
.container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#map {
    flex: 1;
    height: 100%;
    min-width: 0;
}

/* 15. 侧边栏 */
.sidebar {
    width: 380px;
    background: var(--bg-white);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 16. 统计面板（师傅/品牌统计） */
.stats-panel {
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid var(--border-color);
}

.stats-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-fast);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-value.highlight {
    color: var(--success-color);
}

/* 17. 侧边栏 Header（工单列表标题 + 筛选标签） */
.sidebar-header {
    padding: 15px 20px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 18. 激活的筛选标签 */
.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-right: 10px;
}

.filter-tag {
    background: rgba(255,255,255,0.15);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-tag .close {
    cursor: pointer;
    opacity: 0.8;
    transition: var(--transition-fast);
}

.filter-tag .close:hover {
    opacity: 1;
}

/* 19. 工单列表（容器） */
.workorder-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

/* 20. 工单条目（卡片） */
.workorder-item {
    background: var(--bg-white);
    padding: 15px;
    margin-bottom: 12px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition-normal);
    border-left: 4px solid transparent;
}

.workorder-item:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-left-color: var(--primary-color);
}

.workorder-item.active {
    border-left-color: var(--success-color);
    background: linear-gradient(135deg, #f8f9fa 0%, white 100%);
}

.workorder-item h4 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 15px;
    font-weight: 600;
}

.workorder-item .info-row {
    color: var(--text-secondary);
    font-size: 13px;
    margin: 6px 0;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.workorder-item .info-label {
    color: var(--text-muted);
    min-width: 50px;
}

/* 21. 徽章容器 */
.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

/* 22. 师傅统计条目（tag 形式） */
.engineer-stats-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.engineer-stat-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #f5f7fa, #e9ecef);
    border-radius: 20px;
    transition: var(--transition-fast);
    border: 1px solid #e0e6ed;
    cursor: pointer;
}

.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;
}

.engineer-stat-item.active {
    background: linear-gradient(135deg, var(--success-color), #10b981);
    border-color: var(--success-color);
}

.engineer-stat-item.active .engineer-stat-name,
.engineer-stat-item.active .engineer-stat-count {
    color: white;
}

.engineer-stat-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 13px;
}

.engineer-stat-count {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.date-stat-name {
    font-weight: 500;
    font-size: 12px;
}

.date-stat-count {
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.brand-stat-name {
    font-weight: 500;
    font-size: 12px;
}

.brand-stat-count {
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

/* ========= 响应式断点 1：大屏平板 / 小屏笔记本（<= 1024px） ========= */
@media (max-width: 1024px) {
    .sidebar {
        width: 320px;
    }
    .header h1 {
        font-size: 16px;
    }
}

/* ========= 响应式断点 2：大号手机 / 竖屏平板（<= 768px） ========= */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    #map {
        height: 45vh;
        height: 45dvh;
        min-height: 280px;
    }
    .sidebar {
        width: 100%;
        flex: 1;
        height: auto;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    /* header 改为上下两行布局 */
    .header {
        padding: 10px 12px;
    }
    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .header-left {
        justify-content: space-between;
        width: 100%;
        gap: 10px;
    }
    .header-right {
        width: 100%;
        gap: 10px;
        justify-content: space-between;
    }
    .header h1 {
        font-size: 15px;
    }
    .header-stats {
        padding: 5px 10px;
    }
    .header-stats .stat-value {
        font-size: 14px;
    }

    /* 筛选栏更紧凑 */
    .header-filters {
        gap: 8px;
    }
    .filter-select {
        min-width: 90px;
        font-size: 12px;
        padding: 8px 24px 8px 10px;
    }

    /* 按钮：紧凑，但保证 ≥40px 触摸区 */
    .controls {
        gap: 8px;
        flex-wrap: nowrap;
        overflow-x: auto;
        width: 100%;
        -webkit-overflow-scrolling: touch;
    }
    .btn {
        padding: 8px 12px;
        font-size: 12px;
        min-height: 38px;
        white-space: nowrap;
    }
    .file-upload {
        padding: 8px 12px;
        font-size: 12px;
        min-height: 38px;
        white-space: nowrap;
    }

    /* 师傅标签加大触摸区域 */
    .engineer-stat-item {
        padding: 10px 14px;
        min-height: 38px;
        font-size: 13px;
    }
    .engineer-stat-name {
        font-size: 13px;
    }
    .engineer-stat-count {
        font-size: 12px;
        padding: 3px 9px;
    }

    /* 工单列表卡片 */
    .workorder-list {
        padding: 10px;
    }
    .workorder-item {
        padding: 12px;
        margin-bottom: 10px;
    }
    .stats-panel {
        padding: 14px;
    }
}

/* ========= 响应式断点 3：普通手机（<= 576px） ========= */
@media (max-width: 576px) {
    #map {
        height: 40vh;
        height: 40dvh;
        min-height: 260px;
    }
    .header h1 {
        font-size: 14px;
    }
    .header h1::after {
        content: '📍';
        margin-left: 4px;
    }
    .header-left {
        gap: 8px;
    }
    .header-stats .stat-value {
        font-size: 13px;
    }
    .stat-label {
        display: none;
    }

    /* 下拉和按钮：再紧凑一些，但保持触摸区 */
    .filter-select {
        min-width: 0;
        font-size: 12px;
        padding: 7px 22px 7px 8px;
        flex: 1;
    }
    .btn {
        padding: 8px 10px;
        font-size: 12px;
        min-height: 36px;
    }
    .file-upload {
        padding: 8px 10px;
        font-size: 12px;
        min-height: 36px;
    }

    /* 统计面板 */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .stat-card {
        padding: 12px;
    }
    .sidebar-header {
        padding: 12px 14px;
        font-size: 14px;
    }
}

/* ========= 响应式断点 4：小号手机（<= 430px / iPhone SE） ========= */
@media (max-width: 430px) {
    #map {
        height: 38vh;
        height: 38dvh;
        min-height: 240px;
    }
    .header {
        padding: 8px 10px;
    }
    .header-left {
        justify-content: space-between;
    }
    .header h1 {
        font-size: 13px;
    }
    .header-right {
        gap: 6px;
    }
    .btn {
        padding: 7px 8px;
        font-size: 11px;
        min-height: 34px;
    }
    .file-upload {
        padding: 7px 8px;
        font-size: 11px;
        min-height: 34px;
    }
    .filter-select {
        font-size: 11px;
        padding: 7px 20px 7px 8px;
    }
    .engineer-stat-item {
        padding: 8px 12px;
        min-height: 34px;
        font-size: 12px;
    }
}

/* ========= 横屏手机模式 ========= */
@media (max-height: 500px) and (orientation: landscape) {
    .container {
        flex-direction: row;
    }
    #map {
        height: 100%;
        flex: 1.3;
    }
    .sidebar {
        width: 38%;
        height: 100%;
    }
    .header {
        padding: 6px 12px;
    }
    .header h1 {
        font-size: 13px;
    }
    .btn {
        padding: 6px 10px;
        font-size: 11px;
        min-height: 32px;
    }
}

/* ========= 触摸设备卡片点击态 ========= */
.engineer-stat-item:active,
.workorder-item:active,
.stat-card:active {
    transform: scale(0.98);
    opacity: 0.9;
    transition: transform 0.1s ease, opacity 0.1s ease;
}

/* ========= 重置按钮（桌面版 ========= */
#desktopResetBtn {
    background: #95a5a6;
    color: white;
    transition: all 0.25s ease;
    opacity: 0.85;
}

#desktopResetBtn:hover {
    opacity: 1;
    background: #7f8c8d;
}

#desktopResetBtn.filter-active {
    background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
    opacity: 1;
    animation: desktopResetPulse 2s ease-in-out infinite;
    color: white;
    box-shadow: 0 2px 8px rgba(255,152,0,0.3);
}

#desktopResetBtn.filter-active:hover {
    box-shadow: 0 4px 12px rgba(255,152,0,0.5);
}

@keyframes desktopResetPulse {
    0%, 100% { box-shadow: 0 2px 8px rgba(255,152,0,0.3); }
    50% { box-shadow: 0 2px 14px rgba(255,152,0,0.5); }
}
