.designer-calendar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.designer-calendar-modal {
  background: white;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  max-width: 800px;
  width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 24px 16px;
  border-bottom: 1px solid #f0f0f0;

  h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
  }

  .close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #95a5a6;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;

    &:hover {
      background: #f8f9fa;
      color: #e74c3c;
    }
  }
}

.designer-stats {
  padding: 20px 24px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-bottom: 1px solid #dee2e6;

  .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
  }

  .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);

    .stat-label {
      font-size: 12px;
      color: #6c757d;
      margin-bottom: 4px;
    }

    .stat-value {
      font-size: 18px;
      font-weight: 600;
      color: #2c3e50;

      &.warning {
        color: #e74c3c;
      }
    }
  }

  .workload-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);

    .workload-label {
      font-size: 14px;
      color: #6c757d;
      min-width: 60px;
    }

    .workload-bar {
      flex: 1;
      height: 8px;
      background: #e9ecef;
      border-radius: 4px;
      overflow: hidden;

      .workload-fill {
        height: 100%;
        border-radius: 4px;
        transition: width 0.3s ease;

        &.low {
          background: linear-gradient(90deg, #28a745, #20c997);
        }

        &.medium {
          background: linear-gradient(90deg, #ffc107, #fd7e14);
        }

        &.high {
          background: linear-gradient(90deg, #dc3545, #e74c3c);
        }
      }
    }

    .workload-percentage {
      font-size: 14px;
      font-weight: 600;
      color: #495057;
      min-width: 40px;
      text-align: right;
    }
  }
}

.calendar-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid #f0f0f0;

  .nav-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
    color: #495057;

    &:hover {
      background: #e9ecef;
      border-color: #adb5bd;
    }
  }

  .month-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
  }
}

.designer-calendar-modal {
  // 调整最大宽度，避免内容过窄导致日历看不全
  max-width: 1000px;
  width: 95vw;
}

.designer-stats {
  padding: 20px 24px;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-bottom: 1px solid #dee2e6;

  .stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
  }

  .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);

    .stat-label {
      font-size: 12px;
      color: #6c757d;
      margin-bottom: 4px;
    }

    .stat-value {
      font-size: 18px;
      font-weight: 600;
      color: #2c3e50;

      &.warning {
        color: #e74c3c;
      }
    }
  }

  .workload-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 16px;

    .workload-label {
      font-size: 14px;
      color: #6c757d;
      min-width: 60px;
    }

    .workload-bar {
      flex: 1;
      height: 8px;
      background: #e9ecef;
      border-radius: 4px;
      overflow: hidden;

      .workload-fill {
        height: 100%;
        border-radius: 4px;
        transition: width 0.3s ease;

        &.low {
          background: linear-gradient(90deg, #28a745, #20c997);
        }

        &.medium {
          background: linear-gradient(90deg, #ffc107, #fd7e14);
        }

        &.high {
          background: linear-gradient(90deg, #dc3545, #e74c3c);
        }
      }
    }

    .workload-percentage {
      font-size: 14px;
      font-weight: 600;
      color: #495057;
      min-width: 40px;
      text-align: right;
    }
  }

  .designer-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);

    .status-badge {
      padding: 6px 16px;
      border-radius: 20px;
      color: white;
      font-size: 14px;
      font-weight: 600;
    }

    .last-order {
      font-size: 12px;
      color: #6c757d;
    }
  }
}

.calendar-container {
  // 当屏幕较窄时允许水平滚动，确保完整查看7列
  padding: 0 24px 20px;
  overflow-x: auto;
}

.calendar-header {
  display: grid;
  // 使用 minmax 保证每列有最低宽度，减少像素舍入造成的对不齐
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 1px;
  margin-bottom: 8px;

  .weekday {
    box-sizing: border-box;
    padding: 12px 4px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #6c757d;
    background: #f8f9fa;
  }
}

.calendar-grid {
  display: grid;
  // 与 header 保持一致，保证列宽一致
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 1px;
  background: #dee2e6;
  border-radius: 8px;
  overflow: hidden;
  // 统一行高，避免内容挤压导致错位
  grid-auto-rows: 100px;
}

.calendar-day {
  box-sizing: border-box;
  background: white;
  min-height: 100px; // 提升可读性，确保忙闲标识完整展示
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;

  .day-number {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    z-index: 2;
  }

  .day-status {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;

    .status-indicator {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 4px;
      padding: 4px;
      border-radius: 6px;
      font-size: 10px;
      font-weight: 500;

      mat-icon {
        font-size: 16px;
        width: 16px;
        height: 16px;
      }

      &.idle {
        background: rgba(76, 175, 80, 0.1);
        color: #2e7d32;
        
        mat-icon {
          color: #4caf50;
        }
      }

      &.busy {
        background: rgba(33, 150, 243, 0.1);
        color: #1565c0;
        
        mat-icon {
          color: #2196f3;
        }
      }

      &.review {
        background: rgba(244, 67, 54, 0.1);
        color: #c62828;
        
        mat-icon {
          color: #f44336;
        }
      }
    }
  }

  .workload-bar-mini {
    position: absolute;
    bottom: 4px;
    left: 4px;
    right: 4px;
    height: 3px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    overflow: hidden;

    .workload-fill-mini {
      height: 100%;
      border-radius: 2px;
      transition: width 0.3s ease;

      &.medium {
        background: #ffc107;
      }

      &.high {
        background: #ff9800;
      }

      &.review {
        background: #f44336;
      }
    }
  }

  &.other-month {
    color: #adb5bd;
    background: #f8f9fa;
    opacity: 0.6;

    .day-status {
      opacity: 0.5;
    }
  }

  &.weekend {
    background: #fff5f5;
  }

  &.today {
    background: #e3f2fd;
    border: 2px solid #2196f3;

    .day-number {
      color: #1976d2;
      font-weight: 700;
    }
  }

  &.idle {
    background: #e8f5e8;
    border: 1px solid #4caf50;

    &:hover {
      background: #c8e6c9;
      transform: scale(1.02);
      box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
    }

    .day-number {
      color: #2e7d32;
    }
  }

  &.busy {
    background: #e3f2fd;

    .day-number {
      color: #1565c0;
    }

    &:hover {
      background: #bbdefb;
      transform: scale(1.02);
      box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
    }
  }

  &.review {
    background: #ffebee;
    border: 1px solid #f44336;
    cursor: not-allowed;

    .day-number {
      color: #c62828;
    }

    &:hover {
      transform: none;
      box-shadow: 0 2px 8px rgba(244, 67, 54, 0.2);
    }
  }

  &.stagnant {
    background: #fff3e0;
    border: 1px solid #ff9800;

    .day-number {
      color: #ef6c00;
    }
  }
}

// 响应式设计
@media (max-width: 768px) {
  .designer-calendar-modal {
    width: 95vw;
    margin: 10px;
  }

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

    .workload-indicator {
      flex-direction: column;
      align-items: stretch;
      gap: 8px;

      .workload-label {
        min-width: auto;
        text-align: center;
      }
    }
  }

  .calendar-legend {
    flex-wrap: wrap;
    gap: 12px;
  }

  .calendar-day {
    min-height: 70px;
    padding: 6px;

    .day-number {
      font-size: 12px;
    }

    .day-indicators {
      .order-count,
      .review-indicator {
        font-size: 9px;
        padding: 1px 3px;
      }
    }
  }
}

.calendar-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 16px 24px;
  border-top: 1px solid #f0f0f0;
  background: #f8f9fa;

  .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;

    .legend-color {
      width: 12px;
      height: 12px;
      border-radius: 2px;

      &.idle {
        background: #4caf50;
      }

      &.busy {
        background: #2196f3;
      }

      &.review {
        background: #f44336;
      }

      &.today {
        background: #1976d2;
        border: 1px solid #0d47a1;
      }
    }

    .legend-text {
      font-size: 12px;
      color: #6c757d;
    }
  }
}

.calendar-tips {
  padding: 16px 24px;
  background: #f8f9fa;
  border-top: 1px solid #dee2e6;

  p {
    margin: 0 0 8px;
    font-size: 14px;
    color: #495057;
  }

  ul {
    margin: 0;
    padding-left: 20px;
    font-size: 13px;
    color: #6c757d;
    line-height: 1.5;

    li {
      margin-bottom: 4px;
    }
  }
}